16
MAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17 >> f=(1-sin(x)^2)^10*sin(x)^17 f = sin(x)^17*(sin(x)^2 - 1)^10 >> f1=subs(f,sin(x),u) f1 = u^17*(u^2 - 1)^10 >> int(f1,u) ans = u^38/38 - (5*u^36)/18 + (45*u^34)/34 - (15*u^32)/4 + 7*u^30 - 9*u^28 + (105*u^26)/13 - 5*u^24 + (45*u^22)/22 - u^20/2 + u^18/18 >> g=(1-cos(x)^2)^8*cos(x)^21 g = cos(x)^21*(cos(x)^2 - 1)^8 >> g1=subs(-g,cos(x),u) g1 = -u^21*(u^2 - 1)^8 >> int(g1,u)

betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

  • Upload
    dotu

  • View
    220

  • Download
    1

Embed Size (px)

Citation preview

Page 1: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

MAT 192, Lab #2 Key

My comments are in blue.

1a.>> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17 >> f=(1-sin(x)^2)^10*sin(x)^17 f = sin(x)^17*(sin(x)^2 - 1)^10 >> f1=subs(f,sin(x),u) f1 = u^17*(u^2 - 1)^10 >> int(f1,u) ans = u^38/38 - (5*u^36)/18 + (45*u^34)/34 - (15*u^32)/4 + 7*u^30 - 9*u^28 + (105*u^26)/13 - 5*u^24 + (45*u^22)/22 - u^20/2 + u^18/18 >> g=(1-cos(x)^2)^8*cos(x)^21 g = cos(x)^21*(cos(x)^2 - 1)^8 >> g1=subs(-g,cos(x),u) g1 = -u^21*(u^2 - 1)^8 >> int(g1,u) ans = - u^38/38 + (2*u^36)/9 - (14*u^34)/17 + (7*u^32)/4 - (7*u^30)/3 + 2*u^28 - (14*u^26)/13 + u^24/3 - u^22/22

Page 2: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

>> soln1=subs(u^38/38 - (5*u^36)/18 + (45*u^34)/34 - (15*u^32)/4 + 7*u^30 - 9*u^28 + (105*u^26)/13 - 5*u^24 + (45*u^22)/22 - u^20/2 + u^18/18,u,sin(x)) soln1 = sin(x)^18/18 - sin(x)^20/2 + (45*sin(x)^22)/22 - 5*sin(x)^24 + (105*sin(x)^26)/13 - 9*sin(x)^28 + 7*sin(x)^30 - (15*sin(x)^32)/4 + (45*sin(x)^34)/34 - (5*sin(x)^36)/18 + sin(x)^38/38 >> soln2=subs(- u^38/38 + (2*u^36)/9 - (14*u^34)/17 + (7*u^32)/4 - (7*u^30)/3 + 2*u^28 - (14*u^26)/13 + u^24/3 - u^22/22,u,cos(x)) soln2 = cos(x)^24/3 - cos(x)^22/22 - (14*cos(x)^26)/13 + 2*cos(x)^28 - (7*cos(x)^30)/3 + (7*cos(x)^32)/4 - (14*cos(x)^34)/17 + (2*cos(x)^36)/9 - cos(x)^38/38 >> ezplot(soln1,[-2*pi,2*pi])>> hold on>> ezplot(soln2,[-2*pi,2*pi])>> ezplot(soln1-.000001,[-2*pi,2*pi])>> hold off>>

1b.>> f=sec(x)^11*tan(x)^12 f = tan(x)^12/cos(x)^11 >> f=sec(x)^11*(sec(x)^2-1)^6 f = (1/cos(x)^2 - 1)^6/cos(x)^11 >> f1=subs(f,cos(x),1/u) f1 = u^11*(u^2 - 1)^6 >> int(f1,u) ans =

Page 3: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

u^24/24 - (3*u^22)/11 + (3*u^20)/4 - (10*u^18)/9 + (15*u^16)/16 - (3*u^14)/7 + u^12/12 >> soln1=subs(ans,u,sec(x)) soln1 = 1/(12*cos(x)^12) - 3/(7*cos(x)^14) + 15/(16*cos(x)^16) - 10/(9*cos(x)^18) + 3/(4*cos(x)^20) - 3/(11*cos(x)^22) + 1/(24*cos(x)^24) >> g=(1+tan(x)^2)^5*tan(x)^13 g = tan(x)^13*(tan(x)^2 + 1)^5 >> g1=subs(g,tan(x),u) g1 = u^13*(u^2 + 1)^5 >> int(g1,u) ans = u^24/24 + (5*u^22)/22 + u^20/2 + (5*u^18)/9 + (5*u^16)/16 + u^14/14 >> soln2=subs(ans,u,tan(x)) soln2 = tan(x)^14/14 + (5*tan(x)^16)/16 + (5*tan(x)^18)/9 + tan(x)^20/2 + (5*tan(x)^22)/22 + tan(x)^24/24 >> hold on>> ezplot(soln2,[-pi/4,pi/4])>> ezplot(soln1,[-pi/4,pi/4])>> hold offThe graphs have the same window in this range (the y-range didn’t change), so they graphed directly on top of each other. Or add a small constant to separate the graphs a bit.>> hold on>> ezplot(soln1+.01,[-pi/4,pi/4])>> ezplot(soln2-.01,[-pi/4,pi/4])>> hold off

2c.>> f=csc(x)^19*(csc(x)^2-1)^9

Page 4: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

f = (1/sin(x)^2 - 1)^9/sin(x)^19 >> f1=subs(f,sin(x),1/u) f1 = u^19*(u^2 - 1)^9 >> int(-f1,u) ans = - u^38/38 + u^36/4 - (18*u^34)/17 + (21*u^32)/8 - (21*u^30)/5 + (9*u^28)/2 - (42*u^26)/13 + (3*u^24)/2 - (9*u^22)/22 + u^20/20 >> soln1=subs(ans,u,csc(x)) soln1 = 1/(20*sin(x)^20) - 9/(22*sin(x)^22) + 3/(2*sin(x)^24) - 42/(13*sin(x)^26) + 9/(2*sin(x)^28) - 21/(5*sin(x)^30) + 21/(8*sin(x)^32) - 18/(17*sin(x)^34) + 1/(4*sin(x)^36) - 1/(38*sin(x)^38) >> g=(1+cot(x)^2)^9*cot(x)^19 g = cot(x)^19*(cot(x)^2 + 1)^9 >> g1=subs(g,cot(x),u) g1 = u^19*(u^2 + 1)^9 >> int(-g1,u) ans = - u^38/38 - u^36/4 - (18*u^34)/17 - (21*u^32)/8 - (21*u^30)/5 - (9*u^28)/2 - (42*u^26)/13 - (3*u^24)/2 - (9*u^22)/22 - u^20/20 >> soln2=subs(ans,u,cot(x)) soln2 =

Page 5: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

- cot(x)^20/20 - (9*cot(x)^22)/22 - (3*cot(x)^24)/2 - (42*cot(x)^26)/13 - (9*cot(x)^28)/2 - (21*cot(x)^30)/5 - (21*cot(x)^32)/8 - (18*cot(x)^34)/17 - cot(x)^36/4 - cot(x)^38/38 >> ezplot(soln1,[pi/4,3*pi/4])>> hold on>> ezplot(soln2,[pi/4,3*pi/4])>> ezplot(soln2+.1,[pi/4,3*pi/4])>> ezplot(soln1,[pi/4,3*pi/4])>> ezplot(soln2+.1,[pi/4,3*pi/4])>> hold off>>

2a.>> factor(x^3+1) ans = (x + 1)*(x^2 - x + 1) >> syms A B C D E F G H>> f=A/(x+1)+(B*x+C)/(x^2-x+1) f = (C + B*x)/(x^2 - x + 1) + A/(x + 1) >> simple(f) … collect(x): ((A + B)*x^2 + (B - A + C)*x + A + C)/(x^3 + 1) Note: I’ve omitted all the output for this command except for the collect(x) expression, which is the one we need, in the interests of space.

>> [A,B,C]=solve('A+B=1','B-A+C=0','A+C=-2') A = -1/3 B = 4/3

Page 6: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

C = -5/3 >> int(-1/3/(x+1)+4/3/(x^2-x+1)-5/3/(x^2-x+1),x) ans = - log(x + 1)/3 - (2*3^(1/2)*atan((2*3^(1/2)*x)/3 - 3^(1/2)/3))/9 >> int((x^2-2)/(x^3+1),x) ans = - log(x + 1)/3 + log(x - (3^(1/2)*i)/2 - 1/2)*((3^(1/2)*i)/3 + 2/3) - log(x + (3^(1/2)*i)/2 - 1/2)*((3^(1/2)*i)/3 - 2/3)

2b.>> factor(x^2+x-2) ans = (x + 2)*(x - 1) >> f=A/(x+2)+B/(x-1) f = 4/(3*(x - 1)) - 1/(3*(x + 2)) You need to redeclare variables after you solve for them or the substitutions for your old values will be made.

>> syms A B>> f=A/(x+2)+B/(x-1) f = A/(x + 2) + B/(x - 1) >> simple(f) …

collect(x): ((A + B)*x + 2*B - A)/(x^2 + x - 2)

Page 7: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

You can try to use MatLab to do the long division for you, but if that doesn’t work, MatLab can do synthetic division for you as shown below, or you can do it by hand.>> p=[1 0 -1 3]

p =

1 0 -1 3

>> q=[1 1 -2]

q =

1 1 -2

>> [r,R]=deconv(p,q)

r =

1 -1

R =

0 0 2 1

This reduces the original expression to x−1+2 x+1x2+x−2

. Use this expression to find A and B.

>> [A,B]=solve('A+B=2','2*B-A=1') A = 1 B = 1 >> int(1/(x+2)+1/(x-1),x) ans = log(x - 1) + log(x + 2) >> int((x^3-x+2)/(x^2+x-2),x) ans =

Page 8: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

(2*log(x - 1))/3 - x + (4*log(x + 2))/3 + x^2/2 The difference in the solutions here are coming from the polynomial portion.

2c.>> factor(x^3-6*x^2+12*x-8) ans = (x - 2)^3 >> syms A B C>> f=A/(x-2)+B/(x-2)^2+C/(x-2)^3 f = A/(x - 2) + B/(x - 2)^2 + C/(x - 2)^3 >> simple(f) …collect(x): (A*x^2 + (B - 4*A)*x + 4*A - 2*B + C)/(x^3 - 6*x^2 + 12*x - 8)

>> [A,B,C]=solve('A=2','B-4*A=-9','4*A-2*B+C=0') A = 2 B = -1 C = -10 >>>> int(2/(x-2)-1/(x-2)^2-10/(x-2)^3,x) ans =

Page 9: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

2*log(x - 2) + (x + 3)/(x - 2)^2 >> int((x*(2*x-9))/(x^3-6*x^2+12*x-8),x) ans = 2*log(x - 2) + (x + 3)/(x^2 - 4*x + 4)

2d.This one is already factored, so we just need the coefficients.

>> syms A B C D E F G H x y z>> f=A/x+B/x^2+C/(x-1)+D/(x-1)^2+E/(x-1)^3 f = A/x + B/x^2 + C/(x - 1) + D/(x - 1)^2 + E/(x - 1)^3 >> simple(f)

collect(x): ((A + C)*x^4 + (B - 3*A - 2*C + D)*x^3 + (3*A - 3*B + C - D + E)*x^2 + (3*B - A)*x - B)/(x^5 - 3*x^4 + 3*x^3 - x^2) ans = A/x + B/x^2 + C/(x - 1) + D/(x - 1)^2 + E/(x - 1)^3 >> [A,B,C,D,E]=solve('A+C=0','B-3*A-2*C+D=0','3*A - 3*B + C - D + E=6','3*B - A=0','-B=1')Warning: 5 equations in 3 variables. > In C:\Program Files\MATLAB\R2012b\toolbox\symbolic\symbolic\symengine.p>symengine at 54 In mupadengine.mupadengine>mupadengine.evalin at 97 In mupadengine.mupadengine>mupadengine.feval at 150 In solve at 160 Warning: Explicit solution could not be found. > In solve at 169 A = [ empty sym ]

B =

Page 10: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

[]

C =

[]

D =

[]

E =

[]If something like this happens, you can try partially solving by hand to reduce the system (you’ll need to re-declare the variables or the previous error will mess up your equations, you may also try changing the names of your variables), or switch to matrix methods.

>> H=[1 0 1 0 0 0;-3 1 -2 1 0 0;3 -3 1 -1 1 6;-1 3 0 0 0 0;0 -1 0 0 0 1];>> rref(H)

ans =

1 0 0 0 0 -3 0 1 0 0 0 -1 0 0 1 0 0 3 0 0 0 1 0 -2 0 0 0 0 1 7

>> g=-3/x-1/x^2+3/(x-1)-2/(x-1)^2+7/(x-1)^3 g = 3/(x - 1) - 2/(x - 1)^2 + 7/(x - 1)^3 - 3/x - 1/x^2 >> int(g,x) ans = 3*log(x - 1) - 3*log(x) + 2/(x - 1) - 7/(2*(x^2 - 2*x + 1)) + 1/x >>

2e.This one is already factored, so we just need the coefficients.

Page 11: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

>> syms A B C D E F G H>> f=A/x+B/x^2+C/(x-1)+D/(x+3)+E/(x+3)^2+(F*x+G)/(x^2+4) f = A/x + B/x^2 + (G + F*x)/(x^2 + 4) + C/(x - 1) + D/(x + 3) + E/(x + 3)^2 >> simple(f) … collect(x): ((A + C + D + F)*x^6 + (5*A + B + 6*C + 2*D + E + 5*F + G)*x^5 + (7*A + 5*B + 13*C + D - E + 3*F + 5*G)*x^4 + (11*A + 7*B + 24*C + 8*D + 4*E - 9*F + 3*G)*x^3 + (12*A + 11*B + 36*C - 12*D - 4*E - 9*G)*x^2 + (12*B - 36*A)*x - 36*B)/(x^7 + 5*x^6 + 7*x^5 + 11*x^4 + 12*x^3 - 36*x^2)

>> [A,B,C,D,E,F,G]=solve('A+C+D+F=0','5*A+B+6*C+E+5*F+G=0','7*A + 5*B + 13*C + D - E + 3*F + 5*G=0','11*A + 7*B + 24*C + 8*D + 4*E - 9*F + 3*G=0','12*A + 11*B + 36*C - 12*D - 4*E - 9*G=0','12*B - 36*A=0','-36*B=1')Warning: 7 equations in 5 variables. > In C:\Program Files\MATLAB\R2012b\toolbox\symbolic\symbolic\symengine.p>symengine at 54 In mupadengine.mupadengine>mupadengine.evalin at 97 In mupadengine.mupadengine>mupadengine.feval at 150 In solve at 160 Warning: Explicit solution could not be found. > In solve at 169 A = [ empty sym ]

B =

[]

C =

[]

D =

[]

Page 12: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

E =

[]

F =

[]

G =

[]

If something like this happens, you can try partially solving by hand to reduce the system (you’ll need to re-declare the variables or the previous error will mess up your equations, you may also try changing the names of your variables), or switch to matrix methods.

>> X=[1 0 1 1 0 1 0 0;5 1 6 2 1 5 1 0;7 5 13 1 -1 3 5 0;11 7 24 8 4 -9 3 0;12 11 36 -12 -4 0 -9 0;-36 12 0 0 0 0 0 0;0 -36 0 0 0 0 0 1];

>> Y=rref(X)

Y =

Columns 1 through 7

1.0000 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 1.0000

Column 8

-0.0093 -0.0278 0.0125 -0.0029 -0.0021 -0.0003 0.0086

>> A=Y(1,8)

Page 13: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

A =

-0.0093

>> B=Y(2,8)

B =

-0.0278

>> C=Y(3,8)

C =

0.0125

>> D=Y(4,8)

D =

-0.0029

>> E=Y(5,8)

E =

-0.0021

>> F=Y(6,8)

F =

-2.9586e-04

>> G=Y(7,8)

G =

0.0086

>> g=A/x + B/x^2 + (G + F*x)/(x^2 + 4) + C/(x - 1) + D/(x + 3) + E/(x + 3)^2 g = 1/(80*(x - 1)) - (x/3380 - 2/233)/(x^2 + 4) - 1/(340*(x + 3)) - 1/(468*(x + 3)^2) - 1/(108*x) - 1/(36*x^2)

Page 14: betsymccall.netbetsymccall.net/prof/courses/fall16/aacc/192lab2key.docx · Web viewMAT 192, Lab #2 Key My comments are in blue. 1a. >> f=sin(x)^17*cos(x)^20 f = cos(x)^20*sin(x)^17

>> int(g,x) ans = atan(x/2)/233 + log(x - 1)/80 - log(x + 3)/340 - log(x^2 + 4)/6760 - log(x)/108 + 1/(468*(x + 3)) + 1/(36*x) >> int(1/(x^2*(x-1)*(x+3)^2*(x^2+4)),x) ans = log(x - 1)/80 - (215*log(x + 3))/73008 + log(x - 2*i)*(- 1/6760 - (29*i)/13520) + log(x + 2*i)*(- 1/6760 + (29*i)/13520) - log(x)/108 + ((7*x)/234 + 1/12)/(x^2 + 3*x)

these are equivalent answers, but MatLab factored x2+4 and solved with complex solutions instead of arctan. We could use algebra to show they are equivalent.