# Lab sheet 10

## Taylor series

Exercise 1.1

y:log(sqrt((1+x)/(1-x)));

a(n) := subst(x=0,factor(diff(y,x,n)))/n!;

makelist(a(n),n,1,10);

ys0: sum(a(n)*x^n,n,0,12);

ys1: taylor(y,x,0,12);

expand(taytorat(ys1)) - ys0;

kill(a,y,ys0,ys1)$

Exercise 1.2

s: expand(taytorat(taylor(sin(x),x,0,12)));

wxplot2d([sin(x),s],[x,-8,8],[y,-10,10],[legend,false]);

t(n) := expand(taytorat(taylor(sin(x),x,0,n)));
r(n) := expand(taytorat(taylor(cos(x),x,0,n)));

wxplot2d([sin(x),t(20)],[x,-8,8],[y,-10,10],[legend,false]);

q: expand(t(10)^2+r(10)^2);

wxplot2d(q,[x,-6,6],[y,0,2]);

kill(s,t,r,q)$

Exercise 1.3

y:x*(1+x)/(1-x)^3;

taylor(y,x,0,20);

kill(y)$

Exercise 1.4

taylor(sin(x),x,%pi/2,12);

taylor(cos(x),x,0,12);

## Revision

Exercise 2.1

fpprec:20;

bfloat(cos(log(%pi + 20)));

Exercise 2.2

f(x) := x^2-29/16;

f(0);

f(f(f(-1/4)));

Exercise 2.3

a:(1+x)^5 - 3*(1+x)^4+5*(1+x)^3-3*(1+x)^2+3*(1+x)+3;

b:(7*x^2-6*x-x^8)/(x-1)^2;

a: factor(expand(a));

b:factor(b);

expand(b + x * a);

kill(a,b)$

Exercise 2.4

u: ((x^12-1)*(x^2-1)/((x^6-1)*(x^4-1)));

u: factor(u);

v:expand(u^10);

coeff(v,x,6);

kill(u,v)$

Exercise 2.5

eqns: [x^2+y^2+z^2=9, (x-1)^2+(y-1)^2+(z-1)^2=2,4*x^2+y*z=2*x*(y+z)];

sublist(
    solve(eqns),
    lambda([e], integerp(subst(e,x)) and integerp(subst(e,y)) and integerp(subst(e,z)))
);

Exercise 2.6

load("to_poly_solve")$

to_poly_solve(sin(θ)^2=3*cos(θ)^2,θ);

kill(eqns)$

Exercise 2.7

sublist(
    solve([x^2-y^2=1,2*x*y=1]),
   lambda([e],imagpart(subst(e,x))=0 and imagpart(subst(e,y)) = 0 and subst(e,x)>0));

Exercise 2.8

find_root(x=log(x+20),x,2.8,3.2);