What is the approach I can take when I need to find the value of x from an equation which is in the form of eqn=y*(x*a)*0.3014? Solve() is taking over a minute and Solveset is raising a ConditionSet. I don't think nsolve works as well.
On Monday, 17 April 2017 02:40:32 UTC+5:30, Aaron Meurer wrote: > > solve() has issues with equations like these currently because it > wants to treat them as polynomials. But the degree of the polynomial > is related to the numerator and denominator of the exponent: > > In [14]: Rational(0.45) > Out[14]: > 8106479329266893 > ───────────────── > 18014398509481984 > > If you use rational numbers, and solve for a manually in the second > equation, you get a degree 20 polynomial (after multiplying by b**20): > > In [24]: expr = a * b**Rational(45, 100) - a + 1 - 4.5 * b > > In [25]: expr.subs(solve([0.45 * a * b**(Rational(45, 100) - 1) - 4.5], > [a])) > Out[25]: > 11 > ── > 20 > - 10.0⋅b + 5.5⋅b + 1 > > I was able to get solutions with solve(expr.subs(solve([0.45 * a * > b**(Rational(45, 100) - 1) - 4.5], [a]))*b**20, rational=True), but > none are expressible exactly. > > I recommend trying nsolve, which can give you numeric solutions to > this system, and quite fast: > > In [30]: nsolve([a * b**0.45 - a + 1 - 4.5 * b, 0.45 * a * b**(0.45 - > 1) - 4.5], [a, b], [1, 1]) > Out[30]: > ⎡ 1.09929682680944 ⎤ > ⎢ ⎥ > ⎣0.0180539685108078⎦ > > Aaron Meurer > > On Sun, Apr 16, 2017 at 4:51 PM, pdknsk <[email protected] <javascript:>> > wrote: > > I've been trying to get the solution for the following equations. > > > > 4.5*b = a*b^0.45-a+1 > > 4.5 = 0.45*a*b^(0.45-1) > > > > I think this should do it. > > > > ab = sympy.solve([a * b**0.45 - a + 1 - 4.5 * b, 0.45 * a * b**(0.45 - > 1) - > > 4.5]) > > > > After waiting 100 minutes I cancelled it. It's not clear to me if it > will > > eventually find a solution, or if it has reached a broken internal state > > which will make it compute indefinitely. > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at https://groups.google.com/group/sympy. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/sympy/857b5528-22eb-496c-b0a1-5e449c0c2075%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/68667f9d-0b8a-4dda-842e-367c6b55b47e%40googlegroups.com.
