Integral approximation with midpoint method

조회 수: 12 (최근 30일)
Dana Chica
Dana Chica 2017년 3월 13일
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?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Stability Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by