can't solve equation

48 views
Skip to first unread message

nicolas playe

unread,
Dec 4, 2022, 6:26:26 AM12/4/22
to sympy
Hello all,

I have a problem from trying to solve an equation

```
import sympy as sp
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,u,v,w,x,y,z = sp.symbols(' a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,u,v,w,x,y,z',non_zero=True, real=True)

expr1 = a*(g + (g - 1)*exp(a*e)*exp(b*f))*(exp(c*e)*exp(d*f) + 1) + c*(h + (h - 1)*exp(c*e)*exp(d*f))*(exp(a*e)*exp(b*f) + 1)
expr2 =
b*(g + (g - 1)*exp(a*e)*exp(b*f))*(exp(c*e)*exp(d*f) + 1) + d*(h + (h - 1)*exp(c*e)*exp(d*f))*(exp(a*e)*exp(b*f) + 1)

solve([expr1,expr2],[e,f])
```

I know there is a solution because

```
import sympy as sp
a,b,c,d = sp.symbols(' a,b,c,d',non_zero=True, real=True)
g,h = sp.symbols(' g,h',,real=True)
expr1 = a*g +c*h
expr2 = b*g +d*h
solve([expr1,expr2],[g,h])
```
gives {h:0,g:0}

Do you have any tips ?

Thanks a lot

Chris Smith

unread,
Dec 5, 2022, 11:35:55 AM12/5/22
to sympy
Although I am not sure why `solve` doesn't do so automatically, you can find the solutions for `e` and `f` by sending only the pertinent expressions to `solve`:

solve([ (g + (g - 1)*exp(a*e)*exp(b*f))*(exp(c*e)*exp(d*f) + 1) , (h + (h - 1)*exp(c*e)*exp(d*f))*(exp(a*e)*exp(b*f) + 1)], e, f)
[(log(-g*exp(-b*(a*log(-h/(h - 1)) - c*log(-g/(g - 1)))/(a*d - b*c))/(g - 1))/a, (a*log(-h/(h - 1)) - c*log(-g/(g - 1)))/(a*d - b*c)), (log(-exp(-I*pi*d*(a - c)/(a*d - b*c)))/c, I*pi*(a - c)/(a*d - b*c))]
Reply all
Reply to author
Forward
0 new messages