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, 25 Mar 2020 15:59:09 +0100Solving Quartic Equation with a Coefficient of $1$ MB Spacehttps://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/ I have an equation of $4$ degree (Quartic equation)and a coefficient of this equation takes $1$ **megabyte space** in a text file. I want to solve this Quartic equation using computer. If the the equation has rational solution, I want to **get rational solution with the exact numerator and the exact denominator (not the approximation)**. Is it possible?
There are are programming languages (e.g. MAGMA), computer algebra systems (e.g. PARI/GP, SageMath etc, here PARI is C library, can be called from a high-level language application ,for instance, written in C, C++, Pascal, Fortran, Perl, or Python).
If possible, then which programming language or computer algebra systems or library or softaware will be best to solve the Quartic equation as described above? What are the additional issues (configurations of RAM, Processor)?
Thu, 19 Mar 2020 14:54:00 +0100https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/Comment by rburing for <p>I have an equation of $4$ degree (Quartic equation)and a coefficient of this equation takes $1$ <strong>megabyte space</strong> in a text file. I want to solve this Quartic equation using computer. If the the equation has rational solution, I want to <strong>get rational solution with the exact numerator and the exact denominator (not the approximation)</strong>. Is it possible?</p>
<p>There are are programming languages (e.g. MAGMA), computer algebra systems (e.g. PARI/GP, SageMath etc, here PARI is C library, can be called from a high-level language application ,for instance, written in C, C++, Pascal, Fortran, Perl, or Python).</p>
<p>If possible, then which programming language or computer algebra systems or library or softaware will be best to solve the Quartic equation as described above? What are the additional issues (configurations of RAM, Processor)?</p>
https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50345#post-id-50345Upload the text file somewhere (a pastebin?). Also consider the rational root theorem.Tue, 24 Mar 2020 23:09:10 +0100https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50345#post-id-50345Comment by Sébastien for <p>I have an equation of $4$ degree (Quartic equation)and a coefficient of this equation takes $1$ <strong>megabyte space</strong> in a text file. I want to solve this Quartic equation using computer. If the the equation has rational solution, I want to <strong>get rational solution with the exact numerator and the exact denominator (not the approximation)</strong>. Is it possible?</p>
<p>There are are programming languages (e.g. MAGMA), computer algebra systems (e.g. PARI/GP, SageMath etc, here PARI is C library, can be called from a high-level language application ,for instance, written in C, C++, Pascal, Fortran, Perl, or Python).</p>
<p>If possible, then which programming language or computer algebra systems or library or softaware will be best to solve the Quartic equation as described above? What are the additional issues (configurations of RAM, Processor)?</p>
https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50353#post-id-50353If the file `a.txt` contains just the string `123456`, then you may create the corresponding integer in Sage by doing:
sage: !cat a.txt
123456
sage: with open('a.txt','r') as f:
....: a = Integer(f.read())
....:
sage: type(a)
<class 'sage.rings.integer.Integer'>
sage: a
123456Wed, 25 Mar 2020 15:59:09 +0100https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50353#post-id-50353Answer by Emmanuel Charpentier for <p>I have an equation of $4$ degree (Quartic equation)and a coefficient of this equation takes $1$ <strong>megabyte space</strong> in a text file. I want to solve this Quartic equation using computer. If the the equation has rational solution, I want to <strong>get rational solution with the exact numerator and the exact denominator (not the approximation)</strong>. Is it possible?</p>
<p>There are are programming languages (e.g. MAGMA), computer algebra systems (e.g. PARI/GP, SageMath etc, here PARI is C library, can be called from a high-level language application ,for instance, written in C, C++, Pascal, Fortran, Perl, or Python).</p>
<p>If possible, then which programming language or computer algebra systems or library or softaware will be best to solve the Quartic equation as described above? What are the additional issues (configurations of RAM, Processor)?</p>
https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?answer=50339#post-id-50339As long as you are able to express your giant coefficients in Sage form, that should be both pretty trivial and pretty pointless.
Pretty trivial:
sage: var("a,b,c,d,e")
(a, b, c, d, e)
sage: E=a*x^4+b*x^3+c*x^2+d*x+e==0
sage: %time S=solve(E,x)
CPU times: user 4.7 s, sys: 273 ms, total: 4.97 s
Wall time: 4.31 s
sage: len(S)
4
You can then `S2=S.subs({a:whatever, b:you, c:want, d:to, e:substitute})` to get your expressions.
Pretty pointless: with coonstant coefficuients, this explicit solution of the quartic doesn't `\LaTeX` on a single A4 portrait page. Unless your giant coefficients have very specialshape, simplifying "miraculously" the expressions of the roots, your result will be unusable *pe se*.
However, they can be manipulated by Sage for further processing. Wouldn't it be easier ti denote the (unexpressed, but knon existing) roots of your quartic by variables, and use that in the "further processing" ?
HTH,Tue, 24 Mar 2020 21:28:06 +0100https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?answer=50339#post-id-50339Comment by Emmanuel Charpentier for <p>As long as you are able to express your giant coefficients in Sage form, that should be both pretty trivial and pretty pointless.</p>
<p>Pretty trivial:</p>
<pre><code>sage: var("a,b,c,d,e")
(a, b, c, d, e)
sage: E=a*x^4+b*x^3+c*x^2+d*x+e==0
sage: %time S=solve(E,x)
CPU times: user 4.7 s, sys: 273 ms, total: 4.97 s
Wall time: 4.31 s
sage: len(S)
4
</code></pre>
<p>You can then <code>S2=S.subs({a:whatever, b:you, c:want, d:to, e:substitute})</code> to get your expressions.</p>
<p>Pretty pointless: with coonstant coefficuients, this explicit solution of the quartic doesn't <code>\LaTeX</code> on a single A4 portrait page. Unless your giant coefficients have very specialshape, simplifying "miraculously" the expressions of the roots, your result will be unusable <em>pe se</em>.</p>
<p>However, they can be manipulated by Sage for further processing. Wouldn't it be easier ti denote the (unexpressed, but knon existing) roots of your quartic by variables, and use that in the "further processing" ?</p>
<p>HTH,</p>
https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50346#post-id-50346Apparently, this attempt to answer has displeased someone, who didn't took the pain to explain why he/she was displeased. Too bad...Wed, 25 Mar 2020 00:01:10 +0100https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50346#post-id-50346Comment by Sébastien for <p>As long as you are able to express your giant coefficients in Sage form, that should be both pretty trivial and pretty pointless.</p>
<p>Pretty trivial:</p>
<pre><code>sage: var("a,b,c,d,e")
(a, b, c, d, e)
sage: E=a*x^4+b*x^3+c*x^2+d*x+e==0
sage: %time S=solve(E,x)
CPU times: user 4.7 s, sys: 273 ms, total: 4.97 s
Wall time: 4.31 s
sage: len(S)
4
</code></pre>
<p>You can then <code>S2=S.subs({a:whatever, b:you, c:want, d:to, e:substitute})</code> to get your expressions.</p>
<p>Pretty pointless: with coonstant coefficuients, this explicit solution of the quartic doesn't <code>\LaTeX</code> on a single A4 portrait page. Unless your giant coefficients have very specialshape, simplifying "miraculously" the expressions of the roots, your result will be unusable <em>pe se</em>.</p>
<p>However, they can be manipulated by Sage for further processing. Wouldn't it be easier ti denote the (unexpressed, but knon existing) roots of your quartic by variables, and use that in the "further processing" ?</p>
<p>HTH,</p>
https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50349#post-id-50349Sorry Emmanuel, it's me. Personally, I think it is not necessary to add judgements ("trivial", "pretty pointless") to an answer. Most probably, this is not trivial nor pointless for the person asking the question. If you remove those, I will remove my down vote.Wed, 25 Mar 2020 08:23:14 +0100https://ask.sagemath.org/question/50301/solving-quartic-equation-with-a-coefficient-of-1-mb-space/?comment=50349#post-id-50349