Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know how fancy you want it to look, but here is a brute force approach which would be good enough for me as a starting point, and can probably be tweaked further:</p> <pre><code>tk0 = \[Theta]'[t]*\[Theta]'[t] - \[Theta][t]*\[Theta]''[t]; tk1 = \[Theta]''[t]*\[Theta]''[t] - \[Theta]'[t]*\[Theta]'''[t]; a = tk0/Sqrt[tk1]; f = Sqrt[tk1/tk0]; s = NDSolve[{\[Theta]''[t] + \[Theta][t] - 0.167 \[Theta][t]^3 == 0.005 Cos[t - 0.5*0.00009*t^2], \[Theta][0] == 0, \[Theta]'[0] == 0}, \[Theta], {t, 0, 1000}]; plot = Plot[Evaluate[f /. s], {t, 0, 1000}, Frame -&gt; {True, True, False, False}, FrameLabel -&gt; {"t", "Frequency"}, FrameStyle -&gt; Directive[FontSize -&gt; 15], Axes -&gt; False]; Clear[ff]; Block[{t, x}, With[{fn = f /. s}, ff[x_?NumericQ] = First[(fn /. t -&gt; x)]]]; localMinPositionsC = Compile[{{pts, _Real, 1}}, Module[{result = Table[0, {Length[pts]}], i = 1, ctr = 0}, For[i = 2, i &lt; Length[pts], i++, If[pts[[i - 1]] &gt; pts[[i]] &amp;&amp; pts[[i + 1]] &gt; pts[[i]], result[[++ctr]] = i]]; Take[result, ctr]]]; (* Note: takes some time *) points = Cases[ Reap[Plot[(Sow[{t, #}]; #) &amp;[ff[t]], {t, 0, 1000}, Frame -&gt; {True, True, False, False}, FrameLabel -&gt; {"t", "Frequency"}, FrameStyle -&gt; Directive[FontSize -&gt; 15], Axes -&gt; False, PlotPoints -&gt; 50000]][[2, 1]], {_Real, _Real}]; localMins = SortBy[Nest[#[[ localMinPositionsC[#[[All, 2]]]]] &amp;, points, 2], First]; env = ListPlot[localMins, PlotStyle -&gt; {Pink}, Joined -&gt; True]; Show[{plot, env}] </code></pre> <p>What happens is that your oscillatory function has some non-trivial fine structure, and we need a lot of points to resolve it. We collect these points from Plot by Reap - Sow, and then filter out local minima. Because of the fine structure, we need to do it twice. The plot you actually want is stored in "env". As I said, it probably could be tweaked to get a better quality plot if needed.</p> <p>Edit:</p> <p>In fact, <em>much</em> better plot can be obtained, if we increase the number of PlotPoints from 50000 to 200000, and then repeatedly remove points of local maxima from localMin. Note that it will run slower and require more memory however. Here are the changes:</p> <pre><code>(*Note:takes some time*) points = Cases[ Reap[Plot[(Sow[{t, #}]; #) &amp;[ff[t]], {t, 0, 1000}, Frame -&gt; {True, True, False, False}, FrameLabel -&gt; {"t", "Frequency"}, FrameStyle -&gt; Directive[FontSize -&gt; 15], Axes -&gt; False, PlotPoints -&gt; 200000]][[2, 1]], {_Real, _Real}]; localMins = SortBy[Nest[#[[localMinPositionsC[#[[All, 2]]]]] &amp;, points, 2], First]; localMaxPositionsC = Compile[{{pts, _Real, 1}}, Module[{result = Table[0, {Length[pts]}], i = 1, ctr = 0}, For[i = 2, i &lt; Length[pts], i++, If[pts[[i - 1]] &lt; pts[[i]] &amp;&amp; pts[[i + 1]] &lt; pts[[i]], result[[++ctr]] = i]]; Take[result, ctr]]]; localMins1 = Nest[Delete[#, List /@ localMaxPositionsC[#[[All, 2]]]] &amp;, localMins, 15]; env = ListPlot[localMins1, PlotStyle -&gt; {Pink}, Joined -&gt; True]; Show[{plot, env}] </code></pre> <p>Edit: here is the plot (done as <code>GraphicsGrid[{{env}, {Show[{plot, env}]}}]</code>)</p> <p><img src="https://i.stack.imgur.com/s0fqT.jpg" 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. 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