HW3: p. 28, 1, 4, 5, 8, 14; p. 35, 1, 3, 8

#1

a=100
ahat=100.1
b =101
gamma=1/180*Pi (* radians *)

relError[a_,ahat_]:=(ahat-a)/a
tableRowEntry[a_,ahat_]:={N[a],ahat,relError[a,ahat]}

TableForm[
{
tableRowEntry[a,ahat]
,tableRowEntry[b*Cos[gamma]-a,b*Cos[gamma]-ahat]
,tableRowEntry[(b*Cos[gamma]-a)^2,(b*Cos[gamma]-ahat)^2]
,tableRowEntry[(b*Cos[gamma]-a)^2+(b*Sin[gamma])^2,(b*Cos[gamma]-ahat)^2+(b*Sin[gamma])^2]
,tableRowEntry[Sqrt[(b*Cos[gamma]-a)^2+(b*Sin[gamma])^2],Sqrt[(b*Cos[gamma]-ahat)^2+(b*Sin[gamma])^2]]
},TableHeadings->{
{"a","b*Cos[gamma]-a","(b*Cos[gamma]-a)^2","(b*Cos[gamma]-a)^2+(b*Sin[gamma])^2","c"}
,{"true","approx","relError"}}
]

#4

Simplify[relError[Exp[x],Exp[x*(1+eps)]]]

#8: might start with some experiments:

b=Pi/2
f[x_]:=Abs[Cos[b+x]-Cos[b]]
Plot[{f[x],Abs[x]},{x,-Pi/2,Pi/2}]

#8 is an opportunity to make use of the MVT from calculus: for example

Clear[b,e]
Integrate[-Sin[x],{x,b,b+e}]

Can you bound that integral?

#14, p. 30: assume a relative error in x of xhat=x(1+h). Looking at the  relative error in the Log function, we can simplify to get

Clear[x,h]

f[x_]:=Log[1+x*h/(1+x)]
g[x_]:=Log[1+x]
re[x_]:=f[x]/g[x]

Limit[Simplify[re[x]/h],h->0]

condition[x_]:=x*g'[x]/g[x]
condition[x]

Plot[condition[x],{x,-1,8},PlotRange->{{-1,8},{0,10}}]

Now we might revisit #8b, using the condition number:

g[x_]:=Cos[x]
condition[x_]:=x*g'[x]/g[x]
Plot[condition[x],{x,Pi/4,3Pi/4}]

#8, p. 36: Ben found the Mathematica way to represent base 10 decimals in other bases: I happen to know that the base 10 representation of (0.6666....)_8 is 6/7, so

BaseForm[6.0/7.0,8]