



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Math 128a - Homework 4 - Due Sept 28 at the beginning of class
Vn =
∑^ n
i=
aixn−i
Proof byinduction: When n = 1 this just says V 1 = a 1 which we are given. Assume the statement is true for n − 1. Thus
Vn− 1 =
n∑− 1
i=
aixn−^1 −i^ so :
Vn = (
n∑− 1
i=
aixn−^1 −i)x + an
n∑− 1
i=
aixn−i) + anxn−n
∑^ n
i=
aixn−i
i=
x^18 −i
= 104 (x^17 + x^16 +... + x^2 + x + 1)
Then we take 20% in taxes off, but we don’t get taxed on the total amount we put in, so we are left with V 18 − (0.2)(V 18 − 18(10^4 )) = 0. 8 · V 18 + 3. 6 · 104 ; we want to find an r that makes this quantityat least 405592. In other words, solve the following for x and then set r = x − 1:
0 .8(10^4 )x^17 + 0.8(10^4 )x^16 +... + 0.8(10^4 )x + ((0. 8 · 104 + 3. 6 · 104 ) − 405592) = 0
To find the roots of this polynomial I ran the following line on Matlab:
p = [.8e4*ones(1,17), .8e4 + 3.6e4 - 405592]; roots(p) ans = -1.2738+ 0.2321i -1.2738- 0.2321i -1.1080+ 0.6653i -1.1080- 0.6653i -0.7989+ 1.0096i -0.7989- 1.0096i -0.3887+ 1.2192i -0.3887- 1.2192i 0.0667+ 1.2665i 0.0667- 1.2665i 0.5044+ 1.1461i 0.5044- 1.1461i 0.8625+ 0.8752i 0.8625- 0.8752i 1.0852+ 0.4904i 1.0852- 0.4904i
So the root that matters to us is x = 1.1013, or r = 10.03%. If we can make more that 10.03% interest on our investments we should be able to do it, so the stock market will have to do slightly better than 10% for our child to go to Stanford. Just to double check I ran:
V=1e4;for cnt=2:18,V=V1.1013+1e4;end,V=V.8 + 1.8e5*. V =
which is (almost) what we want. Roundoff in this last computation can onlyaffect V in its last figures, because V is computed bymultiplying and adding positive numbers, so a floating point error bound will turn out to be O(V · macheps). Note that all the coeffients of the polynomial we wanted to solve are positive except the constant term, which is negative, which means that the slope is positive for positive arguments, and p(0) < 0 so there must be a unique positive real root, which is what we want.
f 1 (x, y) = x^2 + a · y^2 − 1 = 0 f 2 (x, y) = (x − 1)^2 + y^2 − 1 = 0
where a is a parameter.
Part 1. Solve the equations explicitlybyhand. Show that for all but a finite number of (complex) values of a, there are four (possiblycomplex) solutions ( x, y), but for this finite set of a’s, there are fewer solutions. Exhibit all solutions, and the finite set of a’s, explicitly. Four is the upper bound on the number of solutions given byBezout’s theorem as described in class
1 − (x − 1)^2 since we might have a = 0:
r 1 =
a +
a^2 − a + 1 a − 1
a +
a^2 − a + 1 a − 1
r 2 =
a +
a^2 − a + 1 a − 1
a +
a^2 − a + 1 a − 1
r 3 =
a −
a^2 − a + 1 a − 1
a −
a^2 − a + 1 a − 1
r 4 =
a −
a^2 − a + 1 a − 1
a −
a^2 − a + 1 a − 1
Part 2. Write down two explicit formulas for Newton iteration for this system. First, write it in the form (^) [ xi+ yi+
xi yi
x^2 i + a · y^2 i − 1 (xi − 1)^2 + y^2 i − 1
where you explicitly exhibit the Jacobian J and its inverse J−^1. Second, evaluate this ex- pression explicitly, i.e. multiply it out and simplify. Answer: First we explicitlycalculate J and J−^1
J = 2
x ay x − 1 y
|J| = 4 y[x − ax + a]
J−^1 =
y −ay 1 − x x
2 y[x − ax + a]
y −ay 1 − x x
so that : ( xi+ yi+
xi yi
2 yi[xi − axi + a]
yi −ayi 1 − xi xi
x^2 i + ay^2 i − 1 (xi − 1)^2 + y i^2 − 1
Multiplying out and simplifying we get:
xi+1 = xi 2
1 − axi 2(xi − axi + a)
yi+1 =
yi 2
x^2 i − xi + 1 2 yi(xi − axi + a)
Part 3. Using these formulas, write a (veryshort) Matlab program to implement Newton iteration just for this example. It need onlyimplement one step, i.e. not test test convergence, so that you can just run it ”by hand” and look at the iterates to determine convergence. Thus it need onlybe a few lines long at most.
Answer: The following short program works (using 2-by-1 column vectors):
function [u1] = f1f2Newton(u0,a)
x0 = u0(1); y0 = u0(2); x1 = x0./2 + (1 - a.x0)./(2.(x0 - a.x0 + a)); y1 = y0./2 + (x0^2 -x0+1)/(2.y0.(x0 - a.x0 + a)); u1 = [x1; y1];
Case a = 1 The true solutions are
r 1 = (5. 000000000000000 e − 01 , 8. 660254037844386 e − 01) r 2 = (5. 000000000000000 e − 01 , − 8. 660254037844386 e − 01)
Myrandom perturbations were:
r˜ 1 = (5. 022823383258417 e − 01 , 8. 661856500355939 e − 01) r˜ 2 = (5. 041070358214763 e − 01 , − 8. 698766478912214 e − 01)
The following is a list of the relative errors in the successive Newton iterations:
r iteration x error yerror 0 4.564676651683364e-03 1.850364324822745e- 1 0 3.489185770072777e- 2 0 6.087330680015810e- 3 0 0 r iteration x error yerror 0 8.214071642952625e-03 4.447033643532061e- 1 0 2.103965223123728e- 2 0 2.213289028823506e- 3 0 0
This shows that it took 3 steps in both cases to converge and that the number of digits did roughlydouble at each step. Although there seem to be multiple roots so that
Perturbed root is:
r˜ 4 = ( 9. 525902730462289 e − 01 − 1. 558144024197772 e − 01 i, − 1. 017785863530629 e + 00 + 8. 637730631122583 e − 03 i)
The following are the relative errors for each successive iteration:
iteration x error yerror 0 9.218129707448048e-03 7.382072458106622e- 1 4.058560323436797e-05 6.779658244202396e- 2 7.932815817136543e-10 2.977020893438061e- 3 1.196520692413957e-16 3.948937458207650e- 4 2.901988940035250e-17 6.867717318621998e- 5 1.297808907974276e-16 2.208974879556959e-
Newton does appear to have converged quadratically, i.e. number of correct digits doubled with each step, and it took about 3 iterations to converge.