# What is the difference between show() and view() in sage?

What is the difference between show() and view() in sage?

A=matrix([v1,v2,v3]);show(A); view(A)

looks like the same... is there any difference between these two?

edit retag close merge delete

Sort by » oldest newest most voted

As said by their respective documentation (type show? and view?), show is an alias for pretty_print which choses the "best" output supported by the user interface, and while view computes a LaTeX representation of the object (and possibly compiles the result from mathjax in the notebook or LaTeX from the command line), hence it is more specific.

For your matrix, you can see a difference if you use Sage command line:

sage: show(A);
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr}
0 & 1 & 0 \\
0 & 1 & 0 \\
2 & \frac{1}{2} & 0
\end{array}\right)

sage: view(A)
# this will open a pdf viewer with the matrix inside a pdf, created by LaTeX.


You can also see a difference as follows:

sage: G = graphs.PetersenGraph()
sage: show(G)
# Launch png viewer, not created by LaTeX
sage: view(G)
# show a graph drawn by LaTeX inside a pdf viewer

more