16
$\begingroup$

I guess all computer algebra systems have command line interfaces which render formula as 2D monospace "ascii art". But the only standalone tool to render TeX to 2D I know is tex2mail (comes with PARI/GP).

Are there other standalone programs or libraries for that task, preferably making advantage of various Unicode symbols? Or maybe there is a CAS capable for that.

What I'm talking about:

FriCAS:

            ┌──┐
       x   \│%A
     ┌┐  %e
     │   ─────── d%A
    └┘       2
           %A

tex2mail:

         +-+                              
     ,- \|x   2                              
     | e    /x    dx                              
    -'                 

Maxima:

     /   sqrt(x)
     [ %e
     I --------- dx
     ]     2
     /    x

Those are meant to represent:

$$\int \frac{e^{\sqrt x}}{x^2} \, dx$$

$\endgroup$
  • 3
    $\begingroup$ I have to ask... why?? $\endgroup$ – Asaf Karagila May 24 '12 at 17:45
  • 2
    $\begingroup$ Because it's BOSS! $\endgroup$ – Thomas Eding May 24 '12 at 18:02
  • 1
    $\begingroup$ @AsafKaragila mostly to output a formula to console. $\endgroup$ – Yrogirg May 24 '12 at 19:09
  • 1
    $\begingroup$ I see. Thank you for the answer. If I had to choose between the above examples or a very complicated $\TeX$ code, I'd choose the $\TeX$. That's just me, though. $\endgroup$ – Asaf Karagila May 24 '12 at 19:14
  • 1
    $\begingroup$ Good lord. That is hideous. If you're stuck in ASCII, it's a million times better to write "the indefinite integral of (exp(root x))/(x^2))dx", or something like that. $\endgroup$ – Newb Apr 15 '15 at 6:55
9
$\begingroup$

You can use this Web Application: Diagon

  • No need to download anything
  • Supports ASCII and Unicode.
  • Supports other kind of ASCII art diagrams.

Examples:

sum(i^2, i=0, n) = n^3/2+n^2/2+n/6

output (Unicode)

  n                   
 ___        3    2    
 ╲     2   n    n    n
 ╱    i  = ── + ── + ─
 ‾‾‾        2    2   6
i = 0                 

output (ASCII): 

  n                   
 ===        3    2    
 \     2   n    n    n
 /    i  = -- + -- + -
 ===        2    2   6
i = 0                 

mult(i^2, i=1, n) = (mult(i, i=1, n))^2

                    2  
   n        ⎛  n    ⎞   
 ━┳┳━   2   ⎜━┳┳━   ⎟   
  ┃┃   i  = ⎜ ┃┃   i⎟   
 i = 1      ⎝i = 1  ⎠                         

sqrt(1 + sqrt(1 + x/2))

     _____________
    ╱        _____
   ╱        ╱    x
  ╱        ╱ 1 + ─
╲╱   1 + ╲╱      2

[1,2; 3,4] * [x; y] = [1*x+2*y; 3*x+4*y]

⎛1 2⎞   ⎛x⎞   ⎛1 ⋅ x + 2 ⋅ y⎞
⎜   ⎟ ⋅ ⎜ ⎟ = ⎜             ⎟
⎝3 4⎠   ⎝y⎠   ⎝3 ⋅ x + 4 ⋅ y⎠

int(x^2/2 * dx ,0 ,1) = n^3/6

1             
⌠  2         3
⎮ x         n 
⎮ ── ⋅ dx = ──
⌡  2         6
0             

phi = 1 + 1/(1+1/(1+1/(1+1/(1+...))))

                 1         
φ = 1 + ───────────────────
                   1       
        1 + ───────────────
                     1     
            1 + ───────────
                       1   
                1 + ───────
                    1 + ...

Disclaimer: I am the author.

It is an open source project under the MIT license.

$\endgroup$
8
$\begingroup$

I've edited a bit tex2mail to use Unicode for output. Here are the results:

                                      ┌──────┐             
          ┌─┐  3                   4  │     2     6      4             
     ⌠   \│a  x         ┌─┐     3 x  \│1 - x   + x  - 3 x              
     ⎮  ───────── dx = \│a  ──────────────────────────────────         
     ⌡   ┌──────┐                          ┌──────┐         
         │     2            ⎛    2      ⎞  │     2      2         
        \│1 - x             ⎝ 3 x  - 12 ⎠ \│1 - x   - 9x  + 12         

                                 ⎡     1 ⎤n                        
                   lim           ⎢ 1 + ─ ⎥  = e                        
                       n  --> oo ⎣     n ⎦                        

                                     n       n                   
               ⌠1  x     ──┐oo   ⌠1 x (log x)                    
               ⎮  x dx = >       ⎮  ──────────   dx.                   
               ⌡0        ──┘n=0  ⌡0     n!                       


┬─┬oo ⎛   1  ⎞   ⎛ ┬─┬oo   1   ⎞-1           1            1     6 
│ │   ⎜ 1-── ⎟ = ⎜ │ │   ───── ⎟   = ───────────────── = ──── = ──  ≈ 61%
┴ ┴p  ⎜    2 ⎟   ⎜ ┴ ┴p     -2 ⎟         1    1          ζ(2)    2
      ⎝   p  ⎠   ⎝       1-p   ⎠     1 + ── + ── + ∙∙∙          π 
                                          2    2
                                         2    3 

The look depends hugely on the fonts and the browser. If you are interested in the script here is the link.

$\endgroup$
  • 2
    $\begingroup$ As long as you're using Unicode, why not also replace oo with , --> with , and so on? You might also consider using Unicode's sub- and superscripted characters whenever possible to save vertical space. $\endgroup$ – Rahul Jun 9 '12 at 20:22
  • 1
    $\begingroup$ @RahulNarain Well, --> should be ⟶, not →. However the space occupied by ⟶ depends on the font and the renderer, which can ruin the formatting. Same story with many others characters, even with ⊗. For my taste is ∞ is too small compared to oo. Well, it is ubelievebly easy to make such substitutions. If one wants he may do it, however the results might not be good. $\endgroup$ – Yrogirg Jun 9 '12 at 20:24
  • $\begingroup$ @RahulNarain As for the sub and superscripts, I just think that they are small and poorly readable. Anyway, implementing this is beyond my Perl skills. $\endgroup$ – Yrogirg Jun 9 '12 at 20:32
8
$\begingroup$

At this site one can get following:


Input:

int(int(int(psi^2, x = -inf .. inf), y = -inf .. inf), z = -inf .. inf) = 1

Output:

   oo    oo    oo
  /     /     /
 |     |     |    2
 |     |     | psi  dx dy dz = 1
 |     |     |
/     /     /
 -oo   -oo   -oo

Input:

sqrt(e) = 1+1/(1+1/(1+1/(1+1/(5+1/(1+1/(1+1/(9+1/(1+1/(1+...)))))))))

Output:

  _                          1
\/e = 1 + ---------------------------------------
                               1
          1 + -----------------------------------
                                 1
              1 + -------------------------------
                                   1
                  1 + ---------------------------
                                     1
                      5 + -----------------------
                                       1
                          1 + -------------------
                                         1
                              1 + ---------------
                                           1
                                  9 + -----------
                                             1
                                      1 + -------
                                          1 + ...

Input:

e^x = 1 + x + x^2/2! + x^3/3! + x^4/4! + ... = 1 + sum(x^n/n!, n = 1 .. inf)

Output:

                                       oo
              2    3    4             =====  n
 x           x    x    x              \     x
e  = 1 + x + -- + -- + -- + ... = 1 +  >    --
             2!   3!   4!             /     n!
                                      =====
                                      n = 1

Input:

(1/4)pisqrt(2) = sum((-1)^(k+1)/(4*k + 1) + (-1)^(k+1)/(4*k - 3), k = 1 .. inf) = 1 + 1/3 - 1/5 - 1/7 + 1/9 + 1/11 - ...

Output:

            oo
           ===== /    k + 1       k + 1\
1 __   _   \     |(-1)        (-1)     |       1   1   1   1    1
- || \/2 =  >    |--------- + ---------| = 1 + - - - - - + - + -- - ...
4          /     \ 4 k + 1     4 k - 3 /       3   5   7   9   11
           =====
           k = 1

Input:

sin(a)/a = cos(a/2) * cos(a/4) * cos(a/8) * cos(a/16) * ... = prod(cos(a/2^n), n = 1 .. inf)

Output:

                                        oo
                                       =====
sin a       a     a     a      a        | |       a
----- = cos - cos - cos - cos -- ... =  | |  cos --
  a         2     4     8     16        | |       n
                                        | |      2
                                       n = 1

Input:

lim(1/x^2 - (cos(x)/x)^2, x -> inf) = 1

Output:

        /            2\
        | 1   /cos x\ |
 lim    |-- - |-----| | = 1
        | 2   \  x  / |
x -> oo \x            /

Finally,

$$\int \frac{e^{\sqrt x}}{x^2} \, dx$$

is represented as

Input:

int(e^sqrt(x)/x^2 , x)

Output:

  /
 |    _
 |  \/x
 | e
 | ---- dx
 |   2
 |  x
 |
/
$\endgroup$
4
$\begingroup$

If you are on *NIX platforms you can use asciitex.

There is also aamath which does a great job in traslating the equation to ascii text files.

If you don't want to install anything locally take a look at http://ascii.gallery/matheq which I believe is a web wrapper over aamath.

$\endgroup$
  • $\begingroup$ I noticed ascii.gallery is moved. Use the new url textart.io/matheq $\endgroup$ – dors Oct 29 '18 at 20:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.