How to solve $x^2 + \ln(x) = 0$

$\begingroup$

I was just investigating $y = f(x) = e^{-x^2}$ and then went ahead to plot $x=f(y), y=-f(x), and x=-f(y)$, and what I got was interest rounded square shape, and I think we can calculate this area using integration. However to get the bounds I must solve the equation $x^2 + \ln(x) = 0$. Is there a way to solve this equation without using the graph?

Shape

$\endgroup$ 1

5 Answers

$\begingroup$

Not really. Just as you can't solve $2^x=3$ using algebra (you need to create a new kind of function; logarithms), you can't solve tihs one without creating a new kind of special function. The one we have for this is called the Lambert W function, the inverse function of $xe^x$. Then we can solve

$$ x^2+\ln x=0 $$

$$ x^2+\frac{1}{2}\ln x^2=0 $$

$$ 2x^2+\ln x^2=0 $$

$$ 2x^2+\ln(2x^2)=\ln(2) $$

$$ 2x^2e^{2x^2}=2 $$

$$ 2x^2=W(2) $$

$$ x=\sqrt{\frac{W(2)}{2}}. $$

$\endgroup$ $\begingroup$

$x^2+\ln x=0 \iff \ln x = - x^2$

This implies $x < 1$.

Thus, now rewrite as $$x=e^{-x^2}$$

Now, using Newton-Raphson, set $$x_{n+1} = x_n-\left(\frac{x_n-e^{-x_{n}^2}}{1+2 x_n e^{-x_{n}^2}} \right)$$

And using a very simple piece of software code gives a converging value at $x \approx 0.6529190995 \ldots$

$\endgroup$ $\begingroup$

If for any reason, you prefer to have rational approximations of this number, consider that you look for the zero of function$$f(x)=x^2+\log(x)$$ and use high order iterative methods starting with $x_0$=1.

This will generate the sequence$$\left\{\frac{2}{3},\frac{11}{17},\frac{95}{146},\frac{137}{210},\frac{7897}{12097},\cdots \right\}$$

Edit

Using @Barry Cipra's approach and Newton method, we shall have$$u_{n+1}=\frac{2 (u_n+1)}{e^{u_n}+2}$$ and this converges very fast.$$\left( \begin{array}{cc} n & u_n \\ 0 & 1.00000000000000000000 \\ 1 & 0.84776623046834178028 \\ 2 & 0.85260010780095866454 \\ 3 & 0.85260550200702985567 \\ 4 & 0.85260550201372549135 \end{array} \right)$$

$\endgroup$ $\begingroup$

$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$You can use the Newton Method. Namely,$\ds{x_{n + 1} = x_{n} - {x_{n}\bracks{x_{n}^{2} + \ln\pars{x_{n}}} \over 2x_{n}^{2} + 1}}$ with $\ds{x_{0} = 0.5}$.


The following ${\tt javascript}$ snippet implements it:
// mseMrigankVallabh27jul2020.js
// Execute with node mseMrigankVallabh27jul2020.js
"use strict";
let n = 0, x = 0.5;

console.log("\n########################################"); console.log("Obviously, the solution belongs to (0,1)"); console.log("########################################\n");

while ( n < 5 ) { console.log(x); x -= x*(x*x + Math.log(x))/(2.0*x*x + 1.0); ++n; }

console.log("\nx^2 + ln(x) = " + (x*x + Math.log(x)));

$\ds{\large Result:}$
########################################
Obviously, the solution belongs to (0,1)
########################################
0.5
0.6477157268533151
0.6529168723249813
0.6529186404190143
0.6529186404192047
x^2 + ln(x) = 1.6653345369377348e-16
$\endgroup$ $\begingroup$

Let $x=e^{-u/2}$, which turns the equation to solve into $u=2e^{-u}$. Iterating the function

$$f(u)={u+2e^{-u}\over2}$$

starting with, say $u=1$, leads to $u\approx0.8526055020$, from which $x\approx0.6529186404$ follows.

To be explicit about the iteration (and to indicate how quickly/slowly things converge),

$$\begin{align} f(1)&\approx0.8678794412\\ f(0.8678794412)&\approx0.8537806239\\ f(0.8537806239)&\approx0.8526923995\\ f(0.8526923995)&\approx0.8526119077\\ f(0.8526119077)&\approx0.8526059741\\ f(0.8526059741)&\approx0.8526055368\\ f(0.8526055368)&\approx0.8526055046\\ f(0.8526055046)&\approx0.8526055022\\ f(0.8526055022)&\approx0.8526055020\\ f(0.8526055020)&\approx0.8526055020 \end{align}$$

This approach seems to pick up about one decimal point per iteration. It'd be nice to see a swifter approach.

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like