Opened 7 years ago
Last modified 7 years ago
#17065 needs_work defect
use Maxima's trigrat() in symbolic simplify
Reported by: | rws | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | symbolics | Keywords: | maxima, simplification, trigonometric |
Cc: | Merged in: | ||
Authors: | Ralf Stephan | Reviewers: | |
Report Upstream: | Fixed upstream, but not in a stable release. | Work issues: | |
Branch: | u/rws/use_maxima_s_trigrat___in_symbolic_simplify (Commits, GitHub, GitLab) | Commit: | 3db6f899c380523dc6d6e940650eede5984a37fa |
Dependencies: | Stopgaps: |
Description
The ask page http://ask.sagemath.org/question/11365/simplify-trigonometric-expression/ showed that trigrat() is not used. What a waste.
Change History (12)
comment:1 Changed 7 years ago by
- Branch set to u/rws/use_maxima_s_trigrat___in_symbolic_simplify
comment:2 Changed 7 years ago by
- Commit set to 3db6f899c380523dc6d6e940650eede5984a37fa
- Status changed from new to needs_review
comment:3 Changed 7 years ago by
- Status changed from needs_review to needs_work
Quite some doctest failures on the buildbot. Some of them are probably not due this particular change, but others most probably are. A few are simply *better* answers now (that's just a matter of changing the expected output), but there are also some that are much *worse*. So the change is not uniformly an improvement.
ratsimp claims "canonical form", so that's definitely attractive. However, do we know if its rewrites always apply across the whole domain? We'd have to document if it deviates.
comment:4 follow-up: ↓ 6 Changed 7 years ago by
Since setting "needs_work" makes the buildbot link disappear, and I'm too stupid to find the results otherwise (I tried), I cannot sort this out without help, sorry.
comment:5 follow-up: ↓ 8 Changed 7 years ago by
This can even lead to disaster, I think:
sage: F = (4*cos(9*pi/180)^2 - 3)*(4*cos(27*pi/180)^2 - 3) sage: F.maxima_methods().trigrat() sqrt(5) + 2*cos(7/10*pi) - 2*cos(1/10*pi) - 2*I*sin(3/5*pi) + 2*I*sin(2/5*pi) + 1
I really am not interested in seeing I
turn up in such a simplification, regardless of the "correct" answer.
comment:6 in reply to: ↑ 4 Changed 7 years ago by
- Status changed from needs_work to needs_review
Replying to rws:
Since setting "needs_work" makes the buildbot link disappear, and I'm too stupid to find the results otherwise (I tried), I cannot sort this out without help, sorry.
Oh, that's silly. I'm setting it back to "needs review" to make the report visible for now. Hopefully we can have this fixed.
comment:7 Changed 7 years ago by
- Status changed from needs_review to needs_work
Thanks, the link is now here: http://build.sagedev.org/trac/builders/trac_builder/builds/1046 so the ticket can be set to the right status.
comment:8 in reply to: ↑ 5 ; follow-up: ↓ 12 Changed 7 years ago by
Replying to kcrisman:
This can even lead to disaster, I think:
sage: F = (4*cos(9*pi/180)^2 - 3)*(4*cos(27*pi/180)^2 - 3) sage: F.maxima_methods().trigrat() sqrt(5) + 2*cos(7/10*pi) - 2*cos(1/10*pi) - 2*I*sin(3/5*pi) + 2*I*sin(2/5*pi) + 1I really am not interested in seeing
I
turn up in such a simplification, regardless of the "correct" answer.
While this one could be resolved by adding a trigreduce
to the queue:
sage: F = (4*cos(9*pi/180)^2 - 3)*(4*cos(27*pi/180)^2 - 3) sage: F.maxima_methods().trigrat() sqrt(5) + 2*cos(7/10*pi) - 2*cos(1/10*pi) - 2*I*sin(3/5*pi) + 2*I*sin(2/5*pi) + 1 sage: _.maxima_methods().trigreduce() sqrt(5) - 2*cos(3/10*pi) - 2*cos(1/10*pi) + 1
I cannot see how to fix the doctest failure:
File "src/doc/de/thematische_anleitungen/sage_gymnasium.rst", line 394, in doc.de.thematische_anleitungen.sage_gymnasium Failed example: (sin(x + y)/(log(x) + log(y))).simplify_full() Expected: (cos(y)*sin(x) + cos(x)*sin(y))/log(x*y) Got: ((-I*arctan2(0, x) - I*arctan2(0, y))*sin(x + y) + log(abs(x)*abs(y))*sin(x + y))/(arctan2(0, x)^2 + 2*arctan2(0, x)*arctan2(0, y) + arctan2(0, y)^2 + log(abs(x))^2 + 2*log(abs(x))*log(abs(y)) + log(abs(y))^2)
the minimal case being
sage: log(x).maxima_methods().trigrat() I*arctan2(0, x) + log(abs(x))
comment:9 follow-up: ↓ 10 Changed 7 years ago by
On the other hand, replacing trigrat
with trigsimp/trigexpand/trigreduce
will fail in this case:
sage: sin(1/8*pi)*sin(3/8*pi)*sin(5/8*pi)*sin(7/8*pi) sin(7/8*pi)*sin(5/8*pi)*sin(3/8*pi)*sin(1/8*pi) sage: _.maxima_methods().trigreduce() TypeError Traceback (most recent call last) /home/ralf/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __init__(self, parent, value, is_name, name) 624 self._name = parent._create(value, name=name) 625 except (TypeError, RuntimeError, ValueError) as x: --> 626 raise TypeError(x) 627 628 def _latex_(self): TypeError: ECL says: Unrecognised output from sp1sintcos.
comment:10 in reply to: ↑ 9 Changed 7 years ago by
Replying to rws:
On the other hand, replacing
trigrat
withtrigsimp/trigexpand/trigreduce
will fail in this case: [...]
Yes, I noticed that one too. I have confirmed that the same problem arises in Maxima 5.34.1 on SBCL, so it's probably a maxima problem. This is now: https://sourceforge.net/p/maxima/bugs/2818/
comment:11 Changed 7 years ago by
- Report Upstream changed from N/A to Fixed upstream, but not in a stable release.
comment:12 in reply to: ↑ 8 Changed 7 years ago by
While some of the mentioned problems have been fixed in recent Maxima, this no longer works:
sage: F = (4*cos(9*pi/180)^2 - 3)*(4*cos(27*pi/180)^2 - 3) sage: F.maxima_methods().trigrat() sqrt(5) + 2*cos(7/10*pi) - 2*cos(1/10*pi) - 2*I*sin(3/5*pi) + 2*I*sin(2/5*pi) + 1 sage: _.maxima_methods().trigreduce() sqrt(5) - 2*cos(3/10*pi) - 2*cos(1/10*pi) + 1
Please review.
New commits:
17065: do trigrat after trigexpand; doctest