Numerical Method question solutions

  1. Consider the following second order differential equation: d2 u (N — 1) du
— + —u = O in (0, 1), (0.1) dr r dr r2 where 1 + I (N — and N 1, 2, 3.
  • Find (erplicitly) all the solutions to (0.1) having the form
Hint: make the change of variables t log(r) for r e (0, 1). Find the ODE that v(log(r)) v(t) solves. Observe that this change of variable maps (0, 1) (—00, 0).
  • Find the exact solution for the ODE (0.1) with the Final Values
u(l) 0, du (l) —— 1. dr
Hint: Use the explicit solutions found in i.
  • Write one MATLAB script to solve numerically the ODE (0.1) + Final Value problem in ii.. Hint: rlYansforrn the Final Value Problem into an IVP reversing the interval (0, 1) using
The script must contain at least one implementation based on the Crank-Nicholson method and another based on the Runge-Kutta method of order 2.
Include plots to compare the implementatioms against the true sohltion. Provide also analysis of your findings.

댓글 수: 2

James Tursa
James Tursa 2021년 6월 1일
What have you done so far? What specific problems are you having with your code?
Can you add an image showing the differential equation and instructions? I can't understand what you have posted.
Mehmet Çuha
Mehmet Çuha 2021년 6월 3일
편집: darova 2021년 6월 5일
ı am trying to use this code but I cant replaces variables .
function [t,u]=feuler(odefun,tspan,y0,Nh,varargin)
%FEULER Solves differential equations using the forward
% Euler method.
% [T,Y]=FEULER(ODEFUN,TSPAN,Y0,NH) with TSPAN=[T0,TF]
% integrates the system of differential equations
% y'=f(t,y) from time T0 to TF with initial condition
% Y0 using the forward Euler method on an equispaced
% grid of NH intervals.
% Function ODEFUN(T,Y) must return a vector, whose
% elements hold the evaluation of f(t,y), of the
% same dimension of Y.
% Each row in the solution array Y corresponds to a
% time returned in the column vector T.
% [T,Y] = FEULER(ODEFUN,TSPAN,Y0,NH,P1,P2,...) passes
% the additional parameters P1,P2,... to the function
% ODEFUN as ODEFUN(T,Y,P1,P2...).
h=(tspan(2)-tspan(1))/Nh;
y=y0(:); % always creates a column vector
w=y; u=y.';
tt=linspace(tspan(1),tspan(2),Nh+1);
for t = tt(1:end-1)
w=w+h*odefun(t,w,varargin{:});
u = [u; w.'];
end
t=tt';
return

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

질문:

2021년 6월 1일

편집:

2021년 6월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by