Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use <strong>NMaximize</strong></p> <p>First approximation: </p> <pre><code>s = NDSolve[{x''[t] + x[t] - 0.167 x[t]^3 == 0.005 Cos[t + -0.0000977162*t^2/2], x[0] == 0, x'[0] == 0}, x[t], {t, 0, 1000}] NMaximize[{Evaluate[x[t] /. s[[1]]] , 100 &lt; t &lt; 1000}, t] {1.26625, {t -&gt; 821.674}} </code></pre> <p>As your function is a rapid oscillation like this : <img src="https://i.stack.imgur.com/SJ4XU.png" alt="alt text"> , it doesn't catch the real max value, as you may see below: </p> <pre><code>Plot[{1.26625, Evaluate[x[t] /. s[[1]]]}, {t, 790, 830}, Frame -&gt; {True, True, False, False}, FrameLabel -&gt; {"t", "x"}, FrameStyle -&gt; Directive[FontSize -&gt; 15], Axes -&gt; False, PlotRange -&gt; {{790, 830}, {1.25, 1.27}}] </code></pre> <p><img src="https://i.stack.imgur.com/g0y45.png" alt="alt text"></p> <p>So we refine our bounds, and tune a little the NMaximize function: </p> <pre><code>NMaximize[{Evaluate[x[t] /. s[[1]]] , 814 &lt; t &lt; 816}, t, AccuracyGoal -&gt; 20, PrecisionGoal -&gt; 18, MaxIterations -&gt; 1000] NMaximize::cvmit: Failed to converge to the requested accuracy or precision within 1000 iterations. &gt;&gt; {1.26753, {t -&gt; 814.653}} </code></pre> <p>It failed to converge within the required accuracy, but now the result is good enough</p> <pre><code>Plot[{1.2675307922753962`, Evaluate[x[t] /. s[[1]]]}, {t, 790, 830}, Frame -&gt; {True, True, False, False}, FrameLabel -&gt; {"t", "x"}, FrameStyle -&gt; Directive[FontSize -&gt; 15], Axes -&gt; False, PlotRange -&gt; {{790, 830}, {1.25, 1.27}}] </code></pre> <p><img src="https://i.stack.imgur.com/8O0ax.png" alt="alt text"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload