I asked this question Mark Minimum Value in DensityPlot. Another question has come up, or better said, a task: Find the minimum of a function.

I haven't been able to write the needed code for that, because I want to find the minimum of the function ueislexpl[epsilon, h, n1, n2] with respect to n1 and n2. But ueislexpl calls the function eislminx2[epsilon_?NumericQ, n2_?NumericQ], which needs a value for n2. For tests one may use epsilon = 0.1. Is there a way of finding the minimum of ueislexpl[epsilon, h, n1, n2] with respect to n1 and n2?

eislexpl[gamma_,epsilon_, n2_, x_] :=  
  28 (epsilon)^2 - 1 + ((-2 Log[E^(1/2) x])/x^2 + (27/10(gamma - epsilon))/x + 
    (10 epsilon^2 n2^(3/2))/x^(3/2))

eislminx2[gamma_,epsilon_?NumericQ, n2_?NumericQ] := 
  minx = FindArgMin[{eislexpl[gamma,epsilon, n2, x], 0 < x}, x];
  eislexpl[gamma,epsilon, n2, minx]

ueislexpl[gamma_,epsilon_, h_, n1_, n2_] := 
  n1 (40  epsilon^2 - 1) + (1 -127/100 ) (1 + (n1 - 1) HeavisideTheta[1 - n1] - 
  (-1 + Exp[-(n1 - 1)]) HeavisideTheta[n1 - 1]) + n2  eislminx2[gamma,epsilon, n2] + 
  (h - n1 - n2) (28  epsilon^2 - 1)

The function ueislexpl[gamma,epsilon, h, n1, n2] describes the energy of a specific type of crystal morphology. It is used to predict specific growth modes. h is the total amount of deposited material h=n1 + n2 + n3. There are 3 different types of structures that can appear. A so called wetting layer, 3d-structures of kind 1 (3ds1) and 3d-structures of kind 2 (3ds2). n1is the amount of material comprising the wetting layer, n2is the amount of material comprising 3ds1, and whats left of h, h-n1-n2=n3 is the material comprising 3ds2. In my simulations i usually use values of h within [0,8], meaning that values for n1 and n2 are too within [0,8]. I saw, that i oversimplified my functions, so i edited them, now there is one variable more, gamma, the surface energy per unit area, epsilon is the strain. My goal is to plot 2 different phase diagrams, one that shows the energy as a function of h and epsilon and the second one showing the energy as a function of hand gamma. The function eislminx2[gamma,epsilon, n2] determines the energetic minimum for a given set of gamma,epsilon and n2 - so i can't give constant values for them, they need to be variables. And the function that determines the energetic minimum of the system (minimum of ueislexpl[gamma,epsilon, h, n1, n2]) needs to be able to deal with that, is that possible? Determining the formal minimum of ueislexpl[gamma,epsilon, h, n1, n2], leaving some variables blank for the moment, as if i took the derivative of y=a x^2 + x, dy/dx=2 a x + 1=0 - even though i dont know the value of a i can formally take the derivative and later on plug in values for a and determine the minimum. Or is there another way?


As defined, eislminx2 returns a list rather than a value. I modified its definition to use First (only?) value. I rationalized your equations so that they do not limit the precision of the calculations. In addition to specifying a value for epsilon, h needs a value. Do you know any constraints on values of n1 or n2 (region of interest)?

eislexpl[epsilon_, n2_, x_] :=
 28 (epsilon)^2 - 1 + ((-2 Log[E^(1/2) x])/x^2 +
    (27 (3/10 - epsilon)/10)/x + (10 epsilon^2 n2^(3/2))/x^(3/2))

  n2_?NumericQ] :=
 (minx = 
   FindArgMin[{eislexpl[epsilon, n2, x], 0 < x}, x][[1]];
  eislexpl[epsilon, n2, minx])

ueislexpl[epsilon_, h_, n1_, n2_] :=
 n1 (40 epsilon^2 - 1) +
  (1 - 127/100) (1 + (n1 - 1) HeavisideTheta[1 - n1] -
     (-1 + Exp[-(n1 - 1)]) HeavisideTheta[n1 - 1]) +
  n2 eislminx2[epsilon, n2] + (h - n1 - n2) (28 epsilon^2 - 1)

Use Table of values to get initial search values for n1 and n2.

    With[{epsilon = 0.1, h = 1},
       {n1, n2, ueislexpl[epsilon, h, n1, n2]}, {n1, -5., 5.}, {n2, -5., 
    {_, _, _Real}],
   Last][[1]] // Quiet

{2., 2., -1.51618}

With[{epsilon = 1/10, h = 1},
  ueislexpl[epsilon, h, n1, n2],
  {n1, 2}, {n2, 2}, WorkingPrecision -> 25]]

{-1.519790404331848865382426, {n1 -> 1.811155287630071934805285, n2 -> 2.106604515458455023281628}}

Note that higher working precision is required hence need to rationalize factors in your equations.

  • $\begingroup$ Thanks for your answere, Bob Hanlon. I edited my Question, i hope your questions are answered. Could you please comment on why i should use tables of values to get initial search values for n1 and n2? When i plot the phase diagrams n1 and n2 vary from 0-8. I'm not sure that i understand your proposal. How do you see that "higher working precision is required" ? $\endgroup$ Aug 9 '14 at 16:16
  • $\begingroup$ @11drsnuggles11 - functions can have many local minima (particularly if region is not limited); starting search near minimum will help converge on the desired solution. If you don't use higher WP in original problem you receive warning: "The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances." 25 was lowest WP to eliminate warning. Whenever possible, add bounds (region) to aid in search. $\endgroup$
    – Bob Hanlon
    Aug 9 '14 at 16:48

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.