# Solving equation with 'narrow' solutions

Consider a function such as

f[x_] := 1/4 x^2 - 3 Cos[6 x] - 7/5


Is there some clever way to solve $$f(x)=0$$, either with exact roots or having Mathematica return a list of intervals, $$[a_i,a_i+\delta]$$ of a certain length $$\delta>0$$, where $$f(a_i)\cdot f(a_i+\delta)=-1$$?

I could write a For loop but experts here tend to find brilliant one-line solutions to my own "multiple-line" (basic and naive) solutions. Perhaps the output could even serve as input to FindRoot to find the exact roots?

You could just use Solve:

sols = Solve[1/4 x^2-3 Cos[6 x]-7/5==0,x,Reals]


{{x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -4.1944195824709601156}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -4.1443220023851876569}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -3.32475678696060154959}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -2.9209295073933144008}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -2.3568247304438990610}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -1.79958153941302338362}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -1.36189787914973414618}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -0.71235207082364557790}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, -0.34089931495521312949}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 0.34089931495521312949}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 0.71235207082364557790}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 1.36189787914973414618}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 1.79958153941302338362}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 2.3568247304438990610}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 2.9209295073933144008}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 3.32475678696060154959}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 4.1443220023851876569}]}, {x -> Root[{-28 - 60 Cos[6 #1] + 5 #1^2 &, 4.1944195824709601156}]}}

The above results are exact. To get approximate results, just use NSolve instead, or apply N to the above result:

N[sols, 20]


{{x -> -4.1944195824709601156}, {x -> -4.1443220023851876569}, {x -> -3.3247567869606015496}, {x -> -2.9209295073933144008}, {x -> -2.3568247304438990610}, {x -> -1.7995815394130233836}, {x -> -1.3618978791497341462}, {x -> -0.71235207082364557790}, {x -> -0.34089931495521312949}, {x -> 0.34089931495521312949}, {x -> 0.71235207082364557790}, {x -> 1.3618978791497341462}, {x -> 1.7995815394130233836}, {x -> 2.3568247304438990610}, {x -> 2.9209295073933144008}, {x -> 3.3247567869606015496}, {x -> 4.1443220023851876569}, {x -> 4.1944195824709601156}}

The equation is symmetric and can be solved using NSolve(without RooT...)

sol = NSolve[{1/4 x^2 - 3 Cos[6 x] - 7/5 == 0, 0 <= x }, Reals]
(*{{x -> 0.340899}, {x -> 0.712352}, {x -> 1.3619}, {x ->
1.79958}, {x -> 2.35682}, {x -> 2.92093}, {x -> 3.32476}, {x ->
4.14432}, {x -> 4.19442}}*)

Plot[1/4 x^2 - 3 Cos[6 x] - 7/5, {x, 0, 2 Pi },GridLines -> {x /. sol, None}]


• There is a polynomial part (so it cannot be periodic). Eventually it even becomes monotonic. Commented Nov 17, 2018 at 15:28
• Sorry I didn't see it. My answer will be edited. Thanks. Commented Nov 17, 2018 at 16:12
• This is not periodic. (That was a joke. I am repeating myself. Ha ha.) Commented Nov 17, 2018 at 16:22