Calculator Input
Use standard math syntax like x+y, sin(x)-0.5*y, or exp(-x).
Example Data Table
This example uses dy/dx = x + y, y(0)=1, h=0.2, and the RK4 method.
| Step | x | Approx y | Exact y | Absolute Error |
|---|---|---|---|---|
| 0 | 0.000000 | 1.000000 | 1.000000 | 0.000000 |
| 1 | 0.200000 | 1.242800 | 1.242806 | 0.000006 |
| 2 | 0.400000 | 1.583636 | 1.583649 | 0.000013 |
| 3 | 0.600000 | 2.044213 | 2.044238 | 0.000025 |
| 4 | 0.800000 | 2.651041 | 2.651082 | 0.000041 |
| 5 | 1.000000 | 3.436502 | 3.436564 | 0.000062 |
Formula Used
This calculator solves first order ordinary differential equations.
The model form is dy/dx = f(x,y) with y(x0)=y0.
Euler Method
y(n+1) = y(n) + h * f(x(n), y(n))
Heun Method
k1 = f(x(n), y(n))
k2 = f(x(n)+h, y(n)+h*k1)
y(n+1) = y(n) + h*(k1+k2)/2
RK4 Method
k1 = f(x(n), y(n))
k2 = f(x(n)+h/2, y(n)+h*k1/2)
k3 = f(x(n)+h/2, y(n)+h*k2/2)
k4 = f(x(n)+h, y(n)+h*k3)
y(n+1) = y(n) + h*(k1 + 2*k2 + 2*k3 + k4)/6
Error Metrics
If an exact solution is supplied, the calculator also computes:
Absolute Error = |Exact y - Approx y|
RMSE = sqrt(sum(error²) / total_points)
How to Use This Calculator
- Enter the differential equation as
f(x,y). - Enter the initial point values for
x0andy0. - Choose the final x position for integration.
- Set the step size. Smaller steps usually improve accuracy.
- Select Euler, Heun, or RK4.
- Optionally add an exact solution using only
x. - Press Solve ODE to generate the table and graph.
- Download the generated results as CSV or PDF.
FAQs
1. What does this calculator solve?
It solves first order ordinary differential equations numerically. You provide dy/dx = f(x,y), the initial condition, step size, method, and ending x value.
2. Which method is usually most accurate?
RK4 is usually the most accurate among the three included methods for the same step size. Euler is simplest, while Heun often improves Euler noticeably.
3. Why does step size matter?
Step size controls how far the solver moves at each iteration. Smaller steps usually reduce approximation error, but they also increase computation and table length.
4. Can I compare against an exact solution?
Yes. Enter an exact formula using only x. The calculator then shows exact values, absolute errors, maximum error, and RMSE.
5. What syntax should I use?
Use expressions like x+y, sin(x)-0.2*y, exp(-x), sqrt(x+1), or log(x+2). Standard operators and common functions are supported.
6. Why do I get an invalid expression message?
That usually means the formula contains unsupported characters or unsupported function names. Check spelling, parentheses, commas, and variable usage before solving again.
7. Can I use this for stiff equations?
You can test stiff equations, but explicit methods like Euler, Heun, and RK4 may require very small steps for stability. Specialized stiff solvers are better for hard cases.
8. What does NumPy style mean here?
It means the calculator presents results in a clean array-like workflow. You get ordered numeric sequences, exportable tables, and a plotted trajectory similar to scientific computing practice.