# FindMinimum giving erroneous value?

**URL:** <https://community.wolfram.com/t/findminimum-giving-erroneous-value/18361>\
**Category:** Questions\
**Tags:** calculus\
**Created:** [June 29, 2021, 10:35pm UTC](https://community.wolfram.com/t/findminimum-giving-erroneous-value/18361 "2021-06-29T22:35:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ablongcamp](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@ablongcamp](https://community.wolfram.com/u/ablongcamp)\
**Post date:** [June 29, 2021, 10:35pm UTC](https://community.wolfram.com/t/findminimum-giving-erroneous-value/18361/1 "2021-06-29T22:35:45Z")

</div>

Hello everyone,

I have an ODE (y3) for which I am trying to find the minimum that occurs after the first maximum. To do this, I am hoping to use FindMaximum to find the time (T) at which the first maximum occurs and subsequently use FindMinimum to find the minimum that occurs after time T. When I try this, however, I receive a value that is far from the true value (as indicated by a plot of the ODE).

Is there a way to fix this problem or should I resort to another method of finding the minimum–one not involving the function FindMinimum? I have seen other methods recommended on this forum but I am hoping to achieve this goal with FindMinimum if possible.

If FindMinimum is not the optimal approach to this problem, what is?

Any help or recommendations would be greatly appreciated!

Alex

[test1.nb](https://community.wolfram.com/uploads/short-url/kAdEAhmVnVGarP9llU4YMpvBfKG.nb) (59.2 KB)

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [June 30, 2021, 2:06am UTC](https://community.wolfram.com/t/findminimum-giving-erroneous-value/18361/2 "2021-06-30T02:06:44Z")

</div>

Hi Alex,

From the documentation

> FindMinimum[f,{x,Subscript[x, 0],Subscript[x, 1]}] searches for a  
> local minimum in f using Subscript[x, 0] and Subscript[x, 1] as the  
> first two values of x, avoiding the use of derivatives.

Not sure why you are using `{t, tMax, K*100}`, `K*100 = 100,000` which is way too large. This gives the right answer

```
FindMinimum[y3, {t, tMax + 0.1}]
(* {17.9542, {t -> 56.8603}} *)

```

or

```
FindMinimum[y3, {t, tMax, tMax + 1}]

```

If the solution has high frequency oscillations it is possible that `FindMinimum` can miss the next minimum depending on the `x0, x1` values used.

---

<div class="post-metadata">

**Author:** ![ablongcamp](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@ablongcamp](https://community.wolfram.com/u/ablongcamp)\
**Post date:** [June 30, 2021, 2:17am UTC](https://community.wolfram.com/t/findminimum-giving-erroneous-value/18361/3 "2021-06-30T02:17:48Z")

</div>

Ah I see now; I misread the documentation for FindMinimum. I thought x\_0 and x\_1 comprised the interval over which we wanted to find a minimum. Thank you for the help!

Alex

---

<div class="post-metadata">

**Author:** ![ablongcamp](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@ablongcamp](https://community.wolfram.com/u/ablongcamp)\
**Post date:** [June 30, 2021, 2:28am UTC](https://community.wolfram.com/t/findminimum-giving-erroneous-value/18361/4 "2021-06-30T02:28:40Z")

</div>

Your method works really nicely for values of g that are sufficiently large, but, for low values of g, I only acquire the minimum if I use {t, tMax, K\*100} for NDSolve (as seen in the attached notebook). Is there a way around this problem? I am hoping to eventually plot YMin[g] function, so if I can get it to run for any value of g that would be ideal. Any suggestions would be greatly appreciated!

Alex

[test2.nb](https://community.wolfram.com/uploads/short-url/6b8huO1aL75FYNO9hfaub9QZTFn.nb) (42.9 KB)

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [June 30, 2021, 6:07pm UTC](https://community.wolfram.com/t/findminimum-giving-erroneous-value/18361/5 "2021-06-30T18:07:52Z")

</div>

The problem is that for `g = 0.093` there is no gradient sign change in the domain of the `y3` solution so the `tMax` returned by `FindMaximum` is `2.2518*10^15` which is way outside the domain.

```
Plot[y3, {t, 0, 5000}]

```

 ![10819plot.png](https://global.discourse-cdn.com/wolfram/original/3X/3/b/3b37dcb63e87ae5a8ee64266fab940e7ee16faef.png)
