Skip to main content
Best answer by Werner_E

Mike Armstrong wrote:

Nice Werner, I have to say either the root or Maximize is the way to got though.

Thanks, and yes, I agree. I just added the vector method with max() because this is what sameer obviously was trying to do but failed, because he used a range variable instead of a vector. N=250 as I had set it is too small - this value has at least to be doubled. Furthermore getting the corresponding x-value using match() is not quite "natural".

While I have a slight favor for the derivative way I guess your solve block may be more versatile and probably more robust when we come across more "ill-natured" functions.

2 replies

1-Visitor
April 8, 2014
25-Diamond I
April 8, 2014

See attached two ways to get what you want.

The first follows the way you tried (don't misuse ranges, use vectors) and the second is an analytical approach using the derivative.

1-Visitor
April 8, 2014

Nice Werner, I have to say either the root or Maximize is the way to got though.

Werner_E25-Diamond IAnswer
25-Diamond I
April 8, 2014

Mike Armstrong wrote:

Nice Werner, I have to say either the root or Maximize is the way to got though.

Thanks, and yes, I agree. I just added the vector method with max() because this is what sameer obviously was trying to do but failed, because he used a range variable instead of a vector. N=250 as I had set it is too small - this value has at least to be doubled. Furthermore getting the corresponding x-value using match() is not quite "natural".

While I have a slight favor for the derivative way I guess your solve block may be more versatile and probably more robust when we come across more "ill-natured" functions.