q q q q
Quivers
SOLUTIONS
, SOLUTION MANUAL
q
NUMERICAL AND ANALYTICAL METHODS WITH
q q q q
MATLAB
Table of Contents
q q
Page
Chapter 2 q 1
Chapter 3 q 46
Chapter 4 q 58
Chapter 5 q 98
Chapter 6 q 107
Chapter 7 q 176
Chapter 8 q 180
Chapter 9 q 188
Chapter 10 q 214
Chapter 11 q 271
Chapter 12 q 303
Chapter 13 q 309
Chapter 14 q 339
, CHAPTER 2 q
P2.1. Taylor series expansion of f (x) about x = 0 is:
q q q q q q q q q q q q
f ''(0) 2 f '''(0) 3 f 1V 4
f (x) f (0) f '(0) x x x x ...
q qq q q qqq q q
q q q q q q q q q q q q q q q
2! 3! 4!
For f (x) cos(x) , q q q q q q q f (0) 1,
q q q
f (x) sin(x), f '(0) 0,
q q q q q q q q q q q
f ''(x) cos(x), f ''(0) 1,
q qq q q q q q q qq q q q
f '''(x) sin(x), f '''(0) 0,
q qqq q q q q q q q qqq q q
f 1V (x) cos(x), f 1V (0) 1
q q q q q q q q q q q q
We can see that
q q q
x 2 x4 x6 8
cos(x) 1 x ... 8
q q q
q q q q q
2! 4! 6! !
q q q q
and that q
x2
term(k) term(k 1)
q
2 k (2 k 1)
q q q q q q q q
q q q q
The following program evaluates cos(x) by both an arithmetic statement and by the above s
q q q q q q q q q q q q q q q
eries for -π ≤ x ≤ π in step of 0.1 .
q q q q q q q q q q q q
% cosf.m
q
% This program evaluates cos(x) by both arithmetic statement and by
q q q q q q q q q q
% series for -π ≤ x ≤ π in steps of 0.1 π
q q q q q q q q q q q q
clear; clc; q
xi=-
pi;dx=0.1*pi; for j=1
q q q
:21
x(j)=xi+(j-1)*dx;
cos_arith(j)= cos(x(j)); q
, sum=1.0;term=1.0; fo q q
r k=1:50
q
den=2*k*(2*k-1);
term=-
term*x(j)^2/den; sum=su q
m+term; test=abs(sum*1.
q
0e-
6); if abs(term) <= test
q q q q
;
break;
end
end cos_ser(j)=su
q
m; nterms(j)=k;
q
end fo=fopen('output.dat','w'
q
);
fprintf(fo,'x cos(x) cos (x)
q
terms in \n'); fprintf(fo,'
q q q by arith stm
q q
by series
q
the series \n'); fprintf(fo,'=========================
q q q
============================\n');
for j=1:21
q
fprintf(fo,'%10.5f %10.5f %10.5f
%3i\n',... x(j),cos_arith(j),cos_se
q q
r(j),nterms(j));
fprintf(fo,' \n');
end fclose(fo
q
);
plot(x,cos_arith),xlabel('x'),ylabel('cos(x)'), title('cos(x q
) vs. x'),grid;
q q