# Finding the optimum value of a variable subject to a nonlinear constraint

I want to know whether or not the objective function I have defined is correct. The nonlinear constraint has to be satisfied while ζ varies from 0 < ζ <= 1/2.

This is the first time I am trying to do optimization with Mathematica. It would be helpful if you would direct me to any documentation that can help me.

ClearAll
f[β_] := β;
(*Objective function*)
a = 1/(2*β^3);
eq =
a*(((Sin[β*(1 - ζ)]*Sin[β*ζ])/Sin[β]) - ((Sinh[β*(1 - ζ)]*Sinh[β*ζ])/Sinh[β]));
eq1 = (10^12*eq) + 1;
(*This is the constraint equation*)
NMaximize[f[β_], eq1 == 0]

• Have a look at NMaximize. – b.gates.you.know.what Dec 27 '17 at 8:17
• ClearAll f[[Beta]_] := [Beta];(Objective function *) a = 1/(2*[Beta]^3); eq = a*(((Sin[[Beta]*(1 - [Zeta])]*Sin[[Beta]*[Zeta]])/ Sin[[Beta]]) - (( Sinh[[Beta]*(1 - [Zeta])]*Sinh[[Beta]*[Zeta]])/ Sinh[[Beta]])); eq1 = (10^12*eq) + 1;(*This is the constraint equation) NMaximize[f[[Beta]_], eq1 == 0] – Vijay Kumar S Dec 27 '17 at 9:07
• But how to define variation of zeta from 0 <zeta<=0.5 – Vijay Kumar S Dec 27 '17 at 9:07
• If you add copyable code to your question, rather than an image of an equation, more people might be willing to help out. – aardvark2012 Dec 27 '17 at 10:04
• 1) ClearAll is not a Mathematica command and therefore is ignored. 2) Why does your code have a factor of 10^12 that does not appear in the image you originally posted? – m_goldberg Dec 27 '17 at 14:38

f[β_] = β; (*Objective function*)
a = 1/(2*β^3);
eq = a*(((Sin[β*(1 - ζ)]*Sin[β*ζ])/Sin[β]) - ((Sinh[β*(1 - ζ)]*Sinh[β*ζ])/Sinh[β]));
eq1 = (10^12*eq) + 1; (*This is the constraint equation*)


Use the proper syntax as shown in the documentation for NMaximize: "NMaximize[{f, cons}, {x, y,…}] maximizes f numerically subject to the constraints cons."

NMaximize[{f[β], eq1 == 0, 0 < ζ <= 1/2}, {β, ζ},
WorkingPrecision -> 50] // N

(* {3.92685, {β -> 3.92685, ζ -> 0.00015584}} *)


EDIT: "For nonlinear functions, NMaximize may sometimes find only a local maximum."

NMaximize[{f[β], eq1 == 0,
0 < ζ <= 1/2}, {{β, 3, 10}, ζ}, WorkingPrecision -> 50] //
N

(* {7.07025, {β -> 7.07025, ζ -> 0.000364042}} *)