rev2.mws

MCS 320 Wednesday 2 November 2005

> restart;

#4 on review

> dvd := proc(f)
 local s,n;

 s := op(procname); # get index to dvd, the sequence

 n := nops([s]);    # the number of elements in s

 if n = 1 then      # base case in the recursion

    return f(s);

 else               # general case

    return (dvd[seq(s[k],k=2..n)](f) - dvd[seq(s[k],k=1..n-1)](f))/(s[1] - s[n]);

 end if;

end proc:

> dvd[a](f);

f(a)

> dvd[a,b,c,d](f);

(((f(d)-f(c))/(c-d)-(f(c)-f(b))/(b-c))/(b-d)-((f(c)-f(b))/(b-c)-(f(b)-f(a))/(a-b))/(a-c))/(a-d)

> dvd[a,b,c](f);

((f(c)-f(b))/(b-c)-(f(b)-f(a))/(a-b))/(a-c)

# 10

> f := t -> int((1-exp(x)),x=0..t); # notice the x

f := proc (t) options operator, arrow; int(1-exp(x), x = (0 .. t)) end proc

> D(f)(0.001);

-0.1000500e-2

> D(f)(0);

0

# 11

> g := (1-t^2)/(1-2*x*t+t^2);

g := (1-t^2)/(1-2*x*t+t^2)

(a)

> ty := taylor(g,t=0,10);

ty := series(1+2*x*t+(-2+4*x^2)*t^2+(-2*x-2*(2-4*x^2)*x)*t^3+(2-4*x^2-2*(6*x-8*x^3)*x)*t^4+(6*x-8*x^3-2*(-2+16*x^2-16*x^4)*x)*t^5+(-2+16*x^2-16*x^4-2*(-10*x+40*x^3-32*x^5)*x)*t^6+(-10*x+40*x^3-32*x^5-...ty := series(1+2*x*t+(-2+4*x^2)*t^2+(-2*x-2*(2-4*x^2)*x)*t^3+(2-4*x^2-2*(6*x-8*x^3)*x)*t^4+(6*x-8*x^3-2*(-2+16*x^2-16*x^4)*x)*t^5+(-2+16*x^2-16*x^4-2*(-10*x+40*x^3-32*x^5)*x)*t^6+(-10*x+40*x^3-32*x^5-...ty := series(1+2*x*t+(-2+4*x^2)*t^2+(-2*x-2*(2-4*x^2)*x)*t^3+(2-4*x^2-2*(6*x-8*x^3)*x)*t^4+(6*x-8*x^3-2*(-2+16*x^2-16*x^4)*x)*t^5+(-2+16*x^2-16*x^4-2*(-10*x+40*x^3-32*x^5)*x)*t^6+(-10*x+40*x^3-32*x^5-...ty := series(1+2*x*t+(-2+4*x^2)*t^2+(-2*x-2*(2-4*x^2)*x)*t^3+(2-4*x^2-2*(6*x-8*x^3)*x)*t^4+(6*x-8*x^3-2*(-2+16*x^2-16*x^4)*x)*t^5+(-2+16*x^2-16*x^4-2*(-10*x+40*x^3-32*x^5)*x)*t^6+(-10*x+40*x^3-32*x^5-...ty := series(1+2*x*t+(-2+4*x^2)*t^2+(-2*x-2*(2-4*x^2)*x)*t^3+(2-4*x^2-2*(6*x-8*x^3)*x)*t^4+(6*x-8*x^3-2*(-2+16*x^2-16*x^4)*x)*t^5+(-2+16*x^2-16*x^4-2*(-10*x+40*x^3-32*x^5)*x)*t^6+(-10*x+40*x^3-32*x^5-...

> ty8 := coeff(ty,t,8);

ty8 := 2-36*x^2+96*x^4-64*x^6-2*(14*x-112*x^3+224*x^5-128*x^7)*x

> ch8 := orthopoly[T](8,x);

ch8 := 1+128*x^8-256*x^6+160*x^4-32*x^2

> df := ty8/2 - ch8;

df := 14*x^2-112*x^4+224*x^6-(14*x-112*x^3+224*x^5-128*x^7)*x-128*x^8

> simplify(df);

0

The difference between our polynomial and the Chebyshev polynomials is that our polynomial is twice the Chebyshev polynomial.

(b)

The coefficient of the Taylor series of g about t = 0 are the Chebyshev polynomials, up to a constant.

> cp := n -> coeftayl(g,t=0,n)/2;

cp := proc (n) options operator, arrow; 1/2*coeftayl(g, t = 0, n) end proc

> cp(8);

1+128*x^8-256*x^6+160*x^4-32*x^2

> orthopoly[T](8,x);

1+128*x^8-256*x^6+160*x^4-32*x^2

> cp(0);

1/2

> orthopoly[T](0,x);

1

> ccp := n -> piecewise(n=0,1,cp(n));

ccp := proc (n) options operator, arrow; piecewise(n = 0, 1, cp(n)) end proc

> ccp(0); ccp(8);

1

1+128*x^8-256*x^6+160*x^4-32*x^2

# 17

> s := [4+2*x+2*y+z+x*y,4+2*x+2*y+2*z+4*y^2,x+y+x^2];

s := [4+2*x+2*y+z+x*y, 4+2*x+2*y+2*z+4*y^2, x+y+x^2]

(a)

> gb := Groebner[Basis](s,plex(x,y,z));

gb := [8*z^4+346*z^2+652*z+324+79*z^3, 11710*y-568*z^3-2953*z^2-5150*z+5168, 11710*x+5437*z^2+21200*z+30068+792*z^3]gb := [8*z^4+346*z^2+652*z+324+79*z^3, 11710*y-568*z^3-2953*z^2-5150*z+5168, 11710*x+5437*z^2+21200*z+30068+792*z^3]

> degree(gb[1],z)*degree(gb[2],y)*degree(gb[3],x);

4

There are four complex solutions.

(b)

> vz := fsolve(gb[1],z,complex);

vz := -3.055212030-2.943140020*I, -3.055212030+2.943140020*I, -3.019194795, -.7453811455

> eqy := seq(subs(z=vz[k],gb[2]),k=1..4);

eqy := 11710*y+(-9979.85117-5616.85794*I), 11710*y+(-9979.85117+5616.85794*I), 11710*y+9430.93067, 11710*y+7601.271653eqy := 11710*y+(-9979.85117-5616.85794*I), 11710*y+(-9979.85117+5616.85794*I), 11710*y+9430.93067, 11710*y+7601.271653

> eqx := seq(subs(z=vz[k],gb[3]),k=1..4);

eqx := 11710*x+(9245.57894-9699.43594*I), 11710*x+(9245.57894+9699.43594*I), 11710*x-6174.84718, 11710*x+16958.68930eqx := 11710*x+(9245.57894-9699.43594*I), 11710*x+(9245.57894+9699.43594*I), 11710*x-6174.84718, 11710*x+16958.68930

> vy := map(eq -> fsolve(eq,y,complex),[eqy]);

vy := [.8522503134+.4796633595*I, .8522503134-.4796633595*I, -.8053740965, -.6491265289]

> vx := map(eq -> fsolve(eq,x,complex),[eqx]);

vx := [-.7895455969+.8283036670*I, -.7895455969-.8283036670*I, .5273140205, -1.448222827]

> sols2 := zip((x,y) -> [x,y],vx,vy);

sols2 := [[-.7895455969+.8283036670*I, .8522503134+.4796633595*I], [-.7895455969-.8283036670*I, .8522503134-.4796633595*I], [.5273140205, -.8053740965], [-1.448222827, -.6491265289]]sols2 := [[-.7895455969+.8283036670*I, .8522503134+.4796633595*I], [-.7895455969-.8283036670*I, .8522503134-.4796633595*I], [.5273140205, -.8053740965], [-1.448222827, -.6491265289]]sols2 := [[-.7895455969+.8283036670*I, .8522503134+.4796633595*I], [-.7895455969-.8283036670*I, .8522503134-.4796633595*I], [.5273140205, -.8053740965], [-1.448222827, -.6491265289]]

> sols := zip((xy,z) -> [op(xy),z],sols2,[vz]);

sols := [[-.7895455969+.8283036670*I, .8522503134+.4796633595*I, -3.055212030-2.943140020*I], [-.7895455969-.8283036670*I, .8522503134-.4796633595*I, -3.055212030+2.943140020*I], [.5273140205, -.80537...sols := [[-.7895455969+.8283036670*I, .8522503134+.4796633595*I, -3.055212030-2.943140020*I], [-.7895455969-.8283036670*I, .8522503134-.4796633595*I, -3.055212030+2.943140020*I], [.5273140205, -.80537...sols := [[-.7895455969+.8283036670*I, .8522503134+.4796633595*I, -3.055212030-2.943140020*I], [-.7895455969-.8283036670*I, .8522503134-.4796633595*I, -3.055212030+2.943140020*I], [.5273140205, -.80537...sols := [[-.7895455969+.8283036670*I, .8522503134+.4796633595*I, -3.055212030-2.943140020*I], [-.7895455969-.8283036670*I, .8522503134-.4796633595*I, -3.055212030+2.943140020*I], [.5273140205, -.80537...

> nops(sols);

4

(c) To find only the real solutions we leave off the complex of the fsolve command.

     To find only the rational solutions, we use solve instead of fsolve.

# 12

> p := 5*x^2*a^2 + 61*x^2*a + 66*x^2 + 10*x*a^2 + 121*x*a + 121*x + a^2 +15*a + 44;

p := 5*x^2*a^2+61*x^2*a+66*x^2+10*x*a^2+121*x*a+121*x+a^2+15*a+44

(a)

> solve(p,x);

-(10*a+11-(80*a^2+116*a+25)^(1/2))/(2*(5*a+6)), -(10*a+11+(80*a^2+116*a+25)^(1/2))/(2*(5*a+6))

(b)

Only if the denominator of the solution is nonzero are the solutions valid.

(c)

> collect(p,x);

(5*a^2+61*a+66)*x^2+(121+121*a+10*a^2)*x+44+a^2+15*a

We have fewer than two solutions if the leading coefficient of p in x vanishes:

> p2 := coeff(p,x,2);

p2 := 5*a^2+61*a+66

> special_a := solve(p2,a);

special_a := (-6)/5, -11

> eq1 := subs(a=special_a[1],p);

eq1 := -49*x/5+686/25

> subs(a=special_a[2],p);

0

For the first special value we have one solution.

> solve(eq1,x);

14/5

For the second special value, the polynomial p equals zero for this second special value we have infinitely many solutions for x.

#13

> p := -42*sin(x)^11 + 88*sin(x)^8 - 76*sin(x)^7 - 65*sin(x)^5 + 25*sin(x)^3 + 28;

p := -42*sin(x)^11+88*sin(x)^8-76*sin(x)^7-65*sin(x)^5+25*sin(x)^3+28

> solve(p,sin(x));

RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 1), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 2), RootOf(42*_Z^11-88*_Z^8+76*_Z^7+65*_Z^5-25*_Z^3-28, index = 3), RootOf(4...

The best way is to solve for sin(x).  We see that there are 11 possible values.

> ps := subs(sin(x)=y,p);

ps := -42*y^11+88*y^8-76*y^7-65*y^5+25*y^3+28

> v := fsolve(ps,y);

v := .8845044055

> fsolve(ps,y,complex);

-.9035802185-1.092038821*I, -.9035802185+1.092038821*I, -.6755251351-.3084519469*I, -.6755251351+.3084519469*I, -.2164173039-.9385005392*I, -.2164173039+.9385005392*I, .3119278866-.6616350581*I, .3119...-.9035802185-1.092038821*I, -.9035802185+1.092038821*I, -.6755251351-.3084519469*I, -.6755251351+.3084519469*I, -.2164173039-.9385005392*I, -.2164173039+.9385005392*I, .3119278866-.6616350581*I, .3119...-.9035802185-1.092038821*I, -.9035802185+1.092038821*I, -.6755251351-.3084519469*I, -.6755251351+.3084519469*I, -.2164173039-.9385005392*I, -.2164173039+.9385005392*I, .3119278866-.6616350581*I, .3119...-.9035802185-1.092038821*I, -.9035802185+1.092038821*I, -.6755251351-.3084519469*I, -.6755251351+.3084519469*I, -.2164173039-.9385005392*I, -.2164173039+.9385005392*I, .3119278866-.6616350581*I, .3119...

There is only one real solution, and 10 complex conjugate solutions.  If we are only interested in the real solutions, then there is only value to take.

> _EnvAllSolutions := true;

_EnvAllSolutions := true

> solve(sin(x)=v,x);

1.085430644+.9707313660*_B1+6.283185307*_Z1