0
$\begingroup$

To obtain the natural frequency of the clamped beam, I need to solve the following equation:

Cos[x]Cosh[x]==1

I use the Solve function to do this. Since this transcendental equation has infinite roots, I prescribe the range of the roots. The code I write is

Solve[Cos[x] Cosh[x] == 1 && 0 < x < 500, x, Reals]

I obtain the roots belonging to [0,500]. Now I want to prescribe the number of the roots rather than the range of the roots. How can I do this?

$\endgroup$
  • $\begingroup$ You can find it with CountRoots[Cos[x] Cosh[x] - 1, {x, 0, 500}], however since it counts also multiple roots it might be resonable to use Solve, DeletDuplicates and finally Length. $\endgroup$ – Artes Nov 7 '17 at 9:39
  • $\begingroup$ @Artes Thanks for your comments. I mean I want to obtain the roots with prescribed numbers. For example, I want to obtain the first 100 roots. $\endgroup$ – Ice0cean Nov 7 '17 at 9:42
  • $\begingroup$ I do not think that most root finding methods can find real roots in increasing order, thus it wouldn't really make sense to have such a function. You can keep extending the interval until you have the desired number of roots. If you just want to find one root, whichever that may be, use FindRoot. $\endgroup$ – Szabolcs Nov 7 '17 at 9:56
  • $\begingroup$ You can play with IsolatingInterval for polynomials, however there is no specific functionality for transcendental equations. Nevertheless you can do it simply with Solve and Take[...,100]. There might be a bit more efficient method, but in general, it strongly depends on functions you deal with, so you shouldn't expect a universal approach. $\endgroup$ – Artes Nov 7 '17 at 10:02
3
$\begingroup$

Modifying Daniel's solution here, we have (where I only take the second to twelfth roots, since we already know $x=0$ is a root):

k = 0;
Reap[NDSolve[{y'[x] == D[Exp[-x] (1 - Cos[x] Cosh[x]), x], y[0] == 0, 
              WhenEvent[y[x] == 0, Sow[x]; k++; If[k >= 11, "StopIntegration"]]},
             {}, {x, 0, ∞}, WorkingPrecision -> 20]][[-1, 1]]
{4.7300407456851316296, 7.8532046220416923611, 10.995607838630982039,
 14.137165489317331787, 17.278759656830400174, 20.420352243844582474,
 23.561944901469892955, 26.703537553710273995, 29.845130209052511595,
 32.986722860941260188, 36.128315516208914460}

Note the introduction of the damping $\exp(-x)$ factor for stability. The roots so obtained can be polished further with FindRoot[] if need be.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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