When does $\ln(x)=\sin(x)$?

3.2k Views Asked by At

This isn't a very easy equation to solve, and I really don't know where to start. I need the answer, not hints, because I know this is too hard for my level and I won't be able to do it even with hints. I'd like the answer in fractions, not decimals (I could easily use a graphing calculator to get the decimal answer). Use $\pi$ and e symbols as necessary. Thanks!

Note: if you use any complicated functions in your answer, please explain what they are.

5

There are 5 best solutions below

4
On BEST ANSWER

If $\log x = \sin x$, then $x>0$ (otherwise the logarithm is not defined) and $x\leq e$ (otherwise $\log(x)>1\geq\sin(x)$), so we just have to find the roots of $f(x)=\sin x-\log x$ over $I=(0,e]$. There is at least one root since $e<\pi$ implies that $f$ has opposite signs on the endpoints of $I$. Such a root is unique since $f(x)$ is decreasing over $I$, as a consequence of: $$ f'(x) = \cos x-\frac{1}{x} < 0.\tag{1}$$ To prove $(1)$ it is sufficient to study the function $g(x)=x\cos x-1$ over $I$. By computing its derivative, we see that it has a maximum where $x=\cot x$, hence for some $x<1$. But if $x<1$, then $g(x)<0$.

Since $f$ is concave (by computing $f''$) and negative in a right neighbourhood of the root, we can find such a root by choosing $x=e$ as a starting point for the Newton's method.

2
On

From the graph, one suspects that they cross each other near $x = 2$. Expanding both sides including the second order term you have $$-\frac{1}{8} (x-2)^2+\frac{x-2}{2}+\log (2)\approx-\frac{1}{2} (x-2)^2 \sin (2)+(x-2) \cos (2)+\sin (2)$$ Solve for $x$ and you'll find that one of the solutions is given by:

$$x\approx\frac{2}{4\sin(2)-1}\times \\\Bigg(-2+4 \sin (2)+2 \cos (2)\\+\sqrt{1+2 \log (2)+8 \sin ^2(2)-2 \sin (2)+4 \cos ^2(2)-4 \cos (2)-8 \log (2) \sin (2)}\Bigg) \\ \approx 2.219\dots.$$

0
On

This kind of equation do not show analytical solution (just remember that $x=\cos(x)$ is in this family). So, as Santosh Linkha already commented, only numerical methods will do the job.

One of the simplest root finding method is Newton : starting from a reasonable guess $x_0$, this will be updated according to $$x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}$$ In your case, let us define $$f(x)=\log(x)-\sin(x)$$ $$f'(x)=\frac 1x -\cos(x)$$ As already commented by barak manos, the only valid range is $\frac{1}{e}\leq{x}\leq{e}$. So, let us be very lazy and start at the middle of the range $x_0=\frac 12(e+\frac{1}{e})$ and apply the method.

This generates the following iterates : $2.27593$, $2.21996$, $2.21911$ which is the solution for six significant figures.

Added later

You could have observed that the obtained solution is quite close to $\frac{7\pi}{10} \sim 2.19911$. So, if you perform one single Newton iteration using this estimate, a good approximation of the solution is given by $$\frac{7 \pi \left(7 \sqrt{10-2 \sqrt{5}} \pi +10 \left(5+\sqrt{5}-4 \log \left(\frac{7 \pi }{10}\right)\right)\right)}{400+70 \sqrt{10-2 \sqrt{5}} \pi } \sim 2.21922$$

2
On

Exponentiation of both sides give $$ \ln(x) = \sin(x) \iff x = e^{\sin(x)} \iff f(x) = x $$ where the last equations are fixed point equations.

As $\sin(x) \in [-1, 1]$ we have $$ e^{\sin(x)} \in [1/e, e] \approx [0.368, 2.718] $$

A plot shows that there is one real fixed point in $[2, 2.5]$.

graph x vs f(x)

To determine a more precise value one needs to apply a numerical procedure, or zoom-in graphically.

One way to solve a fixed point equation is by simple iteration. However the fixed point $x^*$ must be attractive. A criterion for this is $\lvert f'(x^*) \rvert < 1$.

Here $f'(x) = f(x) \cos(x)$. A quick plot of $\lvert f'(x) \rvert$ gives

f'(x)

which shows (blue curve) that this is not an attractive fixed point.

So we try the inverse equation: $$ \ln(x) = \sin(x) \Rightarrow (\sin^{-1})(\ln(x)) = x $$

To have $\sin^{-1}$ deliver values around $x=2.2$ we must invert the sine starting $\pi/2$ to the left of the usual $[-\pi/4, \pi/4]$ which gives $$ \sin^{-1}(x) = \pi - \arcsin(x) $$ and leads to the fixed point equation $$ f(x) := \pi - \arcsin(\ln(x)) = x \quad (*) $$ as Barry Cipra pointed out first.

Differentiating $y = f(f^{-1}(y))$ gives $$ (f^{-1})'(y) = 1/f'(f^{-1}(y)) $$ which we use to determine $$ f'(x) = - \frac{1}{\sqrt{1 - (\ln(x))^2}} \frac{1}{x} $$

Plotting this gives

inverse fixed point equation

which shows that $\lvert f'(x) \rvert < 1$ in the interval of interest and thus that this fixed point is attractive.

So we start e.g. with $x_0 = 2$ and calculate the next values using equation $(*)$ by $$ x_n := f(x_{n-1}) = f^n(x_0) $$

This gives an equation with a term of infinite length at the right hand side: $$ x^* = \pi - \arcsin(\ln( \pi - \arcsin(\ln( \pi - \arcsin(\ln( \cdots \pi - \arcsin(\ln( \pi - \arcsin(\ln(x_0))))\ldots)))))) $$

Using a few lines of Ruby (see below) to implement the iteration I got the following values.

Iteration Values

00: 2.000000
01: 2.375746
02: 2.095821
03: 2.308604
04: 2.150467
05: 2.269487
06: 2.180961
07: 2.247301
08: 2.197901
09: 2.234846
10: 2.207311
..
20: 2.218476
..
30: 2.219073
..
40: 2.219105
41: 2.219109
42: 2.219106
43: 2.219108
44: 2.219107
45: 2.219108
46: 2.219107
47: 2.219107

The convergence rate is slower than the quadratic convergence of the Newton-Raphson method. The iteration looks like this:

fixed point iteration

Ruby code

def f(x)
  y = Math::PI - Math.asin(Math.log(x))
end

def g(x0, n)
  x = x0
  i = 0
  while i <= n 
    printf "%02d: %f\n", i, x
    x = f(x)
    i += 1
  end
end
0
On

It's clear that any root of $\displaystyle\,{\rm f}\left(\,x\,\right) \equiv \ln\left(\,x\,\right) - \sin\left(\,x\,\right)$ belong to $\displaystyle\left[\, {1 \over {\rm e}},{\rm e}\,\right]$.

So, once you know this fact you can use the Bisection Method to find the roots.

The following $\displaystyle{\verb*C++*}$ script makes that calculation and it yields the answer

Root = 2.219107153; f(Root) =4.605411053e-09

A further improvement with Newton-Raphson Method which start with the above root $\left(~{\tt 2.219107153}~\right)$ yields

Root = 2.21911; f(Root) = -1.11022e-16


/* bisection0.cc Felix Marin 04-dic-2014
http://math.stackexchange.com/a/1052008/85343
*/
#include <cfloat>
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
const double MINTOL=1.05*sqrt(DBL_EPSILON);
const size_t MAXITER=10000U;

inline double f(double x)
{
 return log(x) - sin(x);
}


inline signed char theSignOf(double x)
{
 return ( x>0 ) - ( x<0 );
}


int main()
{
 double a=1.0/M_E,b=M_E;
 const signed char sfa=theSignOf(f(a)),sfb=theSignOf(f(b));
 if ( sfa==sfb ) {
    cerr<<"\nThere is not any root !!!\n";
    return 0;
 }   

 double x;
 if (  ( sfa!=0 ) && ( sfb!=0 )  ) {
    double fx,tol,xOld;
    signed char sfx;

    x=(a + b)/2.0;
    for ( size_t n=0 ; n<MAXITER ; ++n ) {
        fx=f(x);
        sfx=theSignOf(fx);
        if ( sfx==sfa ) a=x; else if ( sfx==sfb ) b=x; else break;
        xOld=x;
        x=(a + b)/2.0;
        tol=abs(x + xOld)/2.0;
        if ( tol>0 ) tol=abs(x - xOld)/tol; else tol=abs(x - xOld);
        if ( tol<=MINTOL ) break;
    }
 } else if ( sfa==0 ) x=a; else x=b;

 cout<<setprecision(10)<<"\n Root = "<<x<<"; f(Root) ="<<f(x)<<endl;

 return 0;
}