Sage won't solve a symbolic equation unless it is in a specific form.

asked 2016-10-23 17:37:48 +0200

rtc gravatar image

updated 2016-10-24 03:13:26 +0200

I am trying to get sage to solve for the intersection of two Gaussian distributions. Using the solve command does not yield an answer unless I more the exponential terms to both sides. I am trying to solve for the variable y. here is the code:

eqn =1/(sqrt(2*pi*N))*exp(-y^2/(2*N)) == 1/(sqrt(2*pi*(N+P)))*exp(-y^2/(2*(N+P)))
solve(eqn, y)

this results in:

[e^(1/2*y^2/(N + P)) == sqrt(pi*N)*e^(1/2*y^2/N)/sqrt(pi*N + pi*P)]

Which doesn't solve for y.

However If before calling solve I divide both sides by one of the exponentials, the solve functions works as expected.

solve(eqn/exp(-y^2/(2*N)), y)

which yields:

[y == -sqrt(2*N*log(sqrt(pi*N + pi*P)/sqrt(pi*N)) + 2*N^2*log(sqrt(pi*N
+ pi*P)/sqrt(pi*N))/P), y == sqrt(2*N*log(sqrt(pi*N + pi*P)/sqrt(pi*N))
+ 2*N^2*log(sqrt(pi*N + pi*P)/sqrt(pi*N))/P)]

Is this a bug? or am I missing something?

edit retag flag offensive close merge delete



I don't know what's missing, but it does work with Sympy's solve function.

mforets gravatar imagemforets ( 2016-10-23 20:27:25 +0200 )edit