Integral approximation with midpoint method
Mostrar comentarios más antiguos
I want to write a code for the Integral approximation with the midpoint method.
Mathematically, I was thinking like this: y'(t)=f(t,y(t))=-y(t)
The rectangle rule: y(t + h)=y(t) + h · f(t+h/2,y(t)+h/2*f(t,y(t)))
for:
h=0.5 and y(0)=1 (t0=0, y(t0)=1)
I would like to calculate the next step: t1=t0+h=0.5, y(t1)=?
y(t1)=y(t0+h)=y(t0)+h*f(t0+h/2,y(t0)+h/2*f(t0,y(t0)))=
=1+0.5*f(0.25,1+0.25*f(0,1))=
=1+0.5*f(0.25,1+0.25*(-1))=
=1+0.5*f(0.25,0.75) = 1+0.5*(-0.75)=0.625
I don't know how to represent the function f in Matlab (syms ?) so that it would know to calculate f(0,1) for example.
Can someone help me, please?
Respuestas (0)
Categorías
Más información sobre Numerical Integration and Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!