Ask Your Question
0

Exponentiation makes a formula go crazy?

asked 2014-11-19 01:05:17 +0100

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
0

answered 2014-11-19 04:08:55 +0100

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

Comments

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

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

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

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

See also http://trac.sagemath.org/ticket/15346 which seems to have a fix.

kcrisman gravatar imagekcrisman ( 2014-12-02 14:49:54 +0100 )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

Stats

Asked: 2014-11-19 01:05:17 +0100

Seen: 331 times

Last updated: Nov 19 '14