Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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?

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

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?