TransWikia.com

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

Mathematica Asked on January 1, 2021

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.

One Answer

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}*)

addendum

direct solution (one step)

NMinimize[{ #.# &[{782 - (880 E^(Eph/207) - Eph q1)/(-1 + E^(Eph/207)),847 - (1141 E^(Eph/207) - Eph q2)/(-1 + E^(Eph/207))}],
Element[{q1, q2}, Integers], 0 < Eph < 500}, {q1, q2, Eph}]
(*{0.00706728, {q1 -> 4, q2 -> 7, Eph -> 299.679}}*)

Correct answer by Ulrich Neumann on January 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP