|Ruud H.G. van Tol on Tue, 03 Jan 2023 10:44:58 +0100|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: Question on using eval...|
On 2023-01-02 23:42, firstname.lastname@example.org wrote:
On 1/2/2023 4:09 PM, Bill Allombert wrote:On Mon, Jan 02, 2023 at 03:31:00PM -0600, email@example.com wrote:Hello,I've run into an issue using the "eval" function. I'm trying to check two expressions for symbolic equality. But, I run into a problem when I use the exponent operator. Is this a valid use for the eval function? Is there another way to check if two expressions are equal? Thank you for any helpyou can provide!Dear David, The eval function does not work like in Maple. Writing ? eval("something") has the same effect as ? something. so it is not useful with string constants.gp > a %1 = a gp > b %2 = b gp > c %3 = c gp > eval("(a/b)+c == (a-b)+c")gp> (a/b)+c == (a-b)+c would do the same thing faster.I did see that I could just write the expression on the gp command line, but unfortunately, I am using code to generate these expressions and so I only have them available as strings.Do you know of a way to compare two expressions in pari/gp (checking for equality) when each expression is stored in a string? Hopefully a way that includes the exponent operator?
The "symbolic equality" also needs to be defined first. ? f(a,b,c) = (a / b) + c; ? g(a,b,c) = a / b + c; ? h(a,b,c) = c + a / b; ? print([f == g, f == h, g == h, g == f, f === g]); [1, 0, 0, 1, 1] -- Ruud