(* Finding the minimum of the function W under the energy constraint H = E *) (* Printing input parameters and checking their validity *) (* Input: x0, y0 - displacements omx, omy - frequencies h30,h21,h12,h03 - cubic anharmonicity for H h40,h31,h22,h13,h04 - 4th degree anharmonicity for H w30,w21,w12,w03 - cubic anharmonicity for W w40,w31,w22,w13,w04 - 4th degree anharmonicity for W Example of input line: {x0, y0, omx, omy} = {0.1, 0.2, 0.8, 1.2}; {h30,h21,h12,h03}={-0.1,-0.3,0.2,0}; {h40,h31,h22,h13,h04}={0,0,0,0,0}; {w30,w21,w12,w03}={0.05,0.05,0.05,-0.05}; {w40,w31,w22,w13,w04}={0,0,0,0,0}; *) (* Load a package for formatted printing of numbers *) <"]; Print["

"]; Print[""]; Print["
Frequencies      Displacements
wxwyx0y0
  ",printF[omx,10,5],"    ",printF[omy,10,5],"    ",printF[x0,10,5],"    ",printF[y0,10,5],"  
"]; If[!(NumberQ[omx]&&NumberQ[omy]&&omx>0&&omy>0), Print["
Frequencies must be positive numbers!\n"]; fails=True]; If[!(NumberQ[x0]&&NumberQ[y0]), Print["
Displacements must be numbers!\n"]; fails=True]; Print["

"]; Print[""]; Print[""]; Print[""]; Print[""]; Print[""]; Print["
Cubic anharmonicity of H      Quartic anharmonicity of H
h30h21h12h03h40h31h22h13h04
  ",printF[h30,10,5],"    ",printF[h21,10,5],"    ",printF[h12,10,5],"    ",printF[h03,10,5],"    ",printF[h40,10,5],"    ",printF[h31,10,5],"    ",printF[h22,10,5],"    ",printF[h13,10,5],"    ",printF[h04,10,5],"  
Cubic anharmonicity of WQuartic anharmonicity of W
w30w21w12w03w40w31w22w13w04
  ",printF[w30,10,5],"    ",printF[w21,10,5],"    ",printF[w12,10,5],"    ",printF[w03,10,5],"    ",printF[w40,10,5],"    ",printF[w31,10,5],"    ",printF[w22,10,5],"    ",printF[w13,10,5],"    ",printF[w04,10,5],"  
"]; If[!(NumberQ[h30]&&NumberQ[h21]&&NumberQ[h12]&&NumberQ[h03]), Print["
Parameters of cubic anharmonicity for H must be numbers!\n"]; fails=True]; If[!(NumberQ[h30]&&NumberQ[h21]&&NumberQ[h12]&&NumberQ[h03]), Print["
Parameters of quartic anharmonicity for H must be numbers!\n"]; fails=True]; If[!(NumberQ[w30]&&NumberQ[w21]&&NumberQ[w12]&&NumberQ[w03]), Print["
Parameters of cubic anharmonicity for W must be numbers!\n"]; fails=True]; If[!(NumberQ[w30]&&NumberQ[w21]&&NumberQ[w12]&&NumberQ[w03]), Print["
Parameters of quartic anharmonicity for W must be numbers!\n"]; fails=True]; If[fails, Print["

Computations terminated because input parameters are illegitimate.


"]; Exit[] ]; (* Testing ends *) If[!(omx<100&&omy<100), Print["
Warning: one of frequencies is too large. Results may be unpredictable."]; ]; If[!(omx>0.005&&omy>0.005), Print["
Warning: one of frequencies is too small. Results may be unpredictable."]; ]; If[!(Abs[x0]<100&&Abs[y0]<100), Print["
Warning: one of displacements is too large. Results may be unpredictable."]; ]; {h3max,h4max,w3max,w4max}={10,10,10,10}; If[!(Abs[h30]Warning: one of parameters of cubic anharmonicity for H is too large. Results may be unpredictable."]; ]; If[!(Abs[h40]Warning: one of parameters of quartic anharmonicity for H is too large. Results may be unpredictable."]; ]; If[!(Abs[w30]Warning: one of parameters of cubic anharmonicity for W is too large. Results may be unpredictable."]; ]; If[!(Abs[w40]Warning: one of parameters of quartic anharmonicity for W is too large. Results may be unpredictable."]; ]; ndig=128; {x0, y0, omx, omy}=SetPrecision[{x0, y0, omx, omy},ndig]; {h30,h21,h12,h03}=SetPrecision[{h30,h21,h12,h03},ndig]; {h40,h31,h22,h13,h04}=SetPrecision[{h40,h31,h22,h13,h04},ndig]; {w30,w21,w12,w03}=SetPrecision[{w30,w21,w12,w03},ndig]; {w40,w31,w22,w13,w04}=SetPrecision[{w40,w31,w22,w13,w04},ndig]; Print[""];