Ask Your Question

Exponentiation makes a formula go crazy?

asked 2014-11-18 18:05:17 -0600

saggio gravatar image

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-11-18 21:08:55 -0600

kcrisman gravatar image

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.

edit flag offensive delete link more


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

saggio gravatar imagesaggio ( 2014-11-19 10:52:43 -0600 )edit

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

kcrisman gravatar imagekcrisman ( 2014-11-19 20:38:36 -0600 )edit

See also which seems to have a fix.

kcrisman gravatar imagekcrisman ( 2014-12-02 07:49:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-11-18 18:05:17 -0600

Seen: 65 times

Last updated: Nov 18 '14