Dealing with equations in the absence of a good equation editor is messy and unpleasant. For example, if I wanted to express an integral and its solution, it might look something like this:
Integral[x^3 e^(-m x^2 b /2), dx] = -((2 + bmx^2)/(b^2*e^((bmx^2)/2)*m^2))
At integrals.wolfram.com, this is called "input form." No one likes to see an equation in "input form." The ideal way of visualizing this equation would be:
(Wolfram calls this "traditional form")
For this codegolf, write a program that will take some equation in "input form" as input and visualize that equation in an ascii representation of "traditional form." So, for this example we might get something like this:
/\ 3
| x
| ------------ dx =
| 2
\/ (m x b)/2
e
2
2 + b m x
-(-----------------)
2
2 (b m x )/2 2
b e m
Requirements:
- Don't shuffle, simplify or rearrange the input in any way. Render it in exactly the same form it was described by the input.
- Support the four basic mathematical operations (+,-,*,/). When not multiplying two adjacent numbers the * symbol is implied and should be omitted.
- Support for integration (as shown in the example above) is not required. Being able to support input with functions like Integrate[...] or Sqrt[...] is a bonus.
- Support powers as shown in the example above (the nth root can be modeled by raising to the 1/nth power).
- Redundant parenthesis (like those around the denomentator and numerator of the large fraction in the example above) should be omitted.
- The expression in the denominator and numerator of a fraction should be centered above and below the horizontal division line.
- You can choose whether or not to start a new line after an equal sign. In the example above, a new line is started.
- Order of operations must be exactly the same in the output as it is in the input.
Some examples of input and associated output for testing your solution:
Input:
1/2 + 1/3 + 1/4
Output:
1 1 1
- + - + -
2 3 4
Input:
3x^2 / 2 + x^3^3
Output:
2 3
3 x 3
---- + x
2
Input:
(2 / x) / (5 / 4^2)
Output:
2
-
x
--
5
--
2
4
Input:
(3x^2)^(1/2)
Output:
2 1/2
(3 x )