CourseWork Questions

Verified

Added on  2023/04/20

|8
|979
|215
AI Summary
This document contains questions and solutions for CourseWork Questions. It includes solutions for Question 1, Question 2, Question 12, and Question 14. The solutions cover topics such as plotting functions, gas laws, solving differential equations, and applying the shooting method.
tabler-icon-diamond-filled.svg

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
CourseWork Questions............................................................................................................................1
Question 1...............................................................................................................................................1
Question 2...............................................................................................................................................3
Question 12.............................................................................................................................................4
Question 14.............................................................................................................................................6
CourseWork Questions
clear all
close all
clc
Question 1
% Question 1: Part A:1
x=0:0.001:3;
fx=(14*exp(x-2))-(12*exp(x-2))-7*x.^3+20*x.^2-26*x+12;
fx1=diff(fx);
plot(x,fx,'r-.','LineWidth',1.2)
grid on
xlabel('x')
ylabel('f(x)')
% Question 1: Part A:2
fc=@(x) ((14*exp(x-2))-(12*exp(x-2))-7*x.^3+20*x.^2-26*x+12);
xb = fzero(fc,15)
init=20;
tol=1e-2;
maxiter=1e4;
%[root, error_estimate]=newton('fx','fx1',200,tol,maxiter)
%Question 1: Part B
fb=(1-3./(4*x)).^(1/3);
y=abs(fb);
figure(2)
plot(x,y)
xlabel('x')
ylabel('f(x)')
grid on
y1=@(x) (1-3/(4*x))^(1/3);
%xc = fzero(y1,15)
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
xb =
9.8090
Document Page
Question 2
clear
close all
% v - molar volumes vector
% fg - value of functions at v
%For oxygen
R=0.0820578; %molar gas constant
a=1.36; %L^2 atm/mole^2
b=0.003183; %L/mole
P=15; %pressure (atm)
T=320; %one mole of oxygen
v=linspace(0,50);
y=myVanderWaals(v,R,a,b,P,T);
figure(1)
plot(v,y,'r-.')
grid on
xlabel('Samples')
ylabel('Van der Waals')
title('Gas Laws')
Document Page
legend('y')
clear
% For Benzene vapor
R=0.0820578; %molar gas constant
a=18.0; %L^2 atm/mole^2
b=0.1154; %L/mole
P=20; %pressure (atm)
T=700; %one mole of oxygen
v=linspace(0,50);
y=myVanderWaals(v,R,a,b,P,T);
figure(1)
plot(v,y,'b-.')
grid on
% v0=ginput(1);
xlabel('Samples')
ylabel('Van der Waals')
title('Gas Laws')
legend('y')
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Question 12
clear
tspan = [0 0.15];
c = 83;
val_b = 0.14;
omega = 120*pi;
E=165;
N=600;
A=omega*E/N;
ode_fun = @(t,u,c,val_b,A,omega)[u(2);-u(1)-c*u(2)-val_b*u(1).^3+A*cos(omega*t)];
[t,u] = ode15s(@(t,u)ode_fun(t,u,c,val_b,A,omega),tspan,[0 0]);
figure(1);
plot(t,u);
xlabel('Time');
ylabel('State');
grid on
acc = -u(:,1)-c*u(:,2)-val_b*u(:,1).^3+A*sin(omega*t);
figure(2);
plot(t,acc);
xlabel('Time(sec)');
ylabel('Acceleration');
grid on
Document Page
Document Page
Question 14
clear
clc
close all
% applying the shooting method
%[y1, y2]=shooting_method(fun,0.001,1e-5,1,2,[0 0],'fd')
clf
alpha=1/2;
beta=log(2);
a=1;
b=2;
figure(1)
[xv,yv]=ode45('funsysa',[a b],[alpha;0;0;1]);
plot(xv,yv(:,1),'r-.')
hold on
n=length(yv(:,1));
y1n=yv(n,1);
y2n=yv(n,3);
yvsol=yv(:,1)+(beta-y1n)/y2n*yv(:,3);
truesol=-1./(xv.^2).*(2-4*xv+3/2*xv.^2-xv.^2.*log(xv));
plot(xv,yvsol,'b-')
title('Shooting Method: y"=-4/x*y-2/x^2*y+2*ln(x)/x^2, y(1)=1/2,y(2)=ln2')
text(1.2,0.4,'IVP: y_1"=-4/x*y_1-2/x^2*y_1+2*ln(x)/x^2, y_1(1)=1/2,y_1(1)=0')
text(1.2,0.6,'- y=y_1+(beta-y_1(2))/y_2(2)*y_2')
axis([1 2 0 0.8])
grid on
hold off
figure(2)
semilogy(xv,abs(yvsol-truesol),'b-.')
title('Shooting Method: y"=-4/x*y-2/x^2*y+2*ln(x)/x^2, y(1)=1/2,y(2)+ln2')
ylabel('|y(x_i)-y_i|')
xlabel('x')
grid on
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
chevron_up_icon
1 out of 8
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]