Printing LaTeX

## Description

Here, we will have Sage print one of the solutions to the following quartic function as LaTeX output:

(1)\begin{equation} x^4 + x^3 + x^2 + x - 4 = 0 \end{equation}

This is done using the `latex()` command.

## Sage Cell

When we run the output through LaTeX, we get:

(2)\begin{align} x = \frac{1}{3} \cdot 5^{\frac{1}{3}} {\left(3 \, \sqrt{3} \sqrt{2} - 7\right)}^{\frac{1}{3}} - \frac{5^{\frac{2}{3}}}{3 \, {\left(3 \, \sqrt{3} \sqrt{2} - 7\right)}^{\frac{1}{3}}} - \frac{2}{3} \end{align}

This is not perfectly simplified, of course, but it is far more readable than Sage's normal output, and easier to simplify by hand.

#### Code

```
f(x) = x^4 + x^3 + x^2 + x - 4
answers = solve(f(x) == 0, x)
latex(answers[2])
```

## Options

None

## Tags

Primary Tags: Sage: Formatting output

Secondary Tags:

## Related Cells

## Attribute

Permalink:

Author:

Date: 07 Mar 2019 21:48

Submitted by: Zane Corbiere