# Find the best pair of whole numbers that gives a real solution for a system of equations

I have a system of equations given by:

Clear[Eph, q1, q2];
Eeff1 = 782; Eeff2 = 847;
Ereal1 = 880; Ereal2 = 1141;
eq1 = Eeff1 == (Exp[Eph/207]*Ereal1 - q1*Eph)/(Exp[Eph/207] - 1);
eq2 = Eeff2 == (Exp[Eph/207]*Ereal2 - q2*Eph)/(Exp[Eph/207] - 1);


How can I find a pair of (q1,q2) whole numbers that gives the best real solution for the system {eq1,eq2}? By plotting the equations, I found that q1=4 and q2=7 seem to work so that Eph≈300.

• Ephisn't defined? Aug 26, 2020 at 10:19
• Not in principle. But it's a positive number larger than 207. Once the pair of (q1,q2) is determined, it should be the same Eph for both equations. Aug 26, 2020 at 10:23
• What specifically are the equations to solve? Aug 26, 2020 at 11:46

First solve the equations for q1[Eph],q2[Eph] and define the parametric curve

Q[Eph_] := {q1, q2} /. Solve[{eq1, eq2}, {q1, q2}][[1]]



NMinimize solves for the optimal parameters q1,q2(nearly integer)

opt=NMinimize[{Norm[Round[Q[Eph]] - Q[Eph]], 100 < Eph < 400}, Eph]
(*{0.000912665, {Eph -> 299.679}}*)

Q[Eph /.opt[[2]]]
(*{4.0004, 6.99918}*)


NMinimize[{ #.# &[{782 - (880 E^(Eph/207) - Eph q1)/(-1 + E^(Eph/207)),847 - (1141 E^(Eph/207) - Eph q2)/(-1 + E^(Eph/207))}],