|
From: Rubey, M. <mar...@tu...> - 2025-11-22 11:32:40
|
Dear Maxima! I wonder what the (intended) semantics of is(equal(a, b)) are. I found https://maxima.sourceforge.io/docs/manual/Maxima_0027s-Database.html#equal, which, by way of example, states that (%i8) is (equal (x, y)); (%o8) unknown I would have expected false. So, perhaps more precisely, when should is(equal(a, b)) return false? OK, maybe I figured it out now: is(equal(a, b)) returns true (or false) if and only if a and b are equal (or not equal) for all possible values of their variables, as determined by evaluating ratsimp(a - b); Does this mean that is(equal(a, b)) is false if and only if the function (a, b) \mapsto a-b does not have any zeros? Best wishes, Martin |
|
From: David S. <d.s...@go...> - 2025-11-23 12:38:02
|
Rubey, Martin <mar...@tu...> schrieb am So., 23. Nov. 2025, 03:03: > is(equal(a, b)) returns true (or false) if and only if a and b are equal > (or not equal) for all possible values of their variables, as determined by > evaluating ratsimp(a - b); > > Does this mean that is(equal(a, b)) is false if and only if the function > (a, b) \mapsto a-b does not have any zeros? > Yes. As far as I know, this is how it works: - If ratsimp(a-b) gives 0, then is(equal(a,b)) is true. - If ratsimp(a-b) gives a non-zero constant (no variables), then is(equal(a,b)) is false. - Otherwise, is(equal(a,b)) is unknown. Of course, this is quite limited, because it only works reliably with rational expressions due to relying on ratsimp. To get better results, first convert trigonometric/hyperbolic functions to exponential form using "exponentialize" and inverse trigonometric/hyperbolic functions to logarithmic form using "logarc". You may also want to denest roots using "sqrtdenest". Best regards David |
|
From: Stavros M. <mac...@gm...> - 2025-11-23 13:34:01
|
equal tries to do the "right thing" , but for "interesting" cases, you may need to think a bit about what you intend. For example, is(equal(float(%pi),%pi)) => true But is(equal(bfloat(%pi),%pi)) => false for all values of fpprec. And is(equal(bfloat(%pi),float(%pi)))) is true for fpprec = 3-7,11,12,14,15, and false otherwise. On Sun, Nov 23, 2025, 16:38 David Scherfgen via Maxima-discuss < max...@li...> wrote: > Rubey, Martin <mar...@tu...> schrieb am So., 23. Nov. 2025, > 03:03: > >> is(equal(a, b)) returns true (or false) if and only if a and b are equal >> (or not equal) for all possible values of their variables, as determined by >> evaluating ratsimp(a - b); >> >> Does this mean that is(equal(a, b)) is false if and only if the function >> (a, b) \mapsto a-b does not have any zeros? >> > > Yes. > > As far as I know, this is how it works: > - If ratsimp(a-b) gives 0, then is(equal(a,b)) is true. > - If ratsimp(a-b) gives a non-zero constant (no variables), then > is(equal(a,b)) is false. > - Otherwise, is(equal(a,b)) is unknown. > > Of course, this is quite limited, because it only works reliably with > rational expressions due to relying on ratsimp. > > To get better results, first convert trigonometric/hyperbolic functions to > exponential form using "exponentialize" and inverse > trigonometric/hyperbolic functions to logarithmic form using "logarc". You > may also want to denest roots using "sqrtdenest". > > Best regards > David > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |
|
From: Michel T. <ta...@lp...> - 2025-11-23 14:22:30
|
Le 23/11/2025 à 13:37, David Scherfgen via Maxima-discuss a écrit : > Rubey, Martin <mar...@tu...> schrieb am So., 23. Nov. > 2025, 03:03: > > is(equal(a, b)) returns true (or false) if and only if a and b are > equal (or not equal) for all possible values of their variables, > as determined by evaluating ratsimp(a - b); > > Does this mean that is(equal(a, b)) is false if and only if the > function (a, b) \mapsto a-b does not have any zeros? > > > Yes. > > As far as I know, this is how it works: > - If ratsimp(a-b) gives 0, then is(equal(a,b)) is true. > - If ratsimp(a-b) gives a non-zero constant (no variables), then > is(equal(a,b)) is false. > - Otherwise, is(equal(a,b)) is unknown. > > Of course, this is quite limited, because it only works reliably with > rational expressions due to relying on ratsimp. > > To get better results, first convert trigonometric/hyperbolic > functions to exponential form using "exponentialize" and inverse > trigonometric/hyperbolic functions to logarithmic form using "logarc". > You may also want to denest roots using "sqrtdenest". > If you are curious, these things are defined in compar.lisp, notably the function "is" is defmspec $is, which calls mevalp1 which calls alike1. Looking at alike1 one sees a lot of cases in which things are supposed equal or not. If you trace mevalp1 and alike1 you may be surprised by the number of calls generated by the command is(equal(x,y)) 0: (MAXIMA::MEVALP1 ((MAXIMA::$EQUAL) MAXIMA::$X MAXIMA::$Y)) 1: (MAXIMA::ALIKE1 MAXIMA::$X MAXIMA::$Y) 1: ALIKE1 returned NIL 1: (MAXIMA::ALIKE1 MAXIMA::$Y MAXIMA::$X) 1: ALIKE1 returned NIL .............. A lot of ratsimps in between. 1: (MAXIMA::ALIKE1 MAXIMA::$X MAXIMA::$MINF) 1: ALIKE1 returned NIL 0: MEVALP1 returned ((($EQUAL) $X $Y) (($EQUAL SIMP) $X $Y)) (%o5) unknown -- Michel Talon |