- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Wave)
We consider the initial value problem
$$x'(t)=-y(t), t \in [0,1] \\ y'(t)=x(t), t \in [0,1] \\ x(0)=1, y(0)=0$$
I want to solve approximately the above problem using the forward Euler method in uniform partition of 100 and 200 points.
I have written the following code in matlab:
Is my code right? (Thinking)
We consider the initial value problem
$$x'(t)=-y(t), t \in [0,1] \\ y'(t)=x(t), t \in [0,1] \\ x(0)=1, y(0)=0$$
I want to solve approximately the above problem using the forward Euler method in uniform partition of 100 and 200 points.
I have written the following code in matlab:
Code:
N=100;
h=1/N;
y=zeros(N);
A=[0 -1;1 0];
for (i=1:100)
y=(eye(N,N)+A*h)*y
i=i+1;
end
y
Is my code right? (Thinking)