Professional Documents
Culture Documents
Page 1
1/25/12
Part
b
Matlab
Code:
format
long
vpa(log(1.9),
10)
ans
=
0.6418538862
syms
k
vpa(-1.*symsum((-0.9).^k./k,1,166),
10)
ans
=
0.6418538861
vpa(-1.*symsum((-0.9).^k./k,1,167),
10)
ans
=
0.6418538862
Part c
Part d
Matlab
Code:
format
long
vpa(log(1.9),
10)
ans
=
0.6418538862
syms
k
vpa(2.*symsum((9./29).^(2.*k-1)./(2.*k-1),1,9),
10)
ans
=
0.6418538861
vpa(2.*symsum((9./29).^(2.*k-1)./(2.*k-1),1,10),
10)
ans
=
0.6418538862
Part
e
Equation
(2)
would
be
more
efficient
for
computing
log (1.9),
because
it
requires
way
less
operations
(approximately
80)
in
comparison
to
(1)
which
has
approximately
500
operations.
Byron Carasco
Problem 2
Page 2
1/25/12
Matlab
Code:
xvals
=
10^-20:0.01:10^-1
function
A
=
f1a(x)
(sqrt(4.+x).-2)./x
function
B
=
f1b(x)
1./(sqrt(4.+x)+2)
function
C
=
f2a(x)
(1.-exp(-1.*x))./x
function
D
=
f2b(x)
(exp(-1.*x).*(-1+exp(x)))./x
f1a(xvals)
f1b(xvals)
f2a(xvals)
f2b(xvals)
There
is
a
loss
of
significance
error,
the
values
seem
to
be
rounding
up
too
soon.