Numerical methods with first order equations
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Richard Brown
el 9 de Mayo de 2012
ode45
2 comentarios
Walter Roberson
el 9 de Mayo de 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
el 9 de Mayo de 2012
I was just answering the only part of the spiel that looked like a question (the last sentence) :)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!