2
$\begingroup$

I want to numerically solve $$\cosh\left(\frac{1}{x}\right)-\frac{1}{x^2}\sinh\left(\frac{1}{x}\right)=0.$$

A strange thing is that Wolfram|Alpha it solves it perfectly, but Mathematica I have this:

enter image description here

How can this be possible?

$\endgroup$
6
  • 1
    $\begingroup$ what is the output from Wolfram? $\endgroup$
    – Sumit
    Commented Dec 17, 2017 at 11:32
  • $\begingroup$ Please post the input you gave to Wolfram alpha language also. The Wolfram alpha is different from the Wolfram Mathematica language. You could have typed something which Wolfram alpha understood to be something different from Wolfram mathematica, since Wolfram alpha is AI based and uses natural language input which is not the case with the Wolfram Mathematica language. $\endgroup$
    – Nasser
    Commented Dec 17, 2017 at 11:40
  • $\begingroup$ Use FindRoot[Cosh[1/x] - 1/x^2 Sinh[1/x], {x, 1}] $\endgroup$
    – Raffaele
    Commented Dec 17, 2017 at 15:01
  • 1
    $\begingroup$ @Nasser - this is the OP's input: wolframalpha.com/input/… $\endgroup$
    – Jason B.
    Commented Dec 17, 2017 at 16:57
  • 1
    $\begingroup$ NSolve requires some domain restrictions so that there will be finitely many solutions. In[124]:= NSolve[ Cosh[1/x] - Sinh[1/x]/x^2 == 0 && 0 < x < 100, x, Reals] Out[124]= {{x -> 0.897517}} $\endgroup$ Commented Dec 17, 2017 at 17:17

1 Answer 1

7
$\begingroup$

Usually NSolve is preferable for polynomical functions. You can solve your problems in this way:

FindRoot[Cosh[1/x] - Sinh[1/x]/x^2, {x, .1}] (* with startvalue *)
(* {x -> 0.897517} *)

or

NMinimize[{1, Cosh[1/x] - Sinh[1/x]/x^2 == 0}, x] (* without startvalue *)
(* {1., {x -> 0.897517}} *)
$\endgroup$
5
  • $\begingroup$ I did not know the f[x]==0 constraint + nminimize trick... is it yours? $\endgroup$ Commented Dec 17, 2017 at 12:18
  • 1
    $\begingroup$ @Picaud Vincent: Unfortunately not ( ;-) ). I found it by chance someware in the advanced NMinimze documentation... $\endgroup$ Commented Dec 17, 2017 at 12:26
  • 1
    $\begingroup$ @PicaudVincent Related to this trick: mathematica.stackexchange.com/questions/159589/…. $\endgroup$
    – anderstood
    Commented Dec 17, 2017 at 13:10
  • $\begingroup$ @anderstood thanks $\endgroup$ Commented Dec 17, 2017 at 13:12
  • $\begingroup$ The NMinimize-trick can be found in the help NMinimize\NeatEaxamples! $\endgroup$ Commented Dec 17, 2017 at 15:44

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