Discussion:
Converting result to ASCII-art
(too old to reply)
DJ Craig
2005-05-11 06:37:28 UTC
Permalink
When running MathKernel from command line in OS X, it shows expressions
kind of like ASCII-art. I have a very long equation that I need to
convert to ASCII, but when doing this the way I normally do, using
Terminal and copying and pasting, it comes out looking like a mess,
because it does too much line wrapping. What I am trying to display is
the result of:
Solve[a x^4+b x^3+c x+d==0,x]
I've tried displaying this in command line with and without MatrixForm.
Is there some other form that I should try?
What I really need is some way that I can send this result to someone
(who doesn't have Mathematica, MathReader, or any type of MathML
reader), so that they can copy and paste out of it. A PDF would be
fine, but when I use Print to create a PDF, the PDF that it creates
can't be read by either Preview or Acrobat.
dh
2005-05-12 06:35:50 UTC
Permalink
Hi,
it all depends what the receiver wants to do with the formula.
A simple solution would be:
Solve[a x^4 + b x^3 + c x + d == 0, x] // InputForm
This can be copied and pasted without problems.
If he wants C code you may also try:
Solve[a x^4 + b x^3 + c x + d == 0, x] // CForm
There is also FortranForm.

Homever, if the graphic, 2D form is needed, copy and paste it into a
word document.

SIncerely, Daniel
Post by DJ Craig
When running MathKernel from command line in OS X, it shows expressions
kind of like ASCII-art. I have a very long equation that I need to
convert to ASCII, but when doing this the way I normally do, using
Terminal and copying and pasting, it comes out looking like a mess,
because it does too much line wrapping. What I am trying to display is
Solve[a x^4+b x^3+c x+d==0,x]
I've tried displaying this in command line with and without MatrixForm.
Is there some other form that I should try?
What I really need is some way that I can send this result to someone
(who doesn't have Mathematica, MathReader, or any type of MathML
reader), so that they can copy and paste out of it. A PDF would be
fine, but when I use Print to create a PDF, the PDF that it creates
can't be read by either Preview or Acrobat.
yehuda ben-shimol
2005-05-12 07:53:27 UTC
Permalink
Duid you tryTeXForm[]?
also printing into a postscript file can later be converted to a pdf
file, quite easily.
The following is a TexForm output of the required result. you may send
it and the other side copy it into a latex file. There is no line
wrapping of any kind here
__________________________________________________________
\left\{-\frac{b}{4 a}-\frac{1}{2} \sqrt{\frac{b^2}{4
a^2}+\frac{\sqrt[3]{27 d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a
c^2\right)^2-4 (12 a d-3 b c)^3}}}{3 \sqrt[3]{2}
a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27
d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}}-\frac{1}{2}
\sqrt{\frac{b^2}{2 a^2}-\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}-\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27
d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b
c)^3}}}-\frac{-\frac{b^3}{a^3}-\frac{8 c}{a}}{4
\sqrt{\frac{b^2}{4 a^2}+\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d
b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3
b c)^3}}}}}},-\frac{b}{4 a}-\frac{1}{2} \sqrt{\frac{b^2}{4
a^2}+\frac{\sqrt[3]{27 d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a
c^2\right)^2-4 (12 a d-3 b c)^3}}}{3 \sqrt[3]{2}
a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27
d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}}+\frac{1}{2}
\sqrt{\frac{b^2}{2 a^2}-\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}-\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27
d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b
c)^3}}}-\frac{-\frac{b^3}{a^3}-\frac{8 c}{a}}{4
\sqrt{\frac{b^2}{4 a^2}+\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d
b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3
b c)^3}}}}}},-\frac{b}{4 a}+\frac{1}{2} \sqrt{\frac{b^2}{4
a^2}+\frac{\sqrt[3]{27 d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a
c^2\right)^2-4 (12 a d-3 b c)^3}}}{3 \sqrt[3]{2}
a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27
d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}}-\frac{1}{2}
\sqrt{\frac{b^2}{2 a^2}-\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}-\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27
d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b
c)^3}}}+\frac{-\frac{b^3}{a^3}-\frac{8 c}{a}}{4
\sqrt{\frac{b^2}{4 a^2}+\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d
b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3
b c)^3}}}}}},-\frac{b}{4 a}+\frac{1}{2} \sqrt{\frac{b^2}{4
a^2}+\frac{\sqrt[3]{27 d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a
c^2\right)^2-4 (12 a d-3 b c)^3}}}{3 \sqrt[3]{2}
a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27
d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}}+\frac{1}{2}
\sqrt{\frac{b^2}{2 a^2}-\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}-\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27
d b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b
c)^3}}}+\frac{-\frac{b^3}{a^3}-\frac{8 c}{a}}{4
\sqrt{\frac{b^2}{4 a^2}+\frac{\sqrt[3]{27 d b^2+27 a
c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3 b c)^3}}}{3
\sqrt[3]{2} a}+\frac{\sqrt[3]{2} (4 a d-b c)}{a \sqrt[3]{27 d
b^2+27 a c^2+\sqrt{\left(27 d b^2+27 a c^2\right)^2-4 (12 a d-3
b c)^3}}}}}}\right\}
___________________________________________________________________
yehuda
yehuda
Post by DJ Craig
When running MathKernel from command line in OS X, it shows expressions
kind of like ASCII-art. I have a very long equation that I need to
convert to ASCII, but when doing this the way I normally do, using
Terminal and copying and pasting, it comes out looking like a mess,
because it does too much line wrapping. What I am trying to display is
Solve[a x^4+b x^3+c x+d==0,x]
I've tried displaying this in command line with and without MatrixForm.
Is there some other form that I should try?
What I really need is some way that I can send this result to someone
(who doesn't have Mathematica, MathReader, or any type of MathML
reader), so that they can copy and paste out of it. A PDF would be
fine, but when I use Print to create a PDF, the PDF that it creates
can't be read by either Preview or Acrobat.
Paul Abbott
2005-05-13 02:59:20 UTC
Permalink
Post by DJ Craig
When running MathKernel from command line in OS X, it shows expressions
kind of like ASCII-art. I have a very long equation that I need to
convert to ASCII, but when doing this the way I normally do, using
Terminal and copying and pasting, it comes out looking like a mess,
because it does too much line wrapping. What I am trying to display is
Solve[a x^4+b x^3+c x+d==0,x]
Why do they need the solution in radicals to a particular quartic? Are
they really going to try to use this code to compute the (numerical)
solutions to this quartic? If so they will encounter a number of
problems (see Ins and Outs in The Mathematica Journal 9-3):

[1] In general, radical formulations are prone to numeric problems.
Mathematica Root objects, e.g,

Root[Function[x, a x^4+b x^3+c x+d], 1]

do not have this liability.

[2] For certain parameters, the expression involving radicals may
involve I, even when the root is real. This means that numeric
evaluation will give small imaginary part.

In other words, the radical expression is likely to be useless for any
practical purpose. In fact, you can avoid it arising by setting

SetOptions[Roots, Cubics -> False, Quartics -> False]
Post by DJ Craig
What I really need is some way that I can send this result to someone
(who doesn't have Mathematica, MathReader, or any type of MathML
reader), so that they can copy and paste out of it.
MathReader is freely available.
Post by DJ Craig
when I use Print to create a PDF, the PDF that it creates
can't be read by either Preview or Acrobat.
That's strange.

Cheers,
Paul
--
Paul Abbott Phone: +61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul
http://InternationalMathematicaSymposium.org/IMS2005/
Continue reading on narkive:
Loading...