1

How can I find the points of intersection of cosh(x) and sec(x)?

Plotting the two, I can see that it has a root around 4.7, but then I can't tell where the next root is.

But when I use FindRoot with a guess of 4.7 I don't get the root but if I use a guess between 4.72 and 4.8 then I find the root - 4.730040744862704.

Also, another root - 7.8532046241 can be found by guessing between 7.83 and 7.85.

Q: Is there a better way to solve the equation: Cosh[x]==Sec[x]? Q: How do I see the other points of intersection of the graphs y=Cosh[x] and y=Sec[x]?

Any help would be much appreciated. Thanks!

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
Ashish
  • 77
  • 2
  • FYI FindRoot uses newtons method when you give it a single point and the secant method when you supply 2. The derivative of your function is very large near the root so newtons method shoots off far away from your guess on the first iteration. – george2079 May 10 '18 at 15:41
  • Q: How do I see the other points of intersection of the graphs y=Cosh[x] and y=Sec[x]? – Ashish May 14 '18 at 15:35

2 Answers2

3

You can use Solve or Reduce if you add a domain restriction:

N @ Solve[Cosh[x] == Sec[x] && -10<x<10, x]
N @ Reduce[Cosh[x] == Sec[x] && -10<x<10, x]

{{x -> 0.}, {x -> 0.}, {x -> 0.}, {x -> 0.}, {x -> -7.8532}, {x -> -4.73004}, {x -> 4.73004}, {x -> 7.8532}}

x == -7.8532 || x == -4.73004 || x == 0. || x == 4.73004 || x == 7.8532

(using NSolve directly seems to miss roots)

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
  • 1
    Solving N@Solve[Cosh[x]*Cos[x] - 1 == 0 && -10 < x < 10, x] is 20 times faster, presumably because it removes the singularity. – anderstood May 10 '18 at 15:13
  • Q: How do I see the other points of intersection of the graphs y=Cosh[x] and y=Sec[x]? – Ashish May 14 '18 at 15:35
0

From: About multi-root search in Mathematica for transcendental equations

Clear[findRoots]
Options[findRoots] = Options[Reduce];
findRoots[gl_Equal, {x_, von_, bis_}, 
prec : (_Integer?Positive | MachinePrecision | Infinity) : 
MachinePrecision, wrap_: Identity, opts : OptionsPattern[]] := 
Module[{work, glp, vonp, 
bisp}, {glp, vonp, bisp} = {gl, von, bis} /. 
r_Real :> SetPrecision[r, prec];
work = wrap@Reduce[{glp, vonp <= x <= bisp}, opts];
work = {ToRules[work]};
If[prec === Infinity, work, N[work, prec]]];

A domain restriction is -10 < x < 10

findRoots[Cosh[x] == Sec[x], {x, -10, 10}]

(* {{x -> -7.8532}, {x -> -4.73004}, {x -> 0.}, {x -> 4.73004}, {x -> 7.8532}} *)

Or:

findRoots[Cosh[x]*Cos[x] == 1, {x, -10, 10}](* 33 times faster *)

(* {{x -> -7.8532}, {x -> -4.73004}, {x -> 0.}, {x -> 4.73004}, {x -> 7.8532}}*)
Mariusz Iwaniuk
  • 13,841
  • 1
  • 25
  • 41