views:

453

answers:

1

I'm trying to use WolframAlpha to solve for a variable.

I have

u(k, r) = (900-3k)r^(k-1)

and

s(n, r) = sum u(k, r), k=1 to n

and I want to solve for r with

s(5000, r) = -600000000000

I've tried various incantations, but can't seem to get it working. I can't even get s defined to evaluate it.

If you care, it is to solve this problem : http://projecteuler.net/index.php?section=problems&id=235

+1  A: 

WARNING: Spoiler below! You should ask WA to FullSimplify the expression of s(n,r) after you substitute u(k,r) into it. It should give

(3 (299 - 300 r + r^n (-299 + n + 300 r - n r)))/(-1 + r)^2

Solving the final equality is then just finding the root of a (high degree) polynomial:

299 + 200000000000 (-1 + r)^2 + (4701 - 4700 r) r^5000 == 300 r

where r != 1 since that was a pole of the original expression. Note that r must be positive so that the positive quadratic gets negated by the high-degree term. Plotting the function shows that It is positive for r < 1, and negative for r >~ 1, so the solution is somewhere past r=1. Now change variables so that x = r-1 and look near x=0:

200000000000 x^2 + (1 + x)^5000 (1 - 4700 x) - 1 - 300 x == 0

This should be enlightnening:

Plot[200000000000 x^2 + (1 + x)^5000 (1 - 4700 x) - 1 - 300 x, {x, 0, 0.003}]

Using FindRoot with a good guess gives x=0.002322108633 or r=1.002322108633.


The WA commands follow. First I used

FullSimplify[Sum[(900-3k)r^(k-1),{k,1,n]]

Then you would have to retype the expression it spits out:

Plot[(3 (299 - 300 r + r^5000 (-299 + 5000 + 300 r - 5000 r)))/(-1 + r)^2 + 6000000000,{r,-2,2}]

At this point I manually replaced r with x+1:

Plot[200000000000 x^2 + (1 + x)^5000 (1 - 4700 x) - 1 - 300 x, {x, 0, 0.003}]

And solving for the root:

FindRoot[200000000000 x^2 + (1 + x)^5000 (1 - 4700 x) - 1 - 300 x, {x, 0.0023}]

Which doesn't give enough precision, and this is as far as you can go using only WA. You can try to subtract off the first few digits that WA gives you, and do another substitution with y = x + 0.00232211 to get the next few digits, but that is too tedious for me to try.

Victor Liu
Thank you. Those equations look great. But can you please add in the wolfram alpha commands to get those functions? How do I FullSimplify? How do I solve with r!=1? Why do I do a variable change?
Paul Tarjan
I used Mathematica to obtain these, but I will edit my comment to put in the corresponding WA commands.
Victor Liu