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.Wed, 18 Nov 2020 22:47:15 +0100Confusion with equations with no explicit solutionhttps://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/Hello,
I started getting into sage a couple of days ago. To do so I’m following the handbook « Computational Mathematics with SageMath » and I came across something that I would like to have more details about but I didn’t find anything in the documentation.
So the handbook states that
> “In most cases, as soon as the
> equation or system becomes too
> complex, no explicit solution can be
> found:
sage: solve(x^(1/x)==(1/x)^x, x)
> [(1/x)^x == x^(1/x)]
> However, this is not necessarily a limitation!
> Indeed, a specificity of computer
> algebra is the ability to manipulate
> objects defined by equations, and in
> particular to compute their
> properties, without solving them
> explicitly. Even better: in some
> cases, the equation defining a
> mathematical object is the best
> algorithmic representation for it.”
But it doesn’t say what they mean by an equation being “too complex”. And what does it mean for an equation to not have an explicit solution. Plus in some cases we want to have a numerical result (even if it’s an approximation). For exemple I tried finding from what n0 the Tyler series of the exponential function at x0=1 is in the interval [e-10^-3, e+10^-3] i.e.
∀ ε > 10⁻³ , n > n0 ⇒ | vn − e | < ε
vn being equal to the sum of the terms 1 / i! for i ∈ [ 0, n ]. That being the definition of the Taylor series of the exponential function at x0=1 without taking account of the rest.
to do so I wrote this :
sage: k, n, n0, epsilon = var('k, n, n0, epsilon')
sage: assume(n, 'integer')
sage: epsilon = 1e-1
sage: u(n) = 1/factorial(n)
sage: v(n) = sum(u(k), k, 0, n)
sage: n0 = solve(e - v(n) > epsilon, n)
sage: n0
And sage gives out :
> [[e - sum(1/factorial(k), k, 0, n) - 0.1 > 0]]
The documentation says that to get an explicit solution we jut got to set the parameter explicit_solutions to True but I tried it and it doesn't work. Also I'm using the 8.1 version (it's the latest I found on the ubunru packages repository and I tried to download the 9.2 version but the archive was too voluminous (it's 14 GB and I didn't have enough memoiry space to extract it)
Is it possible to get an approximation of the solution in this case I don’t care for the result to be an approximation because I just need the integer part of it anyway.
Please help me I don’t really know if the problem is that the equation is “too complex” or maybe I’m just not using the sum function right.
Thank you in advance.Wed, 18 Nov 2020 10:14:17 +0100https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/Comment by aylimenz for <p>Hello,</p>
<p>I started getting into sage a couple of days ago. To do so I’m following the handbook « Computational Mathematics with SageMath » and I came across something that I would like to have more details about but I didn’t find anything in the documentation.
So the handbook states that</p>
<blockquote>
<p>“In most cases, as soon as the
equation or system becomes too
complex, no explicit solution can be
found: </p>
</blockquote>
<pre><code>sage: solve(x^(1/x)==(1/x)^x, x)
> [(1/x)^x == x^(1/x)]
</code></pre>
<blockquote>
<p>However, this is not necessarily a limitation!
Indeed, a specificity of computer
algebra is the ability to manipulate
objects defined by equations, and in
particular to compute their
properties, without solving them
explicitly. Even better: in some
cases, the equation defining a
mathematical object is the best
algorithmic representation for it.”</p>
</blockquote>
<p>But it doesn’t say what they mean by an equation being “too complex”. And what does it mean for an equation to not have an explicit solution. Plus in some cases we want to have a numerical result (even if it’s an approximation). For exemple I tried finding from what n0 the Tyler series of the exponential function at x0=1 is in the interval [e-10^-3, e+10^-3] i.e.</p>
<p>∀ ε > 10⁻³ , n > n0 ⇒ | vn − e | < ε</p>
<p>vn being equal to the sum of the terms 1 / i! for i ∈ [ 0, n ]. That being the definition of the Taylor series of the exponential function at x0=1 without taking account of the rest.</p>
<p>to do so I wrote this : </p>
<pre><code>sage: k, n, n0, epsilon = var('k, n, n0, epsilon')
sage: assume(n, 'integer')
sage: epsilon = 1e-1
sage: u(n) = 1/factorial(n)
sage: v(n) = sum(u(k), k, 0, n)
sage: n0 = solve(e - v(n) > epsilon, n)
sage: n0
</code></pre>
<p>And sage gives out : </p>
<pre><code>> [[e - sum(1/factorial(k), k, 0, n) - 0.1 > 0]]
</code></pre>
<p>The documentation says that to get an explicit solution we jut got to set the parameter explicit_solutions to True but I tried it and it doesn't work. Also I'm using the 8.1 version (it's the latest I found on the ubunru packages repository and I tried to download the 9.2 version but the archive was too voluminous (it's 14 GB and I didn't have enough memoiry space to extract it)</p>
<p>Is it possible to get an approximation of the solution in this case I don’t care for the result to be an approximation because I just need the integer part of it anyway.</p>
<p>Please help me I don’t really know if the problem is that the equation is “too complex” or maybe I’m just not using the sum function right.</p>
<p>Thank you in advance.</p>
https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?comment=54284#post-id-54284Thank you for your answer. I haven't thought about taking dirrectly the difference (that is sum_{i=n}^{\infty}\frac{1}{j!}) thank you for pointing that out. But I don't know how to implement that in sage : we can't implement sums that go up to infinity. But maybe with a function of two variables
u(n, m) = sum_{i=n}^{\m}\frac{1}{j!}
and take the limit of u when m approaches infinity for a certain n. Is there any other possible way?Wed, 18 Nov 2020 22:46:58 +0100https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?comment=54284#post-id-54284Comment by Emmanuel Charpentier for <p>Hello,</p>
<p>I started getting into sage a couple of days ago. To do so I’m following the handbook « Computational Mathematics with SageMath » and I came across something that I would like to have more details about but I didn’t find anything in the documentation.
So the handbook states that</p>
<blockquote>
<p>“In most cases, as soon as the
equation or system becomes too
complex, no explicit solution can be
found: </p>
</blockquote>
<pre><code>sage: solve(x^(1/x)==(1/x)^x, x)
> [(1/x)^x == x^(1/x)]
</code></pre>
<blockquote>
<p>However, this is not necessarily a limitation!
Indeed, a specificity of computer
algebra is the ability to manipulate
objects defined by equations, and in
particular to compute their
properties, without solving them
explicitly. Even better: in some
cases, the equation defining a
mathematical object is the best
algorithmic representation for it.”</p>
</blockquote>
<p>But it doesn’t say what they mean by an equation being “too complex”. And what does it mean for an equation to not have an explicit solution. Plus in some cases we want to have a numerical result (even if it’s an approximation). For exemple I tried finding from what n0 the Tyler series of the exponential function at x0=1 is in the interval [e-10^-3, e+10^-3] i.e.</p>
<p>∀ ε > 10⁻³ , n > n0 ⇒ | vn − e | < ε</p>
<p>vn being equal to the sum of the terms 1 / i! for i ∈ [ 0, n ]. That being the definition of the Taylor series of the exponential function at x0=1 without taking account of the rest.</p>
<p>to do so I wrote this : </p>
<pre><code>sage: k, n, n0, epsilon = var('k, n, n0, epsilon')
sage: assume(n, 'integer')
sage: epsilon = 1e-1
sage: u(n) = 1/factorial(n)
sage: v(n) = sum(u(k), k, 0, n)
sage: n0 = solve(e - v(n) > epsilon, n)
sage: n0
</code></pre>
<p>And sage gives out : </p>
<pre><code>> [[e - sum(1/factorial(k), k, 0, n) - 0.1 > 0]]
</code></pre>
<p>The documentation says that to get an explicit solution we jut got to set the parameter explicit_solutions to True but I tried it and it doesn't work. Also I'm using the 8.1 version (it's the latest I found on the ubunru packages repository and I tried to download the 9.2 version but the archive was too voluminous (it's 14 GB and I didn't have enough memoiry space to extract it)</p>
<p>Is it possible to get an approximation of the solution in this case I don’t care for the result to be an approximation because I just need the integer part of it anyway.</p>
<p>Please help me I don’t really know if the problem is that the equation is “too complex” or maybe I’m just not using the sum function right.</p>
<p>Thank you in advance.</p>
https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?comment=54273#post-id-54273Your proposed plan is not valid, since you would be using a (Sage-generated) numerical approximation of $e$ when evaluating your function. Thois kind of circular reasoning is generally frowned upon (unless you are building some induction or infinite descent...).
What you might do is to find some function of $x$ and $n$ whose value can be shown to be larger that $\displaystyle\left|\sum_{i=n}^{\infty}\frac{x^j}{j!}\right|$, then solve this function for $n$. This this done in any serious real analysis course , but not exactly trivial.It might help to remember that $\displaystyle\sum_{i=n}^{\infty}\left|\frac{x^j}{j!}\right|\ge\displaystyle\left|\sum_{i=n}^{\infty}\frac{x^j}{j!}\right|$
BTW, numerical solutions of (univariate) equations can be obtained via `find_root`. Read its online help.Wed, 18 Nov 2020 13:47:43 +0100https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?comment=54273#post-id-54273Answer by dsejas for <p>Hello,</p>
<p>I started getting into sage a couple of days ago. To do so I’m following the handbook « Computational Mathematics with SageMath » and I came across something that I would like to have more details about but I didn’t find anything in the documentation.
So the handbook states that</p>
<blockquote>
<p>“In most cases, as soon as the
equation or system becomes too
complex, no explicit solution can be
found: </p>
</blockquote>
<pre><code>sage: solve(x^(1/x)==(1/x)^x, x)
> [(1/x)^x == x^(1/x)]
</code></pre>
<blockquote>
<p>However, this is not necessarily a limitation!
Indeed, a specificity of computer
algebra is the ability to manipulate
objects defined by equations, and in
particular to compute their
properties, without solving them
explicitly. Even better: in some
cases, the equation defining a
mathematical object is the best
algorithmic representation for it.”</p>
</blockquote>
<p>But it doesn’t say what they mean by an equation being “too complex”. And what does it mean for an equation to not have an explicit solution. Plus in some cases we want to have a numerical result (even if it’s an approximation). For exemple I tried finding from what n0 the Tyler series of the exponential function at x0=1 is in the interval [e-10^-3, e+10^-3] i.e.</p>
<p>∀ ε > 10⁻³ , n > n0 ⇒ | vn − e | < ε</p>
<p>vn being equal to the sum of the terms 1 / i! for i ∈ [ 0, n ]. That being the definition of the Taylor series of the exponential function at x0=1 without taking account of the rest.</p>
<p>to do so I wrote this : </p>
<pre><code>sage: k, n, n0, epsilon = var('k, n, n0, epsilon')
sage: assume(n, 'integer')
sage: epsilon = 1e-1
sage: u(n) = 1/factorial(n)
sage: v(n) = sum(u(k), k, 0, n)
sage: n0 = solve(e - v(n) > epsilon, n)
sage: n0
</code></pre>
<p>And sage gives out : </p>
<pre><code>> [[e - sum(1/factorial(k), k, 0, n) - 0.1 > 0]]
</code></pre>
<p>The documentation says that to get an explicit solution we jut got to set the parameter explicit_solutions to True but I tried it and it doesn't work. Also I'm using the 8.1 version (it's the latest I found on the ubunru packages repository and I tried to download the 9.2 version but the archive was too voluminous (it's 14 GB and I didn't have enough memoiry space to extract it)</p>
<p>Is it possible to get an approximation of the solution in this case I don’t care for the result to be an approximation because I just need the integer part of it anyway.</p>
<p>Please help me I don’t really know if the problem is that the equation is “too complex” or maybe I’m just not using the sum function right.</p>
<p>Thank you in advance.</p>
https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?answer=54277#post-id-54277Hello, @aylimenz! This is a very deep question or an easy question, depending on what you are trying to learn from these words. Although I am not entitled to clarify exactly what the authors mean to convey with the text you cited, I can give you some points of view based on my personal experience. I will assume you (or anyone reading this answer) is a beginner, so this will be a long text.
1. The descriptions "too complex" and "not having an explicit solution" are not specific terms in this context; they are more like intuitive concepts. Basically, **an equation has no explicit solution** whenever Sage is unable to find a symbolic solution. For example, in this particular case, you can see that Sage has returned the equation itself, which basically is an admission of defeat. With that in mind, **an equation is too complex** is Sage cannot find an explicit solution.
2. But there exists another way of understanding "too complex." Consider the relative complexity of the equation in your question, compared to a polynomial equation. From the point of view of a human, this particular equation is more difficult to visualize/analyze/understand/solve. From this point of view, "too complex" can be understood as "too complicated," "too exotic," "way too elaborated," "too strange," "too uncommon." With practice, you will learn to recognize this kind of problems just by sight.
3. The previous point doesn't mean that Sage in incapable of solving equations more complicated than a polynomial; on the contrary, it can in fact solve extremely complicated equations and system. However, the more **exotic** your equation is, the more probable is that symbolic algorithm fail to solve it. As an example, consider a fifth-degree polynomial (for which I hope you know there is no explicit formula), inside an absolute, elevated to the sine of a third degree polynomial:
$$|3x^5 + 2x^4 - 5x^3 + 23x^2 - 15x - 56|^{\sin(63x^3-5x^2+3)}=0.$$
Although this is an extreme example, it clearly illustrates the point at hand ("too complex"). I believe you will agree that we cannot expect Sage or any other current software to give a meaningful symbolic solution to this one.
4. When Symbolic algorithms fall short, there are some things you can still try. For example, in the case of the equation on your question, you can try to find a numerical solution, as @Emmanuel Charpentier suggests. The `find_root()` function takes an equation and the extremes of an interval to search the solution as input arguments. In this case, you can try:
find_root(x^(1/x)==(1/x)^x, 0, 2)
in order to find a root in the interval $(0,2)$. This will be an approximation (or exact solution if you are lucky), but it is way better than the output of `solve()`. The interval to find the solution doesn't have to be a very good guess; you can try something more gross, like
find_root(x^(1/x)==(1/x)^x, 0, 10^4)
(Of course, the worse the interval guess, the harder for the algorithm to find the solution.) It is always a good idea to plot the functions to have a good idea of the interval:
p = plot(x^(1/x), 0, 5)
p += plot((1/x)^x, 0, 5)
p.show()
![image description](/upfiles/16057165802920095.png)
5. How do you know if that is the only solution? Why did I used the interval $[0,5]$ to plot? What else can you do in order to obtain additional information about this equation? You should use a combination of mathematical analysis and intuition in order to go further. Of course, Sage can help you with the part of mathematical analysis (by finding derivatives, by plotting functions, etc.), but the intuition is best developed through experience.
6. As the authors of the book indicate, when a **too complex** equation is presented, it is generally the case that the equation has a deeper meaning than the solution itself (hence the complexity). So being unable to find an **explicit solution** is not a problem, because you can do more profound and productive things with that equation than obtaining a simple solution. As in the previous point, obtaining meaningful information and studying the general behavior of a mathematical expression consists basically on doing some mathematical analysis, which Sage can help you with.
I hope this helps!Wed, 18 Nov 2020 17:40:42 +0100https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?answer=54277#post-id-54277Comment by aylimenz for <p>Hello, <a href="/users/29054/aylimenz/">@aylimenz</a>! This is a very deep question or an easy question, depending on what you are trying to learn from these words. Although I am not entitled to clarify exactly what the authors mean to convey with the text you cited, I can give you some points of view based on my personal experience. I will assume you (or anyone reading this answer) is a beginner, so this will be a long text.</p>
<ol>
<li><p>The descriptions "too complex" and "not having an explicit solution" are not specific terms in this context; they are more like intuitive concepts. Basically, <strong>an equation has no explicit solution</strong> whenever Sage is unable to find a symbolic solution. For example, in this particular case, you can see that Sage has returned the equation itself, which basically is an admission of defeat. With that in mind, <strong>an equation is too complex</strong> is Sage cannot find an explicit solution.</p></li>
<li><p>But there exists another way of understanding "too complex." Consider the relative complexity of the equation in your question, compared to a polynomial equation. From the point of view of a human, this particular equation is more difficult to visualize/analyze/understand/solve. From this point of view, "too complex" can be understood as "too complicated," "too exotic," "way too elaborated," "too strange," "too uncommon." With practice, you will learn to recognize this kind of problems just by sight.</p></li>
<li><p>The previous point doesn't mean that Sage in incapable of solving equations more complicated than a polynomial; on the contrary, it can in fact solve extremely complicated equations and system. However, the more <strong>exotic</strong> your equation is, the more probable is that symbolic algorithm fail to solve it. As an example, consider a fifth-degree polynomial (for which I hope you know there is no explicit formula), inside an absolute, elevated to the sine of a third degree polynomial:</p>
<p>$$|3x^5 + 2x^4 - 5x^3 + 23x^2 - 15x - 56|^{\sin(63x^3-5x^2+3)}=0.$$</p>
<p>Although this is an extreme example, it clearly illustrates the point at hand ("too complex"). I believe you will agree that we cannot expect Sage or any other current software to give a meaningful symbolic solution to this one.</p></li>
<li><p>When Symbolic algorithms fall short, there are some things you can still try. For example, in the case of the equation on your question, you can try to find a numerical solution, as <a href="/users/1336/emmanuel-charpentier/">@Emmanuel Charpentier</a> suggests. The <code>find_root()</code> function takes an equation and the extremes of an interval to search the solution as input arguments. In this case, you can try:</p>
<pre><code>find_root(x^(1/x)==(1/x)^x, 0, 2)
</code></pre>
<p>in order to find a root in the interval $(0,2)$. This will be an approximation (or exact solution if you are lucky), but it is way better than the output of <code>solve()</code>. The interval to find the solution doesn't have to be a very good guess; you can try something more gross, like</p>
<pre><code>find_root(x^(1/x)==(1/x)^x, 0, 10^4)
</code></pre>
<p>(Of course, the worse the interval guess, the harder for the algorithm to find the solution.) It is always a good idea to plot the functions to have a good idea of the interval:</p>
<pre><code>p = plot(x^(1/x), 0, 5)
p += plot((1/x)^x, 0, 5)
p.show()
</code></pre>
<p><img alt="image description" src="/upfiles/16057165802920095.png"></p></li>
<li><p>How do you know if that is the only solution? Why did I used the interval $[0,5]$ to plot? What else can you do in order to obtain additional information about this equation? You should use a combination of mathematical analysis and intuition in order to go further. Of course, Sage can help you with the part of mathematical analysis (by finding derivatives, by plotting functions, etc.), but the intuition is best developed through experience.</p></li>
<li><p>As the authors of the book indicate, when a <strong>too complex</strong> equation is presented, it is generally the case that the equation has a deeper meaning than the solution itself (hence the complexity). So being unable to find an <strong>explicit solution</strong> is not a problem, because you can do more profound and productive things with that equation than obtaining a simple solution. As in the previous point, obtaining meaningful information and studying the general behavior of a mathematical expression consists basically on doing some mathematical analysis, which Sage can help you with.</p></li>
</ol>
<p>I hope this helps!</p>
https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?comment=54285#post-id-54285Thank you for your answer. So I was confusing between symbolic and approximative sollution: I thought an approximative solution was obtained only by computing the results of the symbolic algorithmes whereas it is done by determining the variation of a function with numerical analysis methodes and the symbolic sollution is obtained by syntaxically manipulating the equation (formally). It's much clearer for me now. Thank you verry much ^^Wed, 18 Nov 2020 22:47:15 +0100https://ask.sagemath.org/question/54268/confusion-with-equations-with-no-explicit-solution/?comment=54285#post-id-54285