0

I mean to solve a symbolic equation via sympy.solve. It was taking surprisingly long, so I tried a few variations, until I found one "at the boundary" between what works and what doesn't. Code below...

import sympy as sp
import numpy as np
x, y, z = sp.symbols('x, y, z')

# Option 1: works
expr3 = 0.6*x**(3/2)*y**(7/5)*z**2.2
expr4 = 0.9*x**0.5*y**(4/5)*z**1.2
s3 = sp.solve(expr3 - expr4, x)
print(s3)

# Option 2: does not work
expr3 = 0.6*x**(1/9)*y**(7/5)*z**2.2
expr4 = 0.9*x**0.5*y**(4/5)*z**1.2
s3 = sp.solve(expr3 - expr4, x)
print(s3)

... produces this output

[0.0, 1.5/(y**(3/5)*z)]

from option 1, and then it is stuck at option 2. I have to manually interrupt calculation. I don't understand why the difference, both seem to have roughly the same requirements to solve, and they can be worked out by hand.

Any hints?

  • it takes more time because of the math complexity of the fraction `1/9` compared to the rational number `3/2` – RAI Apr 06 '23 at 22:25

0 Answers0