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

x+x does not simplify to 2x #178

Open
andrew-murdza opened this issue Jul 4, 2024 · 1 comment
Open

x+x does not simplify to 2x #178

andrew-murdza opened this issue Jul 4, 2024 · 1 comment

Comments

@andrew-murdza
Copy link

andrew-murdza commented Jul 4, 2024

Code

    import { ComputeEngine } from 'https://unpkg.com/@cortex-js/compute-engine?module';
    const ce = new ComputeEngine();
    const expr1 = ce.parse('x+x', { canonical: false });
    const simplifiedExpr1 = expr1.simplify();
    console.log(simplifiedExpr1.toString());

Actual Behavior

x+x

Expected Behavior

2x

@andrew-murdza
Copy link
Author

andrew-murdza commented Jul 4, 2024

Bugs that are harder to fix

  • \frac{0}{1-1} and \frac{1-1}{0} (\frac{0}{0} works)
  • 2(x+h)^2-2x^2 ((x+h)^2-x^2 and 2(x+h)(x+h)-x^2 work)
  • \frac{\pi+1}{\pi+1} (\frac{\pi}{\pi} works)
  • \frac{x^2}{5x^2} (\frac{5x^2}{x^2} works)
  • (-1)^{3/5} (should be -1 not i)
  • \frac{\frac{1}{x^6}}{\frac{1}{y^4}} becomes \frac{y^4}{x^6} (good) but \left(\frac{x^3}{y^2}\right)^{-2} becomes \frac{\frac{1}{x^6}}{\frac{1}{y^4}} (should be \frac{y^4}{x^6})
  • exp(x)exp(2) (e^xe^2 works)
  • \frac{x+1-1+1}{x+1} (\frac{x+1-1+1}{x} works)
  • (-2x)^{3/5}x simplifies to (i)\sqrt{2}x^{8/5} not -2^{3/5}x^{8/5} ((2x)^{3/5}x works)
  • (x^3y^2)^2 ((x^3)^2(y^2)^2 and \left(\frac{x^3}{y^2}\right)^2 work)
  • \frac{2\sqrt{3}}{\sqrt{3}} becomes 2 (good) but \frac{\sqrt{12x}}{\sqrt{3x}} becomes \frac{2\sqrt{3}}{\sqrt{3}}
  • \sqrt{12} (\frac{\sqrt{12x}}{\sqrt{x}} works)
  • \sqrt{x^2y}
  • \sqrt{x^2}, \sqrt[4]{x^4} (missing absolute value)
  • \sqrt[4]{x^6} (missing absolute value inside of root)

Logs

  • log(e^xy) (ln(e^xy) works)
  • ln(\frac{x}{y}) (log(\frac{x}{y}) works)
  • log(xy)-log(x)-log(y) (ln(xy)-ln(x)-ln(y) works)
  • log(1) (ln(1) works)
  • log(e) (ln(e) works)
  • exp(log(x))
  • exp(clog(x))
  • exp(log(x)+y)
  • exp(log(x)-y)
  • log(exp(x)) (ln(exp(x)) works)
  • \log(\sqrt{2}) and \ln(\sqrt{2}) (\log(\sqrt{x}) and \ln(\sqrt{x}) work)

Negative Signs

  • (-x)(-6)
  • -\frac{-1}{x} (\frac{-1}{-x} works)
  • (-x)^2 ((-2x)^2 works)

Properties of Exponents

  • 2xx (xx works)
  • \frac{e^x}{e}
  • \frac{e}{e^x}
  • e^xe and e^xe^1 (e^xe^2 works)
  • \left(\frac{1}{x}\right)^{-1}

Other Powers

  • 0^0
  • 0^\pi (0^{3.1} works)

Infinity

  • \infty^0
  • \infty(1-1) (\infty(0) works)
  • 1^\infty
  • -\infty(-2) and \infty(-2) (-\infty(2) and \infty(2) work)
  • \frac{\infty}{2}
  • \frac{\infty}{\infty}
  • \frac{\infty}{\infty^{-2}}

Miscellaneous

  • \frac{1}{0}

Trig

  • sec(-x) is 1/cos(x) but I believe sec(x) is nicer
  • Similarly for csc(pi+x), tan(pi/2-x), sec(pi/2-x), csc(pi/2-x)
  • cot(pi+x) is supposed to be cot(x) but set to -cot(x)
  • tan(-x)cot(x) becomes -tan(x)cot(x) and tan(x)cot(x) becomes 1 but tan(-x)cot(x) doesn't become -1
  • sin^2(x) is simplified to 1/2(1-cos(2x)) but 2sin^2(x) is not simplified at all
  • sin(x)cos(x) is simplified to sin(2x)/2 but 2sin(x)cos(x) is not simplified at all

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

No branches or pull requests

1 participant