2

I have to find the positive range for the derivatives of a lot of functions. I have a very inefficient solution.

At the moment I am using a For loop to find the times where the function is positive and use Split as used in #23608 to find the intervals.

Full code:

f[t_] := Sqrt[0.9604 + 0.0099 (Cos[1. t] + Cos[3.14159 t])^2]
ptimes = {};
inc = 0.01;
For[pt = 0, pt <= 10, pt = pt + inc, 
    If[(D[f[z],z]/.{z -> pt}) >= 0, AppendTo[ptimes, pt] && Continue[], Continue[]]
   ]
int = {Min[#], Max[#]} & /@ Split[ptimes, #2 - #1 <= inc &]

({{0, 0}, {0.76, 1.09}, {1.47, 1.9}, {2.28, 3.01}, {3.8, 4.}, {4.01, 4.08}, {4.41, 4.89}, {5.31, 6.02}, {6.83, 7.07}, {7.34, 7.89}, {8.35, 9.03}, {9.87, 10.}})

Although this works, but I am sure there are efficient ways to do this. Appreciate your thoughts.

Note: Using Reduce or Solve barely works for me when some of the arguments inside are irrational.

exp ikx
  • 768
  • 3
  • 13

2 Answers2

7

After replacing 3.14159 with $\pi$ it works:

f[t_] = Sqrt[0.9604 + 0.0099 (Cos[t] + Cos[π*t])^2];

Reduce[f'[t] > 0 && -10 <= t <= 10, t]

(* -9.86111 < t < -9.03828 || -8.34402 < t < -7.89698 || -7.33471 < t < -7.07256 || -6.82692 < t < -6.02582 || -5.30983 < t < -4.89873 || -4.40083 < t < -4.08283 || -3.79273 < t < -3.013 || -2.27564 < t < -1.9027 || -1.46694 < t < -1.09113 || -0.758547 < t < 0 || 0.758547 < t < 1.09113 || 1.46694 < t < 1.9027 || 2.27564 < t < 3.013 || 3.79273 < t < 4.08283 || 4.40083 < t < 4.89873 || 5.30983 < t < 6.02582 || 6.82692 < t < 7.07256 || 7.33471 < t < 7.89698 || 8.34402 < t < 9.03828 || 9.86111 < t <= 10. *)

Roman
  • 47,322
  • 2
  • 55
  • 121
6

Try this:

f[t_] := Sqrt[0.9604 + 0.0099 (Cos[1. t] + Cos[\[Pi] t])^2] // 
  Rationalize

g[t_] := D[f[t], t]

Reduce[g[t] >= 0 && 0 < t < [Pi]] // N

(* 0.758547 <= t <= 1.09113 || 1.46694 <= t <= 1.9027 || 2.27564 <= t <= 3.013 *)

Have fun!

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96