Backward Euler for Van der Pol equation

조회 수: 5 (최근 30일)
Othman El Hammouchi
Othman El Hammouchi 2021년 4월 15일
I'm trying to program the Backward Euler to solve Van der Pol's equation. Theoretically, this method should be stable for any step size h>0. It doesn't produce particularly stellar results, however, and my guess would be that this has to do with the inability of fsolve or the standard fixed point iteration to obtain results. Here's the code for my two attempts:
clear; clc; close all;
u0=[1;0]; %initial value
t0=0; tf=1000; %interval
N = 200; %number of points
h=(tf-t0)/(N-1); %step size
mu = 0.1; %Van der Pol parameter
f = @(t,y) vanderpoldemo(t,y,mu);
t = t0:h:tf;
u = zeros(2,N);
u(:,1)=u0;
%% attempt 1
for i = 2:N
u(:,i)=rand(1,2);
for times = 1:2
u(:,i) = u(:,i-1)+h*f(t(i-1),u(:,i));
end
end
plot(t,u(1,:))
%% attempt 2
for i = 2:N
u(:,i) = fsolve(@(U) u(:,i-1)+h*f(t(i-1),U)-U,rand(1,2), options);
end
I'm quite frustrated by this and would greatly appreciate any help.

답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by