1
$\begingroup$

I want to optimize a second order ODE with more than one variable:

Exp[2*alpha*x]*D[theta[x], {x, 2}] + (2*alpha + a)*Exp[2*alpha*x]*
D[theta[x], x] - b^2*(theta[x] - thetaa) - c*(theta[x] - thetaa)^2 + d*Exp[2*alpha*x] == 0;

With boundary conditions

theta[1] == 1, theta'[0] == 0.20

Here a, b, c, d,thetaa are parameters and alpha=-0.5. I want to maximize theta[x] for different parameters I have no idea how to do it please help me

$\endgroup$
4
  • $\begingroup$ C and D are built-in symbols and should not be used as parameters. In general, all user-defined symbols should begin with a lower case letter to avoid naming conflicts with built-in symbols. If {a, b, c, d} are the parameters, what are the values for the constants {alpha, thetaa}? $\endgroup$ – Bob Hanlon Apr 18 at 18:20
  • $\begingroup$ @Bob Hanlon thanks for the correction, here 'thetaa' is also a parameter and alpha=-0.5 $\endgroup$ – ZDN Apr 18 at 19:12
  • $\begingroup$ Recommend placing an NDSolve of the DE in a Manipulate with sliders for all constants and studying how the solution varies as the constants are varied. $\endgroup$ – Dominic Apr 18 at 19:24
  • $\begingroup$ In what sense do you wish to maximize theta[x]? Also, are the parameters all real? Are there bounds on the values of the parameters? $\endgroup$ – bbgodfrey Apr 19 at 22:51
2
$\begingroup$

With the constraints provide in the OP's comment below, theta[x], maximized over {x, a, b, c, d, thetaa}, can be obtained as follows.

s = ParametricNDSolveValue[{(Exp[2*alpha*x]*D[theta[x], {x, 2}] + 
    (2*alpha + a)*Exp[2*alpha*x]*D[theta[x], x] - b^2*(theta[x] - thetaa) - 
    c*(theta[x] - thetaa)^2 + d*Exp[2*alpha*x] == 0) /. alpha -> -1/2, 
    theta[1] == 1, theta'[0] == 1/5}, theta, x, {a, b, c, d, thetaa}];

NMaximize[{s[a, b, c, d, thetaa][x], 0 < x < 1, 0 < a < 1, 0 < b < 1, 
    0 < c < 1, 0 < d < 1, 0 < thetaa < 1}, {x, a, b, c, d, thetaa}]
s[a, b, c, d, thetaa] /. %[[2]];
Plot[%[x], {x, 0, 1}, PlotRange -> All, ImageSize -> Large, 
    AxesLabel -> {x, theta}, LabelStyle -> {15, Bold, Black}]

(* {1.39758, {x -> 0.226436, a -> 0.0000966814, b -> 0.00719679, 
              c -> 0.0000613951, d -> 1., thetaa -> 0.000312072}} *)

enter image description here

Incidentally, increasing WorkingPrecision from the default machine precision to 30 changes the maximum of theta by about 0.2%, and the values of the parameters at that maximum by modest amounts:

(* {1.39474388212895176033538369038, 
   {x -> 0.218410943433777148986614046571, a -> 0.0108420208584436753782203010895, 
    b -> 0.0153768430340760880593013278062, c -> 0.00248978147185524573445645380282, 
    d -> 0.998856326052919487344087798466, thetaa -> 0.663626080541074452717478080028}} *)

Note that the result is insensitive to thetaa, because it is multiplied in the ODE by b or c, which are small.

$\endgroup$
2
  • $\begingroup$ #bbgodfrey thanks for your effort my problem is to maximize and minimize 'theta' where the range of values of the parameters is '[0,1]' $\endgroup$ – ZDN Apr 20 at 19:36
  • $\begingroup$ @ZDN With this additional information, the answer can be obtained with less running time, on my computer about 3 minutes. Please see above. $\endgroup$ – bbgodfrey Apr 21 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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