Free to use, no account

Differensialligningsløser

Tilnærm et førsteordens initialverdiproblem y′ = f(x,y) med Runge–Kutta-metoden av fjerde orden og fast steglengde. Oppgi den deriverte, startpunkt og startverdi, endepunkt og antall trinn. Alt kjøres i denne nettleseren.

Bruk x og y, tall, + − × ÷ og ^. Funksjonene sin, cos, tan, exp, ln, log, sqrt og abs støttes. Skriv multiplikasjon eksplisitt, for eksempel x*y.

Klassisk RK4 med fast steglengde, bare for førsteordens initialverdiproblemer for ordinære differensialligninger. Støtter opptil 10 000 trinn; x må være innenfor ±1 000 000 og y innenfor ±1 000 000 000 000. Grafen og CSV-filen viser opptil omtrent 101 beregnede punkter. Numeriske resultater kan være unøyaktige nær diskontinuiteter og singulariteter eller for stive ligninger. Verktøyet finner ikke symbolske allmenne løsninger og garanterer ikke feilmarginen.

Hvordan fungerer RK4-løseren for differensialligninger?

RK4 anslår løsningen ved å beregne stigningstallet fire ganger per trinn. Mindre trinn gir ofte bedre nøyaktighet for jevne løsninger, men dette numeriske estimatet er ikke en symbolsk eller eksakt løsning.

Veiledning

Slik bruker du differential-equation-solver

The Differential Equation Solver finds an approximate numerical answer to a first-order problem of the form y' = f(x, y) with a starting value. You type the right-hand side, the starting x and y, the end x and a step count. It uses the classical fourth-order Runge-Kutta method (RK4), draws the curve and lets you export the sampled points. It does not give a formula for y and it does not prove that the answer is right.

Slik gjør du

  1. Type the derivative f(x, y) using x, y, numbers, + - * / and ^, with the functions sin, cos, tan, exp, ln, log, sqrt and abs. Write every multiplication, for example 2*x and not 2x.
  2. Enter the starting x (x0), the starting value y0 and the end x. The end can be smaller than the start, and the solver then steps backwards.
  3. Set the number of integration steps from 1 to 10,000. More steps usually help on a smooth problem but take longer.
  4. Press Solve numerically, read the final value, view the graph, and copy the table or download the points as CSV or the graph as SVG.

Eksempler

Exponential growth

Du skriver inn
Derivert
y
X0
0
Y0
1
Sluttverdi for x
1
Steg
100
Du får
Endelig y-verdi
2.718281828234404

The exact answer to y' = y with y(0) = 1 is e to the power x, so y(1) is e, about 2.718281828459045. RK4 with 100 steps lands within about 2 in 10 billion of it.

Kjørt med verktøyets egen kode.

A polynomial that RK4 gets exactly

Du skriver inn
Derivert
2*x
X0
0
Y0
0
Sluttverdi for x
3
Steg
10
Du får
Endelig y-verdi
9

The exact solution is y = x squared, so y(3) is 9. RK4 is exact when the slope depends only on x and is a low-degree polynomial, so even 10 steps reach 9. Most problems are not this kind.

Kjørt med verktøyets egen kode.

Too few steps

Du skriver inn
Derivert
-2*y
X0
0
Y0
1
Sluttverdi for x
1
Steg
4
Du får
Endelig y-verdi
0.13554977050717967

The exact answer is e to the power -2, about 0.135335. Four large steps give 0.13555, a visible error. Try more steps and watch the final value settle toward the exact one.

Kjørt med verktøyets egen kode.

A slope that blows up

Du skriver inn
Derivert
1/(x-1)
X0
0
Y0
1
Sluttverdi for x
1
Steg
10
Du får
Resultat
no solution
Årsak
The derivative is undefined or non-finite for these values.

At x = 1 the slope divides by zero, so the solver stops and shows its check-your-inputs message. Typing 2x without a star also fails, because the parser reads it as unexpected text.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Check a hand-worked or textbook first-order initial-value problem against a numerical answer.
  • Plot a quick curve for growth, decay or cooling models with a simple slope.
  • See in practice how the step count changes the accuracy of a numerical method.
  • Export sampled points to a spreadsheet to compare with an exact formula or measured data.

Begrensninger

  • It solves only one first-order equation of the form y' = f(x, y) with one starting value. Systems of equations and higher-order equations are not supported.
  • Expressions can be at most 180 characters and 128 tokens. Steps go from 1 to 10,000, x must stay within plus or minus 1,000,000 and y within plus or minus one trillion.
  • RK4 uses a fixed step. It cannot adapt near a sharp change, a singularity or a stiff problem, and the tool gives no error bound.
  • The graph and CSV hold about 101 sampled points even when you ask for 10,000 steps, so they show a thinned view of the work.

Tips

  • Run the same problem with 10, 100 and 1,000 steps. If the final value stops changing in the digits you care about, you can trust it more.
  • Use ln for the natural logarithm and log for base 10, and pi and e as constants.
  • Test your typing on a simple problem with a known answer, such as y or 2*x, before you move on to a harder expression.

Vanlige spørsmål

What does RK4 do?

RK4 is the classical fourth-order Runge-Kutta method. In each step it samples the slope four times, at the start, twice in the middle and at the end, and mixes them with weights 1, 2, 2 and 1 divided by six to move forward.

Does this give an exact solution?

No. It gives a numerical approximation at sampled points. It does not give a symbolic formula, check that a unique solution exists or state an error bound. Comparing runs with more steps is the practical way to judge it.

How many steps should I use?

Start with 100 and double it. If the final value no longer changes in the digits that matter to you, the answer is probably stable. A smooth equation often settles quickly, while one with a sharp change may never settle.

Why do I get an error for 2x?

The parser does not allow implicit multiplication. Write 2*x, and write x*y for the product of x and y. Brackets, powers with ^ and the listed functions are supported.

Which functions and constants can I use?

You can use sin, cos, tan, exp, ln, log (base 10), sqrt and abs, the constants pi and e, and the variables x and y. The usual order of operations applies, and ^ is read from right to left.

Can I solve a system or a second-order equation?

Not directly. The tool takes one first-order equation. A second-order equation can sometimes be rewritten as two first-order ones, but this page has no way to enter more than one equation.

Is my equation sent to a server?

No. The page says that the calculation, the graph and the CSV are made in your browser and that nothing is uploaded or saved.

Kilder

Ofte stilte spørsmål

Hvordan fungerer RK4-løseren for differensialligninger?

RK4 anslår løsningen ved å beregne stigningstallet fire ganger per trinn. Mindre trinn gir ofte bedre nøyaktighet for jevne løsninger, men dette numeriske estimatet er ikke en symbolsk eller eksakt løsning.

Lastes ligningen og verdiene mine opp?

Nei. Beregningen, grafen og CSV-filen lages i nettleseren. Dette verktøyet laster ikke opp eller lagrer inndataene dine.

Hva beregner Runge–Kutta-metoden?

Den anslår løsningskurven fra et startpunkt ved gjentatte ganger å bruke flere derivatprøver i hvert trinn. Denne siden bruker den klassiske Runge–Kutta-metoden av fjerde orden.

Hvor mange trinn bør jeg bruke?

Begynn med eksemplet og sammenlign resultatene med flere trinn. Et mindre trinn kan forbedre en jevn løsning, men kan ikke rette opp en singularitet eller gjøre en stiv ligning egnet for denne enkle metoden.

Kan den løse alle differensialligninger nøyaktig?

Nei. Den tilnærmer numerisk støttede førsteordens startverdiproblemer. Den gir ikke en symbolsk generell løsning, beviser ikke entydighet og garanterer ingen feilgrense.