formatting fractions involving square roots

asked 2016-01-30 13:48:36 +0200

updated 2017-03-20 14:03:19 +0200

How can I tell sage that I want the result to be shown as $\frac{1}{\sqrt{3}}$ rather than $\frac13\sqrt3$ when I type show(1/sqrt(3))?

edit retag flag offensive close merge delete

Comments

1

Not really convenient but it gives the expected answer: show(sqrt(3).power(-1,hold=True)) .

ndomes gravatar imagendomes ( 2017-03-20 18:26:54 +0200 )edit

Thanks, that is at least something. While playing with this, I noticed that power? and power?? documentation does not mention the hold keyword at all.

Searching for hold=True I just found https://ask.sagemath.org/question/757..., which makes this question a duplicate.

Björn gravatar imageBjörn ( 2017-03-25 01:08:34 +0200 )edit
1

You have to look for power as a method of an expression, for example: x.power? or pi.power??

ndomes gravatar imagendomes ( 2017-03-26 00:33:58 +0200 )edit