ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 15 Nov 2021 15:31:33 +0100how to solve an equation including natural loghttps://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/
I am attemping to solve this equation for X:
1=lnX/0.08//x-0.08
I re-arranged to
x-0.08 = ln x/0.08
then:
0.08X-0.0064 = ln X
X = ?
this is where I am stuck.
Any suggestions?Sun, 14 Nov 2021 21:57:34 +0100https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/Comment by keko for <p>I am attemping to solve this equation for X:</p>
<p>1=lnX/0.08//x-0.08</p>
<p>I re-arranged to</p>
<p>x-0.08 = ln x/0.08</p>
<p>then:</p>
<p>0.08X-0.0064 = ln X</p>
<p>X = ?</p>
<p>this is where I am stuck.</p>
<p>Any suggestions?</p>
https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?comment=59750#post-id-59750For future questions you may ask, I suggest that you use LaTeX to write an equation, since the first expression is not very clear:
$1 = \frac{\ln(x)}{0.08(x-0.08)}$Mon, 15 Nov 2021 11:06:24 +0100https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?comment=59750#post-id-59750Answer by Max Alekseyev for <p>I am attemping to solve this equation for X:</p>
<p>1=lnX/0.08//x-0.08</p>
<p>I re-arranged to</p>
<p>x-0.08 = ln x/0.08</p>
<p>then:</p>
<p>0.08X-0.0064 = ln X</p>
<p>X = ?</p>
<p>this is where I am stuck.</p>
<p>Any suggestions?</p>
https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?answer=59753#post-id-59753Setting $Y:=-(\ln X + 0.0064) = -\ln(e^{0.0064}X)$, we get an equation:
$$Ye^Y = -\frac{0.08}{e^{0.0064}},$$
implying that $Y = W( -\frac{0.08}{e^{0.0064}} )$, where $W$ is [Lambert W function](https://en.wikipedia.org/wiki/Lambert_W_function). Then
$$X = e^{- W( -\frac{0.08}{e^{0.0064}} ) - 0.0064}.$$
In Sage we can define a function that computes $X$ depending on a branch of $W$:
def X(branch=0):
return exp(-lambert_w(branch, -0.08/exp(0.0064)) - 0.0064 )
Then `X(0)` gives `1.08359901378819`, `X(-1)` gives `48.6340483659129`, and other branches give various complex solutions.Mon, 15 Nov 2021 15:31:06 +0100https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?answer=59753#post-id-59753Answer by keko for <p>I am attemping to solve this equation for X:</p>
<p>1=lnX/0.08//x-0.08</p>
<p>I re-arranged to</p>
<p>x-0.08 = ln x/0.08</p>
<p>then:</p>
<p>0.08X-0.0064 = ln X</p>
<p>X = ?</p>
<p>this is where I am stuck.</p>
<p>Any suggestions?</p>
https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?answer=59749#post-id-59749This expression has no analytical solution, therefore you need to solve it numerically. For that, you can use *find_root* in a given range $0\lt x \lt 2$:
sol = find_root(0.08*x-0.0064 == log(x), 0,2); sol
which will give you,
1.0835990137881888
Mon, 15 Nov 2021 11:03:07 +0100https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?answer=59749#post-id-59749Comment by Max Alekseyev for <p>This expression has no analytical solution, therefore you need to solve it numerically. For that, you can use <em>find_root</em> in a given range $0\lt x \lt 2$:</p>
<pre><code>sol = find_root(0.08*x-0.0064 == log(x), 0,2); sol
</code></pre>
<p>which will give you,</p>
<pre><code>1.0835990137881888
</code></pre>
https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?comment=59754#post-id-59754It does have an analytical solution in terms of Lambert W function.Mon, 15 Nov 2021 15:31:33 +0100https://ask.sagemath.org/question/59748/how-to-solve-an-equation-including-natural-log/?comment=59754#post-id-59754