Lesson goal: Displaying math

Previous: Speaking text | Home | Next: How programs flow

Math on the web can be pretty ugly. Looking at things like 3/2x^2+5/sin(x) makes us cringe. We'd much rather see $\frac{3}{2}x^2+\frac{5}{\sin(x)}$ instead.

We've developed a function called print_math that will take an "ugly" mathematical expression and make it look nice.

print_math("ugly expression")
Move the mouse over a dotted box for more information.

Now you try. Try programming in some expressions, and make them look nice.

Type your code here:

See your results here:

This example will nicely print x^2 x^3 like $x^2x^3$.

Other things to try:

  • Grouping exponents. Do x^{23} not x^23 to get $x^{23}$.
  • Fractions. Do %frac{numerator}{denominator} to get nice fractions. So, %frac{a+b}{x^2-1} will render $\frac{a+b}{x^2-1}$.
  • Square roots. Do %sqrt{radicand} to get a square root sign. So %sqrt{x^2+1} will render $\sqrt{x^2+1}$.

Here is a share link to your code:


Here's your code:


