Mathematica Asked on July 24, 2021
I have tried NMaximise. But I am getting an error always. Even if my command is correct. My function is
Cos[π E^x]
and I want to maximise it over the range (-3,3)
NMaximize[{Cos[Pi*E^x], -3 < x < 3}, x]
{1., {x -> 1.38629}}
Answered by cvgmt on July 24, 2021
Maximize[{Cos[π E^x], -3 <= x <= 3}, x]
Even has a symbolic solution.
{1, {x -> Log[2] + Log[5]}}
Answered by wuyudi on July 24, 2021
Plot[Cos[π*E^x], {x, -3, 3}]
There is no unique maximum on the intervall (-3,3) for Cos(πe^x). The function oscillates increasingly rapidly the larger x gets. There many maxima at {x,1}.
The equation is 2 π n == π Exp[x] for natural positive n and π Exp[3] is upper limit.
Table[Solve[2 [Pi] n == [Pi] Exp[x], x, Reals], {n, 1, 10}]
(* {{{x -> Log2}}, {{x -> 2 Log2}}, {{x -> Log2 + Log[3]}}, {{x -> 3 Log2}}, {{x -> Log2 + Log[5]}}, {{x -> 2 Log2 + Log[3]}}, {{x -> Log2 + Log[7]}}, {{x -> 4 Log2}}, {{x -> Log2 + 2 Log[3]}}, {{x -> 2 Log2 + Log[5]}}} *)
2 Log2 + Log[5] approx. 2.99573 < 3
So there 10 maxima in the interval (-3,3).
Plot[Cos[[Pi]*E^x], {x, -3, 3},
Epilog -> {PointSize[Medium],
Point[MapThread[{#1, #2} &, {data, Array[1 &, {10}]}]]}]
NMaximize
finds only one value. That is insufficient. But on the proper selected interval in can find numerical unique maxima:
Table[NMaximize[{Cos[Pi*E^x], Log[2 n] < x < Log[2 n + 1]}, x], {n, 1,
10}]
(* {{1., {x -> 0.693147}}, {1., {x -> 1.38629}}, {1., {x -> 1.79176}}, {1., {x -> 2.07944}}, {1., {x -> 2.30259}}, {1., {x -> 2.48491}}, {1., {x -> 2.63906}}, {1., {x -> 2.77259}}, {1., {x -> 2.89037}}, {1., {x -> 2.99573}}} *)
Answered by Steffen Jaeschke on July 24, 2021
All the maximums of a smooth function Cos[Pi*E^x]
on an interval x>-3,x<3
can be found in such a way:
Reduce[{D[Cos[Pi*E^x], x] == 0,D[Cos[Pi*E^x], {x, 2}] < 0, -3 < x < 3}, x]
x==Log[2]||x==2 Log[2]||x==3 Log[2]||x==4 Log[2]||x==Log[2]+Log[3]||x==2 Log[2]+Log[3]||x==Log[2]+2 Log[3]||x==Log[2]+Log[5]||x==2 Log[2]+Log[5]||x==Log[2]+Log[7]
Another way is as follows.
ResourceFunction["StationaryPoints"][{Cos[Pi*E^x], -3 < x && x < 3}, {x}]
<|"Minima" -> {{-1, {x -> 0}}, {-1, {x -> Log[3]}}, {-1, {x -> 2 Log[3]}}, {-1, {x -> Log[5]}}, {-1, {x -> Log[3] + Log[5]}}, {-1, {x -> Log[7]}}, {-1, {x -> Log[11]}}, {-1, {x -> Log[13]}}, {-1, {x -> Log[17]}}, {-1, {x -> Log[19]}}}, "Maxima" -> {{1, {x -> Log[2]}}, {1, {x -> 2 Log[2]}}, {1, {x -> 3 Log[2]}}, {1, {x -> 4 Log[2]}}, {1, {x -> Log[2] + Log[3]}}, {1, {x -> 2 Log[2] + Log[3]}}, {1, {x -> Log[2] + 2 Log[3]}}, {1, {x -> Log[2] + Log[5]}}, {1, {x -> 2 Log[2] + Log[5]}}, {1, {x -> Log[2] + Log[7]}}}|>
Answered by user64494 on July 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP