Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a problem with NMaximize which is best depicted by the following figure. The result indicates, that the solution mathematica finds seems to be smooth except a few outliers. How can I get rid of them? I tried to change the method NMaximizes uses, e.g. SimulatedAnnealing etc. but it did not improve. Moreover, changing WorkingPrecision was also not a viable option, too (increase up to 400). Any kind of help is appreciated!

Solution of NMaximze

The code is as follows:

RS[a_, p_, v_, t1_, T1_, x0_, i1_, i2_, t2_]:=Module[{z, T0, dT0, b, n1, d, i},  
b := 1/2 - (a/v^2) + Sqrt[(1/2 - a/v^2)^2 + (2*p)/v^2];   
n1[w_] := PDF[NormalDistribution[0, 1], w];  
z[a1_] := a1/(p-a);  
i[a4_] := i1 + a4*i2;  
T0[a2_, a3_] := T1 + (a2)^t1*(a3)^t2;  
dT0[a2_, a3_] := t1*(a2)^(t1-1)*(a3)^t2;  
d[a2_, a1_, a3_, a5_] := (Log[T0[a2, a3] - Log[a5]] + (a - 1/2*(v)^2)*a3)*(v*Sqrt[a3])^(-1);  
NMaximize[{((T0[a2, a3]-1)*z[a1]-a2-i[a4])*(x0/a1)^b, 
a4*Exp[-p*a3]*n1[d[a2, a1, a3, a5]]*1/(v*Sqrt[a3])*dT0[a2, a3]==1 
&& a1 >= 0 && a2 >= 0 && a3 >= 0 && a4 >= 0 && a5 >= 1}, {a1, a2, a3, a4, a5}] 

while the graph is generated using, e.g.:

Plot[RS[0.03, 0.05, j, 0.1, 1.1, 1, 30, 0.1, 0.025][[2, 1, 2]], {j, 0.05, 0.25}]
share|improve this question
It will be easier if You provide input data instead of plot image. –  Wojciech Jan 28 '14 at 15:16
Luke, without code to reproduce the problem this question will most likely be closed - so please add that. –  Yves Klett Jan 28 '14 at 17:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.