Practice Set A

 

1.

(a)

1111 - 345  

 

ans =

   766  

 

(b)

format long; [exp(14), 382810*pi]  

 

ans =

  1.0e+006 *

   1.20260428416478   1.20263308372071  

 

The second number is bigger.

 

(c)

[2709/1024, 10583/4000, 2024/765, sqrt(7)]  

 

ans =

  Columns 1 through 2

   2.64550781250000   2.64575000000000

  Columns 3 through 4

   2.64575163398693   2.64575131106459  

 

The third, that is 2024/765, is the best approximation.

 

2.

(a)

cosh(0.1)  

 

ans =

   1.00500416805580  

 

(b)

log(2)

 

ans =

   0.69314718055995  

 

(c)

atan(1/2)

 

ans =

   0.46364760900081  

 

format short;  

 

3.

[x, y, z] = solve('3*x + 4*y + 5*z = 2', '2*x - 3*y + 7*z = -1', 'x -6*y + z = 3', 'x', 'y', 'z')  

 

x =

241/92

y =

-21/92

z =

-91/92  

 

Now we'll check the answer.

 

A = [3, 4, 5; 2, -3, 7; 1, -6, 1]; A*[x; y; z]  

 

ans =

[  2]

[ -1]

[  3]  

 

It checks!

 

4.

[x, y, z] = solve('3*x - 9*y + 8*z = 2', '2*x - 3*y + 7*z = -1', 'x -6*y + z = 3', 'x', 'y', 'z') 

 

x =

39/5*y+22/5

y =

y

z =

-9/5*y-7/5  

 

We get a one-parameter family of answers depending on the variable y.  In fact the three planes determined by the three linear equations are not independent, because the first equation is the sum of the second and third.  The locus of points that satisfy the three equations is not a point, the intersection of three independent planes, but rather a line, the intersection of two distinct planes.  Once again we check.

 

B = [3, -9, 8; 2, -3, 7; 1, -6, 1]; B*[x; y; z] 

 

ans =

[  2]

[ -1]

[  3]  

 

5.

clear x y; syms x y; factor(x^4 - y^4)  

 

ans =

(x-y)*(x+y)*(x^2+y^2)  

 

6.

(a)

simplify(1/(1 + 1/(1 + 1/x)))  

 

ans =

(x+1)/(2*x+1)  

 

(b)

simplify(cos(x)^2-sin(x)^2)  

 

ans =

2*cos(x)^2-1  

 

Let's try simple instead.

 

[better, how] = simple(cos(x)^2 - sin(x)^2)  

 

better =

cos(2*x)

how =

combine  

 

7.

3^301  

 

ans =

  4.1067e+143  

 

sym('3')^301  

 

ans =

410674437175765127973978082146264947899391086876012309414440570235106991532497229781400618467066824164751453321793982128440538198297087323698003  

 

But note the following:

 

sym('3^301')  

 

ans =

3^301  

 

This does not work because sym, by itself, does not cause an evaluation.

 

8.

(a)

solve('8*x + 3 = 0','x')  

 

ans =

-3/8  

 

(b)

vpa(ans, 15)  

 

ans =

-.375000000000000  

 

(c)

syms p q; solve('x^3 + p*x + q = 0', 'x')  

 

ans =

[                                                                                                         1/6*(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)-2*p/(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)]

[ -1/12*(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)+p/(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)+1/2*i*3^(1/2)*(1/6*(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)+2*p/(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3))]

[ -1/12*(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)+p/(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)-1/2*i*3^(1/2)*(1/6*(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)+2*p/(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3))]  

 

(d)

ezplot('exp(x)'); hold on; ezplot('8*x - 4')  

 

  

 

fzero('exp(x) - 8*x + 4', 1)  

 

ans =

    0.7700  

 

fzero('exp(x) - 8*x + 4', 3) 

 

ans =

    2.9929  

 

9.

(a)

hold off; ezplot('x^3 - x', [-4 4])  

 

  

 

(b)

ezplot('sin(1/x^2)', [-2 2])  

 

  

 

X = -2:0.1:2;

plot(X, sin(1./X.^2))  

 

Warning: Divide by zero.

  

 

This picture is incomplete.  Let's see what happens if we refine the mesh.

 

X = -2:0.01:2; plot(X, sin(1./X.^2))  

 

Warning: Divide by zero.

  

 

Because of the wild oscillation near x = 0, neither plot nor ezplot gives a totally accurate graph of the function.

 

(c)

ezplot('tan(x/2)', [-pi pi]); axis([-pi, pi, -10, 10])

 

  

 

(d)

X = -2:0.05:2;

plot(X, exp(-X.^2), X, X.^4 - X.^2)  

 

  

 

10.

Let's plot 2x and x4 and look for points of intersection.  We plot them first with ezplot just to get a feel for the graph.

 

ezplot('x^4'); hold on; ezplot('2^x'); hold off 

 

  

 

Note the large vertical range.  We learn from the plot that there are no points of intersection between 2 and 6 or -6 and -2; but there are apparently two points of intersection between -2 and 2.  Let's change to plot now and focus on the interval between -2 and 2.  We'll plot the monomial dashed.

 

X = -2:0.1:2; plot(X, 2.^X); hold on; plot(X, X.^4, '--'); hold off   

 

  

 

We see that there are points of intersection near -0.9 and 1.2.  Are there any other points of intersection?  To the left of 0, 2x is always less than 1, whereas x4 goes to infinity as x goes to -¥.  On the other hand, both x4 and 2x go to infinity as x goes to ¥, so the graphs may cross again to the right of 6.  Let's check.

 

X = 6:0.1:20; plot(X, 2.^X); hold on; plot(X, X.^4, '--'); hold off  

 

  

 

We see that they do cross again, near x = 16.  If you know a little calculus, you can show that the graphs never cross again (by taking logarithms, for example), so we have found all the points of intersection.  Now let's use the fzero command to find these points of intersection numerically.  This command looks for a solution near a given starting point.  To find the three different points of intersection we will have to use three different starting points. The above graphical analysis suggests appropriate starting points.

 

r1 = fzero('2^x - x^4', -0.9)

r2 = fzero('2^x - x^4', 1.2)

r3 = fzero('2^x - x^4', 16)  

 

r1 =

   -0.8613

r2 =

    1.2396

r3 =

    16  

 

Let's check that these "solutions" satisfy the equation.

 

subs('2^x - x^4', 'x', r1) 

subs('2^x - x^4', 'x', r2) 

subs('2^x - x^4', 'x', r3)

 

ans =

  2.2204e-016

ans =

 -8.8818e-016

ans =

     0  

 

So r1 and r2 very nearly satisfy the equation, and r3 satisfies it exactly.  It is easily seen that 16 is a solution.  It is also interesting to try solve on this equation.

 

symroots = solve('2^x - x^4 = 0')  

 

symroots =

[   -4*lambertw(-1/4*log(2))/log(2)]

[                                16]

[ -4*lambertw(-1/4*i*log(2))/log(2)]

[    -4*lambertw(1/4*log(2))/log(2)]

[  -4*lambertw(1/4*i*log(2))/log(2)]  

 

In fact we get the three real solutions already found and two complex solutions.

 

format short; double(symroots)  

 

ans =

   1.2396         

  16.0000         

  -0.1609 + 0.9591i

  -0.8613         

  -0.1609 - 0.9591i  

 

Only the real solutions correspond to points where the graphs intersect.