Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rational.Simplify and (2 - x)/(1 - x) vs (-2 + x)/(-1 + x) #32

Open
dharmatech opened this issue Jul 9, 2017 · 1 comment
Open

Rational.Simplify and (2 - x)/(1 - x) vs (-2 + x)/(-1 + x) #32

dharmatech opened this issue Jul 9, 2017 · 1 comment

Comments

@dharmatech
Copy link

dharmatech commented Jul 9, 2017

Here's a simple Mathematica evaluation:

image

Note that l[f[x]] // Simplify returns the same expression as m[x] // Simplify.

Here's the equivalent in Symbolics/C#:

                Expression f(Expression x) => 2 - x;
                Expression g(Expression x) => 2 / x;
                Expression h(Expression x) => f(g(x));
                Expression l(Expression x) => g(h(x));
                Expression m(Expression x) => h(h(x));
                
                {
                    var x = Expression.Symbol("x");

                    Console.WriteLine(Infix.Format(Rational.Simplify(x, l(f(x)))));
                    Console.WriteLine(Infix.Format(Rational.Simplify(x, m(x))));
                }

It outputs the following:

(2 - x)/(1 - x)
(-2 + x)/(-1 + x)

Is there a simplification routine in Symbolics which will simplify both cases to the same expression?

Thanks!

(PS: I've been experimenting a bit with Symbolics in C# and its a really nice system. Thanks Christoph!)

@dharmatech dharmatech changed the title Rational.Simplify and (2 - x)/(1 - x) vs (-2 + x)/(-1 + x) Rational.Simplify and (2 - x)/(1 - x) vs (-2 + x)/(-1 + x) Jul 9, 2017
@dharmatech dharmatech changed the title Rational.Simplify and (2 - x)/(1 - x) vs (-2 + x)/(-1 + x) Rational.Simplify and (2 - x)/(1 - x) vs (-2 + x)/(-1 + x) Jul 9, 2017
@cdrnet
Copy link
Member

cdrnet commented Jul 10, 2017

I don't think we have anything simple to use, but agree that we should normalize (on Simplify - not automatic simplification). A rule could be that the leading coefficient of the numerator shall be positive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants