Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

1. (10 points) Use the bisection method with tol = 10−12 to find ALL ZEROS in the interval [0, 1] for the following function: f(x) = x3 − (a1 − exp(a2x))x2 + a3x− a4 with a1 = 1.42, a2 = −7.89, a3 =...

1 answer below »
1. (10 points) Use the bisection method with tol = 10−12 to find ALL ZEROS in the
interval [0, 1] for the following function: f(x) = x3 − (a1 − exp(a2x))x2 + a3x− a4
with a1 = 1.42, a2 = −7.89, a3 = 0.52, a4 = XXXXXXXXXXPresent numerical results in a table
as follows:
Here, [a, b] is the starting interval used in the bisection method to compute the zero.
Put each zero found and the related computational data in one row. Use more rows if
more than one zero are found.
2. (10 points) Consider the following nonlinear function:
f(x) = sin
(
a1 + (a2 − exp(a3x))x2 + a4x3
)
.
(a) Use the secant method to compute the zeros of f in the interval [0, 1] with the
following parameters:
a_1 = 0.1; a_2 = -3.2; a_3 = -5; a_4 = -1;
Use the following inputs for the secant method:
tol = 10^(-12); nmax = 1000;
Present numerical results in a table as follows:
1
zero found a b Iterations Used
zero found Residual NOI
Add more rows for multiple zeros found. Present your script for generating these
numerical results. “NOI” in the table means the number of iteration actually
used by the method.
(b) Use Newton’s method to compute the zeros of f in the interval [0, 1] with the
following parameters:
a1 = 0.2; a2 = 4.5; a3 = -5; a4 = -1;
Use the following inputs for the Newton’s method:
tol = 10^(-12); nmax = 1000;
Present numerical results in a table as follows:
zero found Residual NOI
Add more rows for multiple zeros found. Present your script for generating these
numerical results. “NOI” in the table means the number of iteration actually
used by the method.
3. (30 points) Consider the following nonlinear system for p,Q1, Q2 and Q3:
Q1 +Q2 +Q3 = 0,
p
γ
+ c1sign(Q1)Q
2
1 + z1 = 0,
p
γ
+ c2sign(Q2)Q
2
2 + z2 = 0,
p
γ
+ c3sign(Q3)Q
2
3 + z3 = 0.
and sign(x) is the so called sign function whose values are 1 or 0 or −1 depending
whether x is positive, zero, or negative. We can put the given nonlinear system in the
vector form f(x) = 0 by setting
x =

x1
x2
x3
x4
 =

Q1
Q2
Q3
p

(a) (10 points) Implement f(x) in a Matlab function whose interface is as follows:
function f = fun_Qp(x, gam, c, z)
and implement the Jacobian of f(x) in a Matlab function whose interface is as
follows:
2
function J = fun_QpJ(x, gam, c, z)
where gam is for the value of γ, and c, z are vectors fo
c = [c1, c2, c3]
T , z = [z1, z2, z3]
T .
(b) (10 points) Find approximations to Q1, Q2, Q3, p by using the Broyden’s method
with the initial matrix B0 specified in the following table to solve this nonlinea
system with parameters:
γ = 9791, z1 = −19, z2 = −7, z3 = 2,
c1 = 3.721, c2 = 64.55, c3 = 21.273.
Use the following inputs for the Broyden’s method:
x0 = [1; 1; 1; 1*10^5]; tol = 10^(-8); nmax = 200;
Present numerical results in the following table:
B0 Identity Matrix approxJ_fdh approxJ_compl
esidual
number of iter.
Q2
p
Present the scripts for generating the numerical results in the table above. Among
the three choices for the initial matrix B0, which one is the best? Why? Is the
approximate Jacobian by the complex variable method a good approximation to
the exact Jacobian at the specified x0? Why? Why not?
(c) (10 points) Find approximations to Q1, Q2, Q3, p by using Newton’s method to
solve this nonlinear system with the following parameters:
γ = 9790, z1 = −19, z2 = −7, z3 = 2,
c1 = 3.73, c2 = 64.6, c3 = XXXXXXXXXX.
Use the following inputs for the Newton’s method:
x0 = [1; 1; 1; 1*10^5]; tol = 10^(-8); nmax = 200;
Present numerical results in the following table:
Q1
Q3
number of iterations
Are these approximation acceptable? Why or Why not?
3
4. (30 points) In designing the shape of a gravity-flow discharge chute that will minimize
transit time of discharged granular particles, we need to solve the following system of
nonlinear equations:
sin(θn+1)
vn+1
− sin(θn)
vn
= 0, n = 1, 2, · · · , 19,
∆y
∑20
i=1
tan(θi)−X = 0,
X, ∆y, vn, n = 1, 2, · · · , 20 are parameters to be specified.
(a) (10 points) Put this nonlinear system in vector form f(θ) = 0, in which
θ = (θ1, θ2, · · · , θ20)T .
Then, implement Matlab functions for this nonlinear function and its Jacobian
such that their interfaces are as follows:
function f = fun_gravity_flow(theta, v, X, Del_y)
function J = fun_gravity_flow_J(theta, v, X, Del_y)
Then, assume the parameters in this nonlinear system are such that
g = 32.16 ft/s2, X = 1.9, ∆y = 0.19,
vn =

2gn∆y, n = 1, 2, · · · , 20.
Use your Matlab functions to compute f(θ(0)) and Jf (θ
(0)) where
θ(0) = (1, 2, 3, · · · , 20)T .
Present numerical results in the following table:
f11(θ
(0))
f20(θ
(0))
J(13, 13)
J(13, 14)
J(13, 16)
J(20, 16)
(b) (10 points) Use Newton’s method to solve this nonlinear system with the param-
eters specified in Problem 4a. Use the following inputs for Newton’s method:
theta0 = ones(20, 1); tol = 10^(-12); nmax = 200;
Present numerical results in a table as follows:
4
θ3
θ13
θ18
Residual
Number of iterations
Also, preset the related Matlab script.
(c) (10 points) Use Broyden’s method to this nonlinear system with the following
parameters: Assume
g = 32.16 ft/s2, X = 1.98,∆y = 0.251,
vn =

2g(n+ 1/n)∆y, n = 1, 2, · · · , 20.
Use the following inputs for the Broyden’s method:
theta0 = ones(20, 1); tol = 10^(-12); nmax = 200;
Justify the choice for the initial matrix B0 to be used in the Broyden’s method.
Present numerical results in a table as follows:
θ1
θ11
θ17
Residual
Number of iterations
Also, preset the related Matlab script.
5. (40 points) Consider the following nonlinear equations for ui, i = 1, 2, · · · , N :
−2u1 + u2 + h2u21 − h2g1 = 0,
ui−1 − 2ui + ui+1 + h2u2i − h2gi = 0, i = 2, 3, · · · , N − 1,
uN−1 − 2uN + h2u2N − h2gN = 0,
where
h =
1
N + 1
,
x1 = h, xi = xi−1 + h, i = 2, 3, · · · , N,
gi = e
−2xi
(
sin(xi)
(
e2xi + (e− exi)2 sin(xi)
)
− 2exi+1 cos(xi)
)
(a) (10 points) Let u = (u1, u2, · · · , uN)t be the unknown vector for the nonlinea
system above. Implement the nonlinear function f(u) = 0 such that its interface
is as follows:
function f = fu(u, g, h)
5
Then implement the Jacobian for this nonlinear system such that its interface is
as follows:
function J = fu_J(u, g, h)
Then, for N = 5, ca
y out computations to fill in the following table:
f1(u
(0))
f3(u
(0))
J(2, 2)
J(2, 3)
J(2, 4)
J̃(3, 3)
J̃(3, 2)
J̃(3, 1)
where u(0) = [1, 1, 1, 1, 1]T , J is Jacobian of f , and J̃ is the approximate Jacobian
y the complex variable method with EPS = 10^(-6).
(b) (10 points) Solve this nonlinear system for N = 512 by Newton’s method. Present
your numerical results by filling the following table:
u15
u305
Residual
Iterations used
Use
tol = 10−12, u(0) =

1
1
...
1

Also, present your Maltab script used to generate data in this table. Make sure
that your script uses the Matlab’s “varargin” functionality.
(c) (10 points) Solve this nonlinear system for N = 1024 by Broyden’s method.
Present your numerical results by filling the following table:
u512
u750
Residual
Iterations used
6
Use
tol = 10−12, u(0) =

1
1
...
1

Also, present your Maltab script used to generate data in this table. Make sure
that your script uses the Matlab’s “varargin” functionality.
(d) (10 points) Note that the solution in part 5b above provide data for a function
u(x). Use this set of data to find approximations to u(x) and present these
approximations in the following table:
x u(x)
π/8
π/4
Justify your choice of the method for computing these approximations and present
the related script.
6. (40 points) Consider the following data for the trajectory in the x-y plane of a robot
(from Problem 3.4 and Example 3.10):
t XXXXXXXXXX
x XXXXXXXXXX
y XXXXXXXXXX
Let
T1(t) =
[
x1(t)
y1(t)
]
, t ∈ [0, 2], T2(t) =
[
x2(t)
y2(t)
]
, t ∈ [2, 5]
e the cubic spline interpolations with the natural boundary condition of the trajectory
data in co
esponding time intervals. Then download data file
curve_intersects_RobotTraj.mat
from Canvas for the trajectory of another moving object, and let
T3(s) =
[
x3(s)
y3(s)
]
, s ∈ [0, 5]
e the cubic spline interpolation with the natural boundary condition for this set of
data. In these functions, both t and s variables represent the time.
7
(a) (10 points) Make a plot of the trajectories by the three parametric curves defined
above with red, blue, and green color, respectively.
(b) (10 points) Find the x-y coordinates where T3(s) curve intersects with the T1(t)
curve. Present your results in the following table
x
y
t∗
s∗
where
T1(t
∗) =
[
x
y
]
= T3(s
∗).
8
(c) (10 points) Find the x-y coordinates where T3(s) curve intersects with the T2(t)
curve. Present your results in the following table
x
y
t∗
s∗
where
T2(t
∗) =
[
x
y
]
= T3(s
∗).
(d) (5 points) Make a plot of the trajectories by the three parametric curves defined
above with red, blue, and green color, respectively, together with the intersection
points found above. Mark the two intersection points with red *.
(e) (5 points) Discuss the concern about whether the moving object can collide with
the robot. Why? Why not?
Answered Same Day Nov 02, 2021

Solution

Kshitij answered on Nov 05 2021
139 Votes
issue of science/5d.mat
x:[512x1 double a
ay]
x1:[512x1 double a
ay]
issue of science/Code_1.m
%% problem No.1
% Clear Screen
clc
clear all
disp('Bisection Method');
% Define constants
a1 = 1.42;
a2 = -7.89;
a3 = 0.52;
a4 = 0.047;
% Define Function
f = @(x) x^3 - (a1-exp(a2*x))*x^2 + a3*x - a4;
% starting interval
low = 0;
high = 1;
% tol
tol = 1e-12;
% Evaluate both ends of the interval
y1 = feval(f, low);
y2 = feval(f, high);
i = 0;
% Display e
or and finish if signs are not different
if y1 * y2 > 0
disp('Have not found a change in sign. Will not continue...');
return
end
while (abs(high - low) >= tol)
i = i + 1;
% Find a new value to be tested as a root
m = (high + low)/2;
y3 = feval(f, m);
if y3 == 0
return
end

% Update the limits
if y1 * y3 > 0
low = m;
y1 = y3;
else
high = m;
end
end
% Show the last approximation considering the tolerance
w = feval(f, m);
fprintf('\n x = %f produces f(x) = %g \n %i iterations\n', m, y3, i-1);
fprintf(' Approximation with tolerance = %g \n\n\n', tol);
fprintf(' Zero Found | a | b | Iteration Used\n')
fprintf(' %0.4f | %d | %d | %d\n\n',m,0,1,i-1)
issue of science/Code_2_a.m
%% Problem No. 2 a
% clear screen
clc
clear all
%% Secant Method initilization
% Define constants
a_1 = 0.1;
a_2 = -3.2;
a_3 = -5;
a_4 = -1;
syms x;
% Define function
f=sin(a_1+(a_2 - exp(a_3*x))*x^2 + a_4*x^3);
% tolerance
epsilon = 1e-12;
%initial guess
x0 = 0;
x1 = 1;
% secant method
for i=1:100
f0=vpa(subs(f,x,x0));
f1=vpa(subs(f,x,x1));
y=x1-((x1-x0)/(f1-f0))*f1;
e
=abs(y-x1);
if e
epsilon
eak
end
x0=x1;
x1=y;
end
y = y - rem(y,1e-12);
% Display roots
fprintf('The Root is : %f \n',y);
fprintf('No. of Iterations : %d\n\n\n',i);
fprintf('Zero Found | Resudial | NOI\n')
fprintf(' %0.4f | %0.4e | %d\n\n',y,double(e
),i)
issue of science/Code_2_b.m
%% Problem No. 2
% clear screen
clc
clear all
%% Newton's Method to find roots
% Define constants
a_1 = 0.1;
a_2 = -3.2;
a_3 = -5;
a_4 = -1;
syms x;
f=sin(a_1+(a_2 - exp(a_3*x))*x^2 + a_4*x^3); %Enter the Function here
g=diff(f); %The Derivative of the Function
n=11;
epsilon = 10^-(n+1)
x0 = -0.1;
for i=1:100
f0=vpa(subs(f,x,x0)); %Calculating the value of function at x0
f0_der=vpa(subs(g,x,x0)); %Calculating the value of function derivative at x0
y=x0-f0/f0_der; % The Formula
e
=abs(y-x0);
if e
epsilon %checking the amount of e
or at each iteration
eak
end
x0=y;
end
y = y - rem(y,10^-n); %Displaying upto required decimal places
fprintf('The Root is : %f \n',y);
fprintf('No. of Iterations : %d\n',i);
issue of science/Code_3_b.m
%% problem 3.
% clear screen
clc
clear all
%% Broyden's Method
x0=[1;1;1;1*10^5];
tol = 1e-8;
nmax = 200;
gam = 9791;
z=[-19 -7 2];
c=[3.721 64.55 21.273];
J =@(x) fun_QpJ(x,gam,c,z);
invJ =@(x) inv(fun_QpJ(x,gam,c,z));
F =@(x) fun_Qp(x,gam,c,z);
x1 = x0;
J1 = J(x0);
n=0;
delF=1;
while tol x2 = x1 - inv(J1) * F(x1);
delx = x2-x1;
delF = F(x2)-F(x1);
J2 = J1 + ((delF - J1*delx)./(abs(x2).^2))*delx';
x1=x2;
J1=J2;
n=n+1;
end
fprintf(' Resudial | NOI | Q2 | P\n')
fprintf(' %0.4e | %d | %0.4f | %0.3e\n\n',abs(mean(delF)),n,x1(2),x1(4))
issue of science/Code_3_c.m
%% Problem No. 3 c
% clear screen
clc
clear all
%% Newtons's Method to solve non linear equation
% initial guess
x0=[1;1;1;1*10^5];
% tol
tol = 1e-8;
% maximum iteration
nmax = 200;
% remaining constant
gam = 9791;
z=[-19 -7 2];
c=[3.721 64.55 21.273];
% anomly. function
J =@(x) fun_QpJ(x,gam,c,z);
invJ =@(x) inv(fun_QpJ(x,gam,c,z));
F =@(x) fun_Qp(x,gam,c,z);
x1 = x0;
n=0;
delF=1;
while tol x2 = x1 - inv(J(x1)) * F(x1);
x1=x2;
n=n+1;
end
fprintf(' Q1 | Q3 | NOI\n')
fprintf(' %0.4f | %0.4f | %d\n\n',x1(1),x1(3),n)
issue of science/Code_4_a.m
%% Problem No. 4 a
% clear screen
clc
clear all
%% using fuction fun_gravity_flow and fun_gravity_flow_J cmopute table
theta=ones(20,1);
g=32.16;
Del_y=0.19;
n=1:20;
v=sqrt(2*g.*n*Del_y);
v=v';
X=1.9;
% compute function and jacobian
J =fun_gravity_flow_J(theta, v, X, Del_y);
F =fun_gravity_flow(theta, v, X, Del_y);
% print Table
fprintf(' f11 | f20 | J(13,13) | J(13,14) | J(13,16) | J(20,16)\n')
fprintf(' %0.4f | %0.4f | %0.4f | %0.4f | %0.4f | %0.4f \n\n',F(11),F(20),J(13,13),J(13,14),J(13,16),J(20,16))
issue of science/Code_4_b.m
%% Problem No. 4
% clear screen
clc
clear all
%% Newtons's Method to solve non-linear equations
theta0=ones(20,1);
g=32.16;
Del_y=0.19;
n=1:20;
v=sqrt(2*g.*n*Del_y);
v=v';
X=1.9;
tol = 1e-12;
nmax = 200;
J =@(theta) fun_gravity_flow_J(theta, v, X, Del_y);
invJ =@(theta) inv(fun_gravity_flow_J(theta, v, X, Del_y));
F =@(theta) fun_gravity_flow(theta, v, X, Del_y);
x1 = theta0;
n=0;
delF=1;
while tol x2 = x1 - inv(J(x1)) * F(x1);
x1=x2;
n=n+1;
end
% Print Results
fprintf(' theta3 | theta13 | theta18 | Resudial | NOI\n')
fprintf(' %0.4f | %0.4f | %0.4f | %0.3e | %d\n\n',x1(3),x1(13),x1(18),abs(mean(F(x1))),n)
issue of science/Code_4_c.m
%% Problem No. 4 c
clc
clear all
%% Broyden's Method
theta0=ones(20,1);
g=32.16;
Del_y=0.251;
n=1:20;
v=sqrt(2*g.*((n+1)./n).*Del_y);
v=v';
X=1.98;
tol = 1e-12;
nmax = 200;
J =@(theta) fun_gravity_flow_J(theta, v, X, Del_y);
invJ =@(theta) inv(fun_gravity_flow_J(theta, v, X, Del_y));
F =@(theta) fun_gravity_flow(theta, v, X, Del_y);
x1 = theta0;
J1 = J(theta0);
n=0;
delF=1;
while tol x2 = x1 - inv(J1) * F(x1);
delx = x2-x1;
delF = F(x2)-F(x1);
J2 = J1 + ((delF - J1*delx)./(abs(x2).^2))*delx';
x1=x2;
J1=J2;
n=n+1;
end
% print Results
fprintf(' theta1 | theta11 | theta17 | Resudial | NOI\n')
fprintf(' %0.4f | %0.4f | %0.4f | %0.3e | %d\n\n',x1(1),x1(11),x1(17),abs(mean(F(x1))),n)
issue of science/Code_5_a.m
%% problem 5. a
clc
clear all
N = 5;
h=1/(1+N);
x(1)=h;
for i=2:N
x(i)=x(i-1)+h;
end
for i=1:N
g(i) = exp(-2*x(i))*(sin(x(i))*(exp(2*x(i))+(exp(1)-exp(x(i)))^2*sin(x(i)))-2*exp(x(i)+1)*cos(x(i)));
end
u=[1 1 1 1 1]';
g=g';
f=fu(u,g,h);
J=fu_J(u,g,h);
% print result
fprintf(' f1 | f3 | J(2,2) | J(2,3) | J(2,4) | J(3,3) | J(3,2) | J(3,1)\n')
fprintf(' %0.4f | %0.4f | %0.4f | %0.4f | %0.4f | %0.4f | %0.4f | %0.4f\n\n',f(1),f(3),J(2,2),J(2,3),J(2,4),J(3,3),J(3,2),J(3,1))
issue of science/Code_5_b.m
%% Problem 5
clc
clear all
%% Newtons's Method
N = 512;
h=1/(1+N);
x(1)=h;
for i=2:N
x(i)=x(i-1)+h;
end
for i=1:N
g(i) =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here