Solve within assumptions

asked 2021-12-04 18:23:16 +0200

I am trying to get the solutions of an inequality which has several variables. These variables move within intervals I have defined with assume. When I call solve the assumptions seem to be ignored. Below is my code:

variables = var('n_s','alpha','n_p','m','omega_p')
for variable in variables:
    assume(variable, 'real')
for refractive_index in {n_s, n_p}:
    assume(refractive_index > 1)
assume(0 < alpha, alpha < 1)
assume(omega_p > 0)
assume(m > 0)
assume(m < omega_p)

Xi = ((1-alpha)**2-(m/omega_p)**2)**(1/2)

expression = (n_s**2*alpha**2 + n_p**2 - Xi)/(2*n_p*n_s*alpha)

solve([1>expression],[n_p])

and this produces the following output

[[0 < n_p,
  0 < n_s,
  0 < alpha,
  -alpha^2*n_s^2 + 2*alpha*n_p*n_s - n_p^2 + sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0],
 [n_p < 0,
  0 < n_s,
  alpha < 0,
  -alpha^2*n_s^2 + 2*alpha*n_p*n_s - n_p^2 + sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0],
 [0 < n_p,
  n_s < 0,
  alpha < 0,
  -alpha^2*n_s^2 + 2*alpha*n_p*n_s - n_p^2 + sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0],
 [n_p < 0,
  n_s < 0,
  0 < alpha,
  -alpha^2*n_s^2 + 2*alpha*n_p*n_s - n_p^2 + sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0],
 [0 < n_p,
  0 < n_s,
  alpha < 0,
  alpha^2*n_s^2 - 2*alpha*n_p*n_s + n_p^2 - sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0],
 [n_p < 0,
  0 < n_s,
  0 < alpha,
  alpha^2*n_s^2 - 2*alpha*n_p*n_s + n_p^2 - sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0],
 [0 < n_p,
  n_s < 0,
  0 < alpha,
  alpha^2*n_s^2 - 2*alpha*n_p*n_s + n_p^2 - sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0],
 [n_p < 0,
  n_s < 0,
  alpha < 0,
  alpha^2*n_s^2 - 2*alpha*n_p*n_s + n_p^2 - sqrt((alpha^2 - 2*alpha + 1)*omega_p^2 - m^2)/omega_p > 0]]

This is clearly ignoring the assumptions, for example the second solution has alpha < 0. Is it possible to somehow check for my assumptions automatically?

edit retag flag offensive close merge delete

Comments

1

You may have noticed that none of the solutions given is an explicit solution for n_p. In fact, your inequation can be, at best, tirned a=in a biquartic inequality.

It turns out that no Sage-reachable algorithm can give explicit solution to such Inequalities. Mathematica manages to solve it, but expresses the solution as an intractable set of conditions, abundantly using the roots of "pure function" polynomial roots, which turns out it cannot simplify...

OTOH, it is probably faster to write a function checking the conditions, searching the roots of the quartic (using QQ[] polynomials roots) and checking the signs...

I doubt that any explicit answer is useable...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-12-06 22:50:28 +0200 )edit