Solution Practice Set A

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Solutions to the

Practice Sets

Practice Set A

Problem 1
(a)
1111 - 345

ans =
766
(b)
format long; [exp(14), 382801*pi]

ans =
1.0e+006 *
1.20260428416478 1.20260480938683

The second number is bigger.


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

ans =
2.64550781250000 2.64575000000000 2.64575163398693
2.64575131106459

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

235
236 Solutions to the Practice Sets

Problem 2
(a)
cosh(0.1)

ans =
1.00500416805580
(b)
log(2)

ans =
0.69314718055995
(c)
atan(1/2)

ans =
0.46364760900081

format short

Problem 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]
Practice Set A 237

[ -1]
[ 3]

It checks!

Problem 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]

Problem 5
syms x y; factor(xˆ4 - yˆ4)

ans =
(x-y)*(x+y)*(x^2+y^2)
238 Solutions to the Practice Sets

Problem 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

Problem 7
3ˆ301

ans =
4.1067e+143

sym(’3’)ˆ301

ans =
4106744371757651279739780821462649478993910868760123094144405
7023510699153249722978140061846706682416475145332179398212844
0538198297087323698003

But note the following:


sym(’3ˆ301’)
Practice Set A 239

ans =
3^301

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

Problem 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’); hold off
240 Solutions to the Practice Sets

8 x−4

40

20

–20

–40

–60
–6 –4 –2 0 2 4 6
x

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

ans =
0.7700

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

ans =
2.9929

Problem 9
(a)
ezplot(’xˆ3 - x’, [-4 4])

3
x −x

60

40

20

–20

–40

–60

–4 –3 –2 –1 0 1 2 3 4
x
Practice Set A 241

(b)
ezplot(’sin(1/xˆ2)’, [-2 2])

2
sin(1/x )

0.8

0.6

0.4

0.2

–0.2

–0.4

–0.6

–0.8

–1

–2 –1.5 –1 –0.5 0 0.5 1 1.5 2


x

X = -2:0.1:2;
plot(X, sin(1./X.ˆ2))

Warning: Divide by zero.

0.8

0.6

0.4

0.2

–0.2

–0.4

–0.6

–0.8

–1
–2 –1.5 –1 –0.5 0 0.5 1 1.5 2

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.


242 Solutions to the Practice Sets

0.8

0.6

0.4

0.2

–0.2

–0.4

–0.6

–0.8

–1
–2 –1.5 –1 –0.5 0 0.5 1 1.5 2

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])

tan(x/2)
10

–2

–4

–6

–8

–10
–3 –2 –1 0 1 2 3
x

(d)
X = -2:0.05:2;
plot(X, exp(-X.ˆ2), X, X.ˆ4 - X.ˆ2)
Practice Set A 243

12

10

–2
–2 –1.5 –1 –0.5 0 0.5 1 1.5 2

Problem 10

Let’s plot 2x and x 4 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

2x
50

45

40

35

30

25

20

15

10

−6 −4 −2 0 2 4 6
x

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
244 Solutions to the Practice Sets

16

14

12

10

0
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2

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
x 4 goes to infinity as x goes to −∞. However, both x 4 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

5
x 10
12

10

0
6 8 10 12 14 16 18 20

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
fzero 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
Practice Set A 245

intersection we will have to use three different starting points. The graphical
analysis above suggests appropriate starting points.

r1 = fzero(inline(’2ˆx - xˆ4’), -0.9)


r2 = fzero(inline(’2ˆx - xˆ4’), 1.2)
r3 = fzero(inline(’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)]
246 Solutions to the Practice Sets

[ -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.

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.

Practice Set B

Problem 1
(a)
[X, Y] = meshgrid(-1:0.1:1, -1:0.1:1); contour(X, Y, 3*Y +
Y.ˆ3 - X.ˆ3, ’k’)

0.8

0.6

0.4

0.2

−0.2

−0.4

−0.6

−0.8

−1
−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1

[X, Y] = meshgrid(-10:0.1:10, -10:0.1:10); contour(X, Y, 3*Y


+ Y.ˆ3 - X.ˆ3, ’k’)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy