# Exponentiation makes a formula go crazy?

Hi guys,

I'm new to Sage, so I hope that somebody will help me, because I've been wasting a whole day tring to fix a (relatively) simple plot that just won't work. Here's the code:

k = var('k')
f(x) = (1 - e ^ (- (k *33 * x) / 1024)) ^ k
g(y) = sum(f(x),x,y,15)
h(z) = f(z) - g(z+1)
plot([h(l) for l in range(1,15)], (k,10,15))


It fails saying (after a lot of other things): ValueError: Variable 'x' not found

Now, I believe the error is in the f(x) formula, because if I cahge it to something simpler, but still with x and k I get the correct result and it plots. But why is the one above not working? Does it have something to do with the exponentiation?

Thank you so much for any clue on what's wrong!

edit retag close merge delete

Sort by ยป oldest newest most voted

Huh, this is an interesting one. In principle, it should work, but your sum is so big (not long, just complicated) that it doesn't expand.

sage: h(1)
(-e^(-33/1024*k) + 1)^k - sum(((e^(33/1024*k*x) - 1)*e^(-33/1024*k*x))^k, x, 2, 15)
sage: sum(((e^(33/1024*k*x) - 1)*e^(-33/1024*k*x))^k, x, 2, 15)
((e^(33/512*k) - 1)*e^(-33/512*k))^k + ((e^(99/1024*k) - 1)*e^(-99/1024*k))^k + ((e^(33/256*k) - 1)*e^(-33/256*k))^k + ((e^(165/1024*k) - 1)*e^(-165/1024*k))^k + ((e^(99/512*k) - 1)*e^(-99/512*k))^k + ((e^(231/1024*k) - 1)*e^(-231/1024*k))^k + ((e^(33/128*k) - 1)*e^(-33/128*k))^k + ((e^(297/1024*k) - 1)*e^(-297/1024*k))^k + ((e^(165/512*k) - 1)*e^(-165/512*k))^k + ((e^(363/1024*k) - 1)*e^(-363/1024*k))^k + ((e^(99/256*k) - 1)*e^(-99/256*k))^k + ((e^(429/1024*k) - 1)*e^(-429/1024*k))^k + ((e^(231/512*k) - 1)*e^(-231/512*k))^k + ((e^(495/1024*k) - 1)*e^(-495/1024*k))^k


This is another manifestation of this question, I think, and ultimately I think it leads to Trac 9424.

But you want a workaround, presumably. From that ticket, we can try:

plot([SR(maxima_calculus(h(l)).simplify_sum()) for l in range(1,15)], (k,10,15))


This seems to work.

more

Tanks, that actually solved it! You made my day... :D

( 2014-11-19 17:52:43 +0100 )edit

Great! Now we just have to fix the actual problem.

( 2014-11-20 03:38:36 +0100 )edit

( 2014-12-02 14:49:54 +0100 )edit

## Stats

Seen: 240 times

Last updated: Nov 19 '14