Menu

#3374 trigsimp/trigonometricp fails with pderivop

None
closed
nobody
5
2017-12-22
2017-12-19
bigfooted
No

in my codes, I have to clean my expressions from pderivop terms by converting back to diff form or trigsimp fails. I mentioned this about a year ago on the mailing list and Robert Dodier provided a solution.

There might be a more general approach needed than the fix from Robert...

copy-pasted old correspondence below:

On Mon, 2016-11-28 at 07:43 +0000, Robert Dodier wrote:

On 2016-11-27, nijso beishuizen nijso@... wrote:

trigsimp fails when the expression contains a (pdiff) derivative to a
power:

load(pdiff);
expr:pderivop(f,1)((y))^2;

trigsimp(%);
get: argument must be a symbol or a string; found: f
(1)
0: trigonometricp(exp=pderivop(f,1)(y)) (trgsmp.mac line 54)
1: listoftrigsq(expn=pderivop(f,1)(y)^2) (trgsmp.mac line 137)
2: trigsimp1(expn=pderivop(f,1)(y)^2) (trgsmp.mac line 107)
-- an error. To debug this try: debugmode(true);

Is this a limitation of trigsimp when using pdiff?

I think the problem is that trigonometricp doesn't bother to check that
the argument to 'get' is a symbol. For expressions like foon,
that's not true. I think we can fix that error by just adding a check to
avoid calling 'get' with a non-symbol argument.

One attempt to fix it is shown below. But maybe we should fix it by
extracting the foo from foon instead of just returning false. Any
comments on this point are welcome.

best,

Robert Dodier

diff --git a/share/trigonometry/trgsmp.mac b/share/trigonometry/trgsmp.mac
index efd43a2..d9d1d20 100644
--- a/share/trigonometry/trgsmp.mac
+++ b/share/trigonometry/trgsmp.mac
@@ -50,9 +50,10 @@ eval_when([translate,batch,demo],

/ Predicates /

-trigonometricp(exp):=
- is(get(inpart(exp,0),'type)='trigonometric
- or get(piece,'type)='hyper_trigonometric)$
+trigonometricp(exp):=
+ if not atom(exp) and symbolp(inpart(exp, 0))
+ then is(get(inpart(exp,0),'type)='trigonometric
+ or get(piece,'type)='hyper_trigonometric)$

/ Rules /

Discussion

  • Robert Dodier

    Robert Dodier - 2017-12-22
    • labels: --> simplification, trigsimp, trigonometry
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2017-12-22

    Fixed by commit d4bdc65. Closing this report.

     

Log in to post a comment.