Sie sind auf Seite 1von 7

ADVANCED ENGINEERING MATHEMATICS – MATLAB

Submitted in fulfillment of the requirements of

Advanced Engineering Mathematics – DE-ZG535

(Assignment 1)

By

NAME : HIMANSHU KUMAR

ID NO:2018 HT 30562

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE ,


PILANI CAMPUS
First Semester 2018-19
Given Problem :
Instructions: Submit the “m”file, along with ppt slides for each problem with solutions.

1) The temperature of a bearing cooling to room temperature after being taken out of an heat
treatment oven is given by dT/dt=c(T−23) where c=−0.028. 23°C is the ambient temperature.
When the bearing is removed from the oven (t=0 minutes), the bearing’s temperature is 175 ∘C
Find solutions for this differential equation from time range 0 to 100 s using

a) ODE45 (Inbuilt Numercial solver)


b) Euler’s Numerical method

Plot the resultant graph.

ANS:

(a) Script (ODE45 (Inbuilt Numercial solver)

tspan=[0 100]

T0 = 175; 

[t,T]=ode45(@(t,T)-0.028*(T-23),tspan,T0);
plot (t,T,'-*')
[t,T]

2
(b) Script (Euler’s Numerical Method)

% Problem 1b) : Temperature of a bearing cooling to room temperature


% after being taken out of an heat treatment oven is given by dT/dt=c(T−23)
% To solve by (b) Euler s Numerical method
F= @(t,T) c*(T-23);
c=-0.028
t0=0;
h=0.1;
tfinal=100;
T0=175;
Tout=euler73(F,t0,h,tfinal,T0)
ans=[(t0:h:tfinal)',Tout]
plot(t0:h:tfinal,Tout)
hold on
function Tout = euler73(F,t0,h,tfinal,T0) T=T0;
Tout=T;
for t=t0:h:tfinal-h s=F(t,T);
T=T+h*s;
Tout=[Tout;T];
end
end

3
𝒅𝒚
2) Solve 𝒅𝟐 𝒚/𝒅𝒙𝟐 + 𝟒 ∗ 𝒅𝒙 − 𝟐 ∗ 𝒚 = 𝟐 ∗ 𝒙𝟐 − 𝟑 ∗ 𝒙 + 𝟔

Using appropriate solution technique

syms y(x)
ode= diff(y,x,2)+4*diff(y)-2*y==2*x^2-3*x+6;
ysol(x)=dsolve(ode)

ysol(x) =

C1*exp(-x*(6^(1/2) + 2)) - (5*x)/2 + C2*exp(x*(6^(1/2) - 2)) -


x^2 - 9

4
𝑑2 𝜃
3) Solve + 𝜃 = 0; 𝜃 (0) = 1 ; 𝜃 ′ (0) = 0
𝑑𝑡 2

Using method of your choice.


Script
% To Solve (d^2 θ)/(dt^2 )+θ=0; θ(0)=1 ; θ^' (0)=0
syms theta(t)
Dtheta=diff(theta);
ode=diff(theta,t,2)+theta==0;
cond1=theta(0)==1;
cond2=Dtheta(0)==0;
conds=[cond1 cond2];
thetasol=dsolve(ode,conds)
ezplot(thetasol)
grid on

5
4. Implement RK4 to solve y’= 2x -3y +1 ; y(1)=5; Find y(1.5) step size h=0.1;
repeat with h=0.05; P lot the results h=0.1 and h=0.05 in the same graph with
different colours.

F=@(x,y)2*x-3*y+1
x0=1;
%h=0.1;
h=0.05;
xfinal=1.5;
y0=5;
rkfour(F,x0,h,tfinal,y0);
x=x0:h:tfinal
x=[x',ans]
%plot(x0:h:xfinal,ans,'-+')
%hold on
plot(x0:h:xfinal,ans,'-*')
hold on
function yout =rkfour(F,x0,h,tfinal,y0)
y=y0;
yout=y;
for t=x0:h:tfinal-h
k1=F(t,y);
k2=F(t+(0.5*h),y+(o.5*k1*h));
k3=F(t+0.5*h,y+0.5*k2*h);
k4=F(t+h,y+k3*h);
y=y+((h/6)*(k12*k2+2*k3+k4));
yout=[yout;y];
end
end

6
***************************************

Das könnte Ihnen auch gefallen