3

As I am using Mathematica a lot I got the idea to write a small and free CAS which just exposes a very small subset of necessary functions and packages to be used and I want to present the results in an appropriate way to the user like Mathematica does (ignore the Facebook logo in the background :D ):

Mathematica's Output

My first idea was to create LaTeX code in the background and to pdflatex the source and include the PDF then in the view... however this seems way to much overkill! I want to write this CAS either in C++ or C# and I want to know if there are any recommended solutions to output nice formula like that.

My first thought was a "real-time formula editing view" but it would be ok to have an input box to enter the commands and formulas and the upper view just to be uneditable output.

Michael J. Barber
  • 24,518
  • 9
  • 68
  • 88
Christian Ivicevic
  • 10,071
  • 7
  • 39
  • 74
  • 2
    I may be off, but if I'd want to write my own CAS, the presentation layer would not be among my main initial concerns. You can always make it more sophisticated later, or you could even generate Mathematica boxed expressions from your CAS expressions, and use Mathematica FE for the time being. And I probably wouldn't choose either of the languages you mentioned as an implementation language, but would rather pick some modern fast functional language with good FFI, like OCaml for instance (or LISP). Just my 2 cents. – Leonid Shifrin Oct 12 '11 at 13:20
  • 3
    Not to curb your enthusiasm but there are already several open source CAS programs. [Maxima](http://maxima.sourceforge.net/) and its GUI enriched pendant [wxmaxima](http://andrejv.github.com/wxmaxima/), and [Sage](http://www.sagemath.org/) come to mind. Projects like that are usually not one-man affairs and I feel you might be underestimating the effort involved. Additionally, I wouldn't start with thinking about how to achieve the nicest possible output, but with doing the core CAS stuff first. – Sjoerd C. de Vries Oct 12 '11 at 13:12
  • I know, however i already have implemented some core components. My goal is just to practise my skills and to implement the algorithms we learn in our CAS lecture and i want to implement only a few things to get the "taste" of this :) – Christian Ivicevic Oct 12 '11 at 13:18
  • Hi Christian. [Symbolism](https://github.com/dharmatech/Symbolism) is a library for automatic simplification of algebraic expressions in C#. It can be used as the core of a CAS. – dharmatech Apr 01 '13 at 09:13

2 Answers2

5

A few ways come to my mind.

  1. Use LaTeX behind the scenes to typeset equations, as you say. Again, Cadabra does this.
  2. Use TeXmacs as the front end. Cadabra does this.
  3. Use MathJax. This is a javascript framework which renders TeX equations to images or MathML. It's very easy to use it if you have a HTML view in your UI toolkit. MathJax is used in the sister site MathOverflow, for example.

I find the route 3 is the most attractive.

Community
  • 1
  • 1
Yuji
  • 34,103
  • 3
  • 70
  • 88
  • +1 MathJax seems to be the most convenient solution for such a small project! I will have a look whether i will either show images or htmls but very cool solution. – Christian Ivicevic Oct 12 '11 at 14:24
  • TeXMacs would probably be the least amount of work. There's already a [standard interface for external programs](http://www.texmacs.org/tmweb/manual/webman-interface.en.html) which has been used by [many CAS](http://www.texmacs.org/tmweb/plugins/cas.en.html). Then you can concentrate on writing your CAS. – Simon Oct 12 '11 at 21:31
2

For calling LaTeX in the background, don't use pdflatex, but use the non-PDF latex to produce a DVI file, and convert it then to PNG with dvipng.

Have a look at the preview package or the standalone class to get the output in the right size (i.e. only the formula, not a whole page).

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210