1
$\begingroup$

I am trying to use Solve in Mathematica to get the $x$ and $U$ parameters here but the solution doesn't come out. The program continues running forever. Any ideas? Wolfram Alpha solves the problem easily.

Program: Variables first and then I use Solve.

P = 0.5;
theta = 74*Pi/180;
muL1 = -30;
muL2 = -200;
eps = -800;
time = 2.418884326505*^-17;
Hartree = 27211.4;
h = (1*^9)*2*time*Hartree*Pi;
NSolve[x*P*Cos[theta]*Log[(muL1 - eps - U)^2/(muL1 - eps)^2] == 2*Pi*h*(15.883 - 14.9265) && 
  x*P*Cos[theta]*Log[(muL2 - eps - U)^2/(muL2 - eps)^2] == 2*Pi*h*(15.883 - 14.6216), {x, U}]
$\endgroup$
3
  • 4
    $\begingroup$ Use NSolve[{eq1,eq2},{x,U},Reals] then it solves it. !Mathematica graphics Wolfram Alpha solves the problem easily Wolfram Alpha uses A.I. so may be it tried this on its own. Hard to know. $\endgroup$
    – Nasser
    Dec 5, 2023 at 5:38
  • $\begingroup$ Thank you! I did not know Wolfram alpha uses A.I.... $\endgroup$ Dec 5, 2023 at 9:22
  • $\begingroup$ @Nasser To be clear, W|A is built on GOFAI. $\endgroup$
    – Greg Hurst
    Dec 5, 2023 at 13:53

1 Answer 1

4
$\begingroup$

One approach is by @Nasser in the comments. Another one is to use Rationalize

Coefficients

P = 0.5;
theta = 74*Pi/180;
muL1 = -30;
muL2 = -200;
eps = -800;
time = 2.418884326505*^-17;
Hartree = 27211.4;
h = (1*^9)*2*time*Hartree*Pi;

Equations

eq1 = x*P*Cos[theta]*Log[(muL1 - eps - U)^2/(muL1 - eps)^2] == 
    2*Pi*h*(15.883 - 14.9265) // Rationalize[#, 0] &;
eq2 = x*P*Cos[theta]*Log[(muL2 - eps - U)^2/(muL2 - eps)^2] == 
    2*Pi*h*(15.883 - 14.6216) // Rationalize[#, 0] &;

Solve instead of NSolve

Solve[{eq1, eq2}, {x, U}, Reals]

you get your solutions like that as well.

Note that using Reals is also pivotal here.

$\endgroup$
1
  • 1
    $\begingroup$ Thank you so much! $\endgroup$ Dec 5, 2023 at 9:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.