My favorites | Sign in
Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 694: Add tests from "Review of CAS mathematical capabilities", by Michael Wester
5 people starred this issue and may be notified of changes. Back to list
Status:  Started
Owner:  ----
Cc:  ondrej.certik
Type-Defect
Priority-Medium
EasyToFix
Milestone-Release0.6.6


Sign in to add a comment
 
Reported by ondrej.certik, Feb 10, 2008
Go through the 1994 paper "Review of CAS mathematical capabilities", by
Michael Wester, available for example here:

http://www.math.unm.edu/~wester/cas/book/Wester.pdf

And write tests for each of the example in there if sympy can do it, or a
new issue if it cannot. Together with fixing the issue 688, this should
produce a nice documentation of how to do the ususal things in sympy.

See also:

http://www.sagemath.org/doc/html/ref/module-sage.calculus.wester.html
Comment 1 by kirill.smelkov, Apr 19, 2008
This should be an easy-to-do task. And also you'll learn a lot while doing it!
Labels: easy-to-fix
Comment 2 by rwnobrega, May 21, 2008
(No comment was entered for this change.)
Labels: -easy-to-fix EasyToFix
Comment 3 by robert.kern, Jan 11, 2009
Here's a start.
test_wester.py
11.2 KB Download
Comment 4 by ondrej.certik, Jan 12, 2009
(No comment was entered for this change.)
Labels: NeedsReview Milestone-Release0.6.4
Comment 5 by ondrej.certik, Jan 12, 2009
Here is what I get:

$ bin/test test_wester.py 
============================= test process starts ==============================
executable:   /usr/bin/python  (2.5.2-final-0)

test_wester.py[84] ...............ffffffffffffffffffffffffffffffXfffffffffffffff
ffffff.................                                                     [OK]

________________________________ xpassed tests _________________________________
test_wester.py:'XPASS: test_H4'

====== tests finished: 32 passed, 51 xfailed, 1 xpassed in 34.91 seconds =======


so test_H4 actually passes. Thanks for the work, great job!

I am thinking where to put the test, any ideas?
Comment 6 by robert.kern, Jan 13, 2009
I'm developing it more here:

http://github.com/rkern/sympy-rkern/blob/HEAD/sympy/core/tests/test_wester.py

test_H4 technically passes, but per the comment there, it's purely an accident.
Comment 7 by robert.kern, Jan 13, 2009
Also note that adding this file to the test suite appears to be causing problems with
other tests. See issue #1264.
Comment 8 by fredrik.johansson, Jan 14, 2009
K4, K5: expand(complex=True) should work. x and y need to be declared real.

Also D4 works (ceil should be ceiling)
Comment 9 by robert.kern, Jan 14, 2009
@fredrik.johansson: Fixed, thank you.
Comment 10 by ondrej.certik, Feb 08, 2009
I rebased your commits, available here:

http://github.com/certik/sympy/tree/wester

Currently this is the result of the tests for me:

$ bin/test sympy/core/tests/test_wester.py 
============================= test process starts ==============================
executable:   /usr/bin/python  (2.5.2-final-0)

sympy/core/tests/test_wester.py[115] .F............ffffffffffffffsffffffffffffff
fffffffffsffffffffffffffffffffffffffffff............s.s......E.s.....F.F  [FAIL]

________________________________________________________________________________
___________________ sympy/core/tests/test_wester.py:test_J6 ____________________
  File "/home/ondra/repos/sympy/sympy/core/tests/test_wester.py", line 466, in test_J6
    assert mpmath.jn(2, 1+1j).ae(mpc('0.04157988694396212', '0.24739764151330632'))
AttributeError: 'module' object has no attribute 'jn'

________________________________________________________________________________
___________________ sympy/core/tests/test_wester.py:test_C2 ____________________
  File "/home/ondra/repos/sympy/sympy/core/tests/test_wester.py", line 39, in test_C2
    (41, 1), (43, 1), (47, 1)])
AssertionError
________________________________________________________________________________
___________________ sympy/core/tests/test_wester.py:test_K8 ____________________
  File "/home/ondra/repos/sympy/sympy/core/tests/test_wester.py", line 555, in test_K8
    assert simplify(sqrt(1/z) - 1/sqrt(z)) != 0
AssertionError
________________________________________________________________________________
___________________ sympy/core/tests/test_wester.py:test_K10 ___________________
  File "/home/ondra/repos/sympy/sympy/core/tests/test_wester.py", line 565, in test_K10
    assert simplify(sqrt(1/z) + 1/sqrt(z)) == 0
AssertionError

 tests finished: 39 passed, 3 failed, 5 skipped, 67 xfailed, 1 exceptions in 5.11
seconds 
DO *NOT* COMMIT!


Plus there are two more fixes in your repository, that should be polished & merged.
Labels: -NeedsReview -Milestone-Release0.6.4 Milestone-Release0.6.5
Comment 11 by ondrej.certik, Feb 08, 2009
(No comment was entered for this change.)
Owner: ---
Comment 12 by asmeurer, Apr 07, 2009
Ondrej, I've started adding tests to the file in your git hub, but I couldn't figure out how to make git download 
the wester branch, so I downloaded it manually (still quite new to git here).  How can I push my changes?  I went 
ahead and created my own git hub account if that helps.  
Status: Started
Cc: ondrej.certik
Comment 13 by ondrej.certik, Apr 07, 2009
Thanks! To push your changes, just do:

git push repository branch_name

where branch_name is the name of your branch and repository is the name of your
repository, if you create a new repository at github, it tells you everything.
Comment 14 by asmeurer, Apr 09, 2009
I have added the L tests here: http://github.com/asmeurer/sympy/blob/4fe5c2cbffe43abafa1238ceb7a0bb597b59d201/sympy/core/tests/te
st_wester.py.  I will probably be adding more over the weekend.  Sorry about the delay.  It took me longer to 
figure out how to use git than it did to write the tests :)
Comment 15 by ondrej.certik, Apr 09, 2009
Thanks, looks good. Yes, but you will not regret learning git. :)
Comment 16 by asmeurer, Apr 13, 2009
I'm having trouble with test M3: solve(x**4+x**3+x**2+x+1,x)
Plugging this expression in to SymPy generates a humongous expression.  With my terminal fullscreen (238x58), the 
solution list fills my whole screen with pretty printing turned off, and several screens with it turned on (obviously, I refrain 
from pasting it here).  Running
l = []
s = solve(x**4+x**3+x**2+x+1,x)
for i in s:
    l.append(simplify(i))

reduces the size of the output to about half of my screen, but it is still huge.  I ran the test command in Maple, and got 
f:=solve(x**4+x**3+x**2+x+1,x);
f:=-1/4+(1/4)*sqrt(5)+(1/4*I)*sqrt(2)*sqrt(5+sqrt(5)), -1/4-(1/4)*sqrt(5)+(1/4*I)*sqrt(2)*sqrt(5-sqrt(5)), -1/4-
(1/4)*sqrt(5)-(1/4*I)*sqrt(2)*sqrt(5-sqrt(5)), -1/4+(1/4)*sqrt(5)-(1/4*I)*sqrt(2)*sqrt(5+sqrt(5))
I had no luck getting even Maple to simplify the SymPy expression down to this, though that could just be because I am 
relatively new to Maple.  I was able to determine that they are the same solutions by numerically evaluating them both.  

Test M4 is verify a solution of M3, but 
for i in s:
    print simplify((x**4+x**3+x**2+x+1).subs({x:i}))

raises a maximum recursion error.  Removing the simplify just makes each print fill the whole screen (they should all be 0).  

Any idea how to make this return a more simplified expression?  Should I report this as a bug?  The solution SymPy gives is 
technically correct (I think), but I hardly feel that this should write an assert line in the test_wester.py that is several hundred 
characters long when it could be much simpler.  
Comment 17 by andy.terrel, Apr 14, 2009
This is definitely a bug.  I would separate it out from this issue and work on it
there.  Simplify needs help.
Comment 18 by mattpap, Apr 14, 2009
I won't judge if

 solve(x**4+x**3+x**2+x+1,x)

gives correct result or not, because it's only useful for testing pretty-printing
engine. solve(), in fact roots(), should recognize that the input is a cyclotomic
polynomial and return simple result (currently quartic formula is used and is
responsible for this mess). I will sent a patch fixing this issue.
Comment 19 by ondrej.certik, Jul 13, 2009
(No comment was entered for this change.)
Labels: Milestone-Release0.6.6
Sign in to add a comment

Hosted by Google Code