# Lab sheet 8

Exercise 1

p[0]:sqrt(1/2);   p[1]:sqrt(3/2)*x;  p[2]:sqrt(5/8)*(3*x^2-1); p[3]:sqrt(7/8)*(5*x^3-3*x);

apply(matrix,makelist(makelist(integrate(p[i]*p[j],x,-1,1),j,0,3),i,0,3));

p[4]:a*x^4+b*x^2+c;

sols: solve(cons(integrate(p[4]^2,x,-1,1)-1,makelist(integrate(p[i]*p[4],x,-1,1),i,0,3,2)));

p[4]: subst(sols[1],p[4]);

q(n) := sqrt(n+1/2)/(2^n*n!) * diff((x^2-1)^n,x,n);

makelist(expand(p[n]-q(n)),n,0,4);

apply(matrix,makelist(makelist(integrate(p[i]*p[j],x,-1,1),j,0,4),i,0,4));

kill(p,q)$

Exercise 2

apply(matrix,makelist(makelist(subst(log(x)=y,integrate(x^n*log(x)^m,x)),m,0,5),n,0,6));

Exercise 3

u: exp(-x^2); U: integrate(u,x);

u : 1/log(x); U: integrate(u,x);

u: 1/(sqrt(1-x^2)*sqrt(1-2*x^2));
U: elliptic_f(asin(x),2);
err: diff(U,x) - u;

u: 1/sqrt(x^8+1);
U:x*hypergeometric([1/8, 1/2], [9/8], -x^8);
err: diff(U,x) - u$
err: taylor(err,x,0,10);

integrate(sin(x)*log(log(x)),x);
integrate(sin(sin(sin(x))),x);
integrate(1/sqrt(1+x+x^10),x);

kill(u,U,err)$

Exercise 4

y:sin(x)+sin(3*x)/3+sin(5*x)/5+sin(7*x)/7;

Y:integrate(y,x);

wxplot2d([y,Y,0.8,-0.8],[x,-2*%pi,2*%pi],[legend,"y","Y","0.8","-0.8"]);

kill(y,Y)$

Exercise 5

y: x*exp(-x)*sin(20*x);
z: 20*integrate(y,x); 

wxplot2d([y,z],[x,0,10],[legend,"y","z"]);

integrate(coeff(expand(trigsimp(expand((y^2+z^2)*exp(2*x)))),x,2),x,0,2*%pi)/(2*%pi);

wxplot2d([y^2+z^2,x^2*exp(-2*x)],[x,0,10],[legend,"E","x^2 exp(-2x)"]);

Exercise 6

solve(makelist(integrate(x^k*(a*x^2+b*x+c)*exp(-x),x,0,inf)-k,k,1,3));

Exercise 7

err: x*(log(log(x))+log(x)-1)-541;

wxplot2d(err,[x,90,110]);

find_root(x*(log(log(x))+log(x)-1)-541,x,100,111);

Exercise 8

makelist(a+b^n,n,2,10);

Exercise 9

wxdraw(gr2d(
    proportional_axes=xy,
    ip_grid=[100,100],
    implicit(x^4+y^4=1,x,-1.5,1.5,y,-1.5,1.5),
    color=red,
    nticks=200,
    parametric(cos(t)/(2+cos(4*t)),sin(t)/(2+cos(4*t)),t,0,2*%pi)    
    ));

Exercise 10

fpprec: 100;

bfloat(%pi^76/%e^87);

Exercise 11

expand(factor(exponentialize(sin(2*x)*tan(2*x)*diff(log(tan(x)),x,2))));