1
$\begingroup$

I have a equation nn which is a function of t and k. I want to find the maximum of the equation for different wave numbers in a fixed range.

so far I tried the following,

nn =  -k^2 Sin[t] Exp[-2 k^2 Sin[t/2]^2];
i2k[i_] = 1/2 (i - 1) ;
data2 = Table[
   nn /. k -> -i2k[i] /. t -> t - 2 // Evaluate, {i, 3, 10}]; 
dxx2[t_] = D[data2, t ];
max = t /. FindRoot[dxx2[t], {t, #}] & /@ Range[20.72, 20.80, 0.01] //
    Select[20.72 < # < 20.80 &] // 
  DeleteDuplicatesBy[Round[#, 10^-4] &]
data2 /. t -> max // Evaluate

However, the number the equation does not match with the numbers of variable in the FindRoot and I can understand why, but I can not implement what I want.dxx[t_] contains all the dervatives. I need to find the root of each dxx[t_] in Range[20.72, 20.80, 0.01] and put it in the main equation to calculate the maximums.

I appreciate it if you could help me.

$\endgroup$

2 Answers 2

2
$\begingroup$

Try

nn = Function[{k, t}, -k^2 Sin[t] Exp[-2 k^2 Sin[t/2]^2]];

(* list of functions i=3...10*)
funs = Table[nn[1/2 (i - 1), t - 2], {i, 3, 10}]
pic=Plot[funs, {t, 20  , 21}]  (* time range 20 <t<21 *)

enter image description here

maxis = Map[NMaximize[{#, 20 < t < 21}, t] &, funs]
Show[pic, Graphics[Map[Point[{t /. #[[2]], #[[1]]}] &, maxis]]]

enter image description here

$\endgroup$
0
$\begingroup$
$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global`*"]

nn = -k^2 Sin[t] Exp[-2 k^2 Sin[t/2]^2];
i2k[i_] = 1/2 (i - 1);
data2 = Table[nn /. k -> -i2k[i] /. t -> t - 2 // Evaluate, {i, 3, 10}];

The exact values are

(max = Maximize[{#, 19 < t < 21}, t] & /@ data2 // Simplify)

(* {{-E^(-2 Sin[
      2 ArcTan[Sqrt[5 + 2 Sqrt[5] + 2 Sqrt[11 + 5 Sqrt[5]]]]]^2) Sin[
    4 ArcTan[Sqrt[5 + 2 Sqrt[5] + 2 Sqrt[11 + 5 Sqrt[5]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[5 + 2 Sqrt[5] + 2 Sqrt[11 + 5 Sqrt[5]]]]}}, {-(9/4)
     E^(-(9/2) Sin[
     2 ArcTan[Sqrt[10 + Sqrt[85] + 2 Sqrt[46 + 5 Sqrt[85]]]]]^2)
    Sin[4 ArcTan[Sqrt[
      10 + Sqrt[85] + 2 Sqrt[46 + 5 Sqrt[85]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[
       10 + Sqrt[85] + 2 Sqrt[46 + 5 Sqrt[85]]]]}}, {-4 E^(-8 Sin[
     2 ArcTan[Sqrt[17 + 2 Sqrt[65] + 2 Sqrt[137 + 17 Sqrt[65]]]]]^2)
    Sin[4 ArcTan[Sqrt[
      17 + 2 Sqrt[65] + 2 Sqrt[137 + 17 Sqrt[65]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[
       17 + 2 Sqrt[65] + 2 Sqrt[137 + 17 Sqrt[65]]]]}}, {-(25/4)
     E^(-(25/2) Sin[
     2 ArcTan[Sqrt[26 + Sqrt[629] + 2 Sqrt[326 + 13 Sqrt[629]]]]]^2)
    Sin[4 ArcTan[Sqrt[
      26 + Sqrt[629] + 2 Sqrt[326 + 13 Sqrt[629]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[
       26 + Sqrt[629] + 
        2 Sqrt[326 + 13 Sqrt[629]]]]}}, {-9 E^(-18 Sin[
     2 ArcTan[Sqrt[37 + 10 Sqrt[13] + 2 Sqrt[667 + 185 Sqrt[13]]]]]^2)
    Sin[4 ArcTan[Sqrt[
      37 + 10 Sqrt[13] + 2 Sqrt[667 + 185 Sqrt[13]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[
       37 + 10 Sqrt[13] + 2 Sqrt[667 + 185 Sqrt[13]]]]}}, {-(49/4)
     E^(-(49/2) Sin[
     2 ArcTan[Sqrt[
       50 + Sqrt[2405] + 2 Sqrt[1226 + 25 Sqrt[2405]]]]]^2)
    Sin[4 ArcTan[Sqrt[
      50 + Sqrt[2405] + 2 Sqrt[1226 + 25 Sqrt[2405]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[
       50 + Sqrt[2405] + 
        2 Sqrt[1226 + 25 Sqrt[2405]]]]}}, {-16 E^(-32 Sin[
     2 ArcTan[Sqrt[
       65 + 10 Sqrt[41] + 2 Sqrt[2081 + 325 Sqrt[41]]]]]^2)
    Sin[4 ArcTan[Sqrt[
      65 + 10 Sqrt[41] + 2 Sqrt[2081 + 325 Sqrt[41]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[
       65 + 10 Sqrt[41] + 2 Sqrt[2081 + 325 Sqrt[41]]]]}}, {-(81/4)
     E^(-(81/2) Sin[
     2 ArcTan[Sqrt[
       82 + Sqrt[6565] + 2 Sqrt[3322 + 41 Sqrt[6565]]]]]^2)
    Sin[4 ArcTan[Sqrt[
      82 + Sqrt[6565] + 2 Sqrt[3322 + 41 Sqrt[6565]]]]], {t -> 
    2 + 4 π + 
     4 ArcTan[Sqrt[82 + Sqrt[6565] + 2 Sqrt[3322 + 41 Sqrt[6565]]]]}}} *)

The approximate values are

max // N

(* {{0.536563, {t -> 19.945}}, {0.860824, {t -> 20.2097}}, {1.17579, 
    {t -> 20.3605}}, {1.48632, {t -> 20.4551}}, {1.7945, 
    {t -> 20.5194}}, {2.10131, {t -> 20.5658}}, {2.40724, 
    {t -> 20.6009}}, {2.71259, {t -> 20.6283}}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.