rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

problem with constantp and user defined functions #2560

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-06 15:03:35 Created by robertmarik on 2008-05-04 07:35:11 Original: https://sourceforge.net/p/maxima/bugs/1409


constantp returns false if a constant is inside a user defined function.

Example: The following returns false

load(ntrig); declare(a,constant); constantp(sin(a));

but the following returns true

declare(a,constant); constantp(sin(a));

The answer from Robert Dodier in Maxima mail list

constantp assumes that if a function foo is not a Maxima built-in simplifying function, then any expression foo(x) (ignoring what might be known about x) is not constant.

There are 2 problems here. The immediate problem is that the test (MOPP) to distinguish Maxima built-in simplifying functions is buggy; in particular the presence of tellsimp rules for the operator (as created by ntrig, for example) cause MOPP to mistakenly return NIL. Not sure what we can do to fix MOPP.

The other problem is the assumption that functions other than the ones that pass MOPP are not constant. Maybe that should be relaxed. I am a little surprised that constantp('foo(1)) => false where foo is some random symbol. I suppose the rationale here is that some random function could depend on a global variable.

In summary it's clear what's going on here, but I'm not sure what to do about it at this point.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-06 15:03:36 Created by robert_dodier on 2008-08-24 03:04:29 Original: https://sourceforge.net/p/maxima/bugs/1409/#3c5c