# Plotting and manipulate with min/max inside and free parameters

I shall reformulate my question with a better attempt.

My goal is to plot a (alleged) function ee[..] which depends on another function f stationary points and derivatives which itself depend on two other parameters betta and h. I would like to plot ee[h_,..] and eventually stick the Plot[ee[h_,..] into a Manipulate[...,{betta,1,2}. For now, betta = 1.264.

(* Source of dependency on h *)
betta = 1.264;
f[x_, b_, h_] := -0.5*x^2 -
h*x + (1/b)*0.5*((1 + x)*Log[1 + x] + (1 - x)*Log[1 - x]);

(* Function to be plotted*)
ee[fmstar_, fmbar_, mstar_, mbar_, fmb_, fms_, b_, h_] :=
Exp[fmbar - fmstar]*Sqrt[(1 - mstar)/(1 - mbar)]*
Pi/(2*b*Sqrt[-fms*fmb]);

(* Define max, min and second derivative of f as func. of h, I know how f behaves and so I expect it to have one local max near zero and 2 mins on the left and on the right. I pick the left one. *)
fmax[h_] := FindMaximum[{f[x, betta, h], -1 < x < 1}, {x, 0}];
fmin[h_] := FindMinimum[{f[x, betta, h], -1 < x < 1}, {x, -0.05}]
fxx[h_] := D[f[x, betta, h], {x, 2}];

(* Try to supply the various parameter and plot *)
(Plot[{
ee[
(fmax[h])[],
(fmin[h])[],
mstar = x /. (fmax[h])[],
mbar = x /. (fmin[h])[],
fxx[h] /. x -> mbar,
fxx[h] /. x -> mstar,
betta, h]
},
{h, 0.005, -0.005},
ImageSize -> 500
]
)


but I get an empty plot here.

If you need to inspect f this manipulate is convenient.

Manipulate[Plot[f[x, b, h], {x, -1, 1}, GridLines -> {{-0.5, 0.5}}, ImageSize -> 500], {b, 0.2, 2}, {h, -1, 1}]


For my purposes

$-1<x<1, b >1$ and $h\in(\pm \frac{1}{2b}\sqrt{1-\frac{1}{b}})$

• I am still not quite sure what you trie to achive, but you should have a look at the output structure of FindMinimum. Also you have some problems with complex values which cannot be plotted. – meneken17 Oct 7 '16 at 9:09
• I know I have some points where this should not work, but it is ok for me to work in a subset of the parameter where all minima and maxima are well defined. What I want is just plotting the ee[] function as a function of h. Only, ee depends on h in a funny way through the position of minima and maxima of the f function. – Three Diag Oct 7 '16 at 11:16
• @meneken17 I have reformulated the question, hopefully is clearer now. – Three Diag Oct 7 '16 at 13:52
• Much clearer now. There are 2 mistakes: 1) in the definition of ee you use fmb did you mean 'fmm'? 2) fxx only has 1 argumetn, but you call it with 3 in the plot command. – meneken17 Oct 7 '16 at 14:04
• Right I was fixing those, but I am not sure, should I just declare it w/ three arguments fxx? – Three Diag Oct 7 '16 at 14:04