# Messy typesetting problem

If I enter the followng in a sage notebook, the typeset output is correct but for h(r) is unreadable, is there someway to coerce sage to output a reasonable representation?

The desired expression is $$h(r) = {1\over{r^2 \sqrt{ \frac{1}{b^2} - (1 - \frac{d}{r}) \frac{1}{r^2}}}}$$

f(r) looks good, g(r) is poor and confusing, h(r) is unreadable.

var ('r, b, d')
f(r) = r^2 * sqrt(1/b^2)
print(f)
f.show()
g(r) = r^2 * sqrt(1/b^2 - 1)
print(g)
g.show()
h(r) = 1 / (r^2 * sqrt (1/b^2 - (1 - d/r)*1/r^2))
print (h)
h.show()

edit retag close merge delete

Sort by » oldest newest most voted

I don't think there's any real way to do it now (ticket 10035 could work, if it is ever implemented). If you know the LaTeX code, however, you can do

show(LatexExpr(r'h(r) = {1\over{r^2 \sqrt{ \frac{1}{b^2} - (1 - \frac{d}{r}) \frac{1}{r^2}}}}'))


in the terminal, or

html(r'$h(r) = {1\over{r^2 \sqrt{ \frac{1}{b^2} - (1 - \frac{d}{r}) \frac{1}{r^2}}}}$')


in the notebook.

more

Even using things like h(r) = 1/((r^2).mul(sqrt (1/b^2 - (1 - d/r).mul(1/r^2,hold=True)),hold=True)) doesn't really help (we've had hold, just not hold contexts, for quite a while now) because the symbolics automatically reorder things according to its own ordering. I'm not sure how to get it to print in the order one wants (e.g., with the r^2 first).