Numerical methods with first order equations
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
As can be easily verified, the solution to the above initial value problem is
g(x) = - cos(x) + 2
Now with the solution of the above differential equation we can compare the results obtained by using ode45 to the actual values. Type the following commands into MATLAB
>> g = inline('-cos(x)+2')
>> [x,y,g(x),abs(y-g(x))]
Include the output in your writeup. The second and third columns give us the estimate that we get by using ode45 versus the actual function value at specified each value of x. How do the values in the two columns compare? The fourth column gives the absolute value of the difference between the function and our approximation.
(b) Now let us compare the results that ode45 gives us with the results we would get from using Euler’s method. Enter the following commands into MATLAB:
>> f = inline('sin(x)', 'x', 'y');
>> [x, z] = Euler(0.25, 0, 1, 10, f);
>> [y, z, g(x), abs(y - g(x)), abs(z - g(x))]
In the first column we have the results of ode45, in the second from our Euler's method routine, and in the third the values at x of the real solution to our differential equation. Columns four and five give the error of ode45 and Euler's method, respectively. Which method seems to give more accurate answers in this situation?
0 Kommentare
Antworten (1)
Richard Brown
am 9 Mai 2012
ode45
2 Kommentare
Walter Roberson
am 9 Mai 2012
We don't know that. The problem requires the inheriting of x and y, but we do not have proof that the y is produced by MATLAB's ode45 routine.
Richard Brown
am 9 Mai 2012
I was just answering the only part of the spiel that looked like a question (the last sentence) :)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!