-
-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
calculus -- wrap maxima's symbolic summation #3587
Comments
comment:1
I would like to add a +1 to this proposal as I'm not planning on implementing symbolic summation anytime in the near (or far) future, so I would be really happy if someone would work on this. |
comment:3
"sum" is probably the most appropriate name for this, but we'd have to make sure that it behaves the same way as Python's sum. |
comment:4
The attached patch adds a summation command which wraps simplify_sum from maxima. |
comment:5
Many thanks for the patch, this was long overdue. A few comments after reading your patch: Your patch replicates the way integrate/integral works perfectly. Though, as Mike wrote in comment:3, we should just call this http://groups.google.com/group/sage-devel/browse_thread/thread/bd4eb3b613c98030 I suggest putting a Here are some suggested changes:
In the long term, I would like to see |
comment:6
Replying to @burcin:
It would be great if you could do this.
I will take care of these.
This is definitely necessary. Currently there is no way to interact with an unevaluated integral or sum.
|
comment:7
Attachment: summation.patch.gz Replying to @burcin:
I posted a new patch that takes care of these issues. The second patch (sum.patch) renames summation to sum. This currently overwrites the python sum command. |
Attachment: sum.patch.gz |
comment:8
I updated sum.patch so that it's compatible with builtin.sum. Burcin, can you look at this? |
Author: Wilfried Huss |
Reviewer: Burcin Erocal, Mike Hansen |
comment:9
I uploaded a new patch in attachment: trac_3587-maxima_simplify_sum.patchThis has both patches folded together, and renames I am OK with the patch, and ready to give it a positive review. However, there is a problem, maxima returns wrong results in certain cases:
It seems that maxima doesn't handle definite sums with "non natural" bounds. I.e., in the examples above the bounds don't span the whole support of the expression, so one needs further processing to get the final result after calling Zeilberger's algorithm. Indefinite sums seem to be fine. In this case, we could check the inputs, and raise a warning if we have a definite sum. I'll try to do this, but don't count on me since I already signed up for a lot this week. |
Attachment: trac_3587-maxima_simplify_sum.patch.gz |
comment:10
I installed this, but it does not seem to work as advertised. Namely,
It does behave as desired if I go to Maxima and load(simplify_sum) etc., but that's not the same. Somehow it's staying symbolic for some reason. This is off of 4.1.1 on Mac OSX.5.
Looks like this problem is fixed in Maxima 5.19 (at least they work properly in 5.19.1), so this is another good reason to get that in Sage soon (there was an experimental spkg posted at http://sage.math.washington.edu/home/kirkby/Solaris-fixes/maxima-5.19.0/maxima-5.19.0.spkg at one point). Incidentally, apparently it never got to as heavy a hitter as Zeilberger, but I'm not sure where the problem was. |
comment:11
Replying to @kcrisman:
It works for me on sage-4.1.1 on Linux. I don't have a Mac to check. |
comment:12
The fix for my problem is to change
by
the need for which perhaps does depend on the operating system. Can someone check that this doesn't break Linux? |
comment:14
This should fix all the outstanding issues. It is built off of 4.1.1, with #6564 and (then) #6699 applied, then this patch. Several additional doctests/fixes to them are included beyond the previous patch, in addition to the Maxima init fix. Should definitely be tested on Linux to make sure the fix for OSX didn't break Linux! |
Changed reviewer from Burcin Erocal, Mike Hansen to Burcin Erocal, Mike Hansen, Karl-Dieter Crisman |
comment:15
I browsed through the patch---is it still easy to access the (fast) native python sum command, or will we have to import that into the namespace? In other words, was the suggestion given above about calling the python sum vs. this new sum depending on the arguments implemented? If not, I see a serious, far-reaching problem with backwards compatibility... |
comment:16
Well, the following was identical with and without the patch:
And the same with summing m = 5l, both 0.79 s, and summing n = 100m, both about 80 s. And sum(l,3) returns the correct answer (without the L). Also, earlier mhansen seems to indicate that it's still okay - I don't know exactly where in the code that happens, though. Hope this helps. |
comment:17
Fix this one broken doctest and this gets a positive review from me: wstein@sage:~/build/sage-4.1.2.alpha1$ ./sage -t devel/sage/sage/misc/functional.py
sage -t "devel/sage/sage/misc/functional.py"
**********************************************************************
File "/scratch/wstein/build/sage-4.1.2.alpha1/devel/sage/sage/misc/functional.py", line 442:
sage: sum(k * binomial(n, k), k, 1, n)
Expected:
1/2*2^n*n
Got:
n*2^(n - 1)
**********************************************************************
File "/scratch/wstein/build/sage-4.1.2.alpha1/devel/sage/sage/misc/functional.py", line 480:
sage: sum(a*q^k, k, 0, oo)
Expected:
Traceback (most recent call last):
...
ValueError: Sum is divergent.
Got:
-a/(q - 1)
**********************************************************************
1 items had failures:
2 of 20 in __main__.example_25
***Test Failed*** 2 failures.
For whitespace errors, see the file /scratch/wstein/build/sage-4.1.2.alpha1/tmp/.doctest_functional.py
[8.3 s]
exit code: 1024
----------------------------------------------------------------------
The following tests failed:
sage -t "devel/sage/sage/misc/functional.py"
Total time for all tests: 8.3 seconds
wstein@sage:~/build/sage-4.1.2.alpha1$ The above is just the result of changes in Maxima going from 5.16 to 5.19 in sage-4.1.2. -- William |
comment:18
This is nice! Just a small note: Sphinx warns about the indentation of the new
|
fixes the doctest errors reported by William |
comment:19
Attachment: trac_3587-fix_doctests.patch.gz Okay, I fixed those tests; there were identical ones elsewhere I did fix but functional.py escaped me. I also think I fixed the note issue. Since #6197 is merged I also used the correct algorithm=maxima behavior. I don't have Maple so I didn't feel comfortable changing the Maple behavior, but it would be easy to open a new ticket for that if the appropriate algorithm worked, which it certainly seems like it should post-#6197. I'm going to assume that the builtin sum is indeed okay - great! |
Changed reviewer from Burcin Erocal, Mike Hansen, Karl-Dieter Crisman to Burcin Erocal, Mike Hansen, Karl-Dieter Crisman, William Stein |
comment:20
Use only the 5-19-1 patch. |
Attachment: trac_3587-binomial_workaround.patch.gz removes the workaround for binomials. Depends on #6197 |
comment:21
Looks like I have been a little too late. I have checked that algorithm=maple also works without the workaround for #6197. |
This comment has been minimized.
This comment has been minimized.
comment:22
Great, I'll do that as well. |
comment:23
I get tons of doctest failures when I apply this patch, say to sage-4.1.2.alpha1:
See http://sage.math.washington.edu/home/wstein/build/sage-4.1.2.alpha1/test_3587.out |
comment:24
Did you do #6197? |
comment:25
This patch in fact applies cleanly to 4.1.2.alpha2, and none of the files above have doctest failures with it. Please review. |
Based on 4.2.1, apply only this patch |
comment:26
Attachment: trac_3587-maxima_simplify_sum-with-maxima-5-19-1.patch.gz Please someone (beyond myself and the author) review this! It would be perfect for the big 4.3 release coming up! |
Merged: sage-4.3.alpha1 |
comment:28
Positive review from me (by the way). |
Maxima has good symbolic summation and it would be easy to wrap in the calculus package.
We are constantly getting stuff like this:
Probably the only reason that this hasn't been done yet is the calculus rewrite by gfurnish.
That is not a good enough reason, and don't worry, the work won't be lost.
CC: @burcin @jasongrout
Component: calculus
Author: Wilfried Huss
Reviewer: Burcin Erocal, Mike Hansen, Karl-Dieter Crisman, William Stein
Merged: sage-4.3.alpha1
Issue created by migration from https://trac.sagemath.org/ticket/3587
The text was updated successfully, but these errors were encountered: