If you run the init_printing() function in the terminal it will enable pretty printing. Or you can use the isympy script which does this automatically.
Aaron Meurer On Thu, Mar 19, 2020 at 6:11 PM David Collett <[email protected]> wrote: > > Thanks very much for taking the time to help. > > I made the changes you suggested, and it works. > > Yes, I would prefer it to print the actual continued fraction rather than a > simple fraction, but I can't figure it out. > > Also, in the SymPy Live Shell, the output of the continued fraction is > beautifully displayed. I realize that this same output isn't possible in the > Terminal. But is there any way to output nice-looking math formulas such as > this? > > Thanks again for your help. > > David > > ----- > > On Thursday, March 19, 2020 at 1:47:30 PM UTC-7, David Collett wrote: >> >> Hi, everyone. I'm new to python and to sympy. >> >> On the sympy documentation site >> (https://docs.sympy.org/latest/tutorial/simplification.html#example-continued-fractions), >> near the end is the following script: >> >> def list_to_frac(l): expr = Integer(0) for i in reversed(l[1:]): expr += i >> expr = 1/expr return l[0] + expr >> print(list_to_frac([x, y, z])) >> __________ >> >> The output they show (in the SymPy Live Shell) is: >> >> x + (1 / (y + 1/z)) >> >> However, when I copied this to a text file and run it from the terminal >> (MacOS, Python 3.x), I get the following error: >> >> NameError: name 'x' is not defined >> >> >> How do I solve this problem? >> >> >> (If instead of x, y, z, I substitute numbers, such as >> list_to_frac([1,1,3,1,1,5,1,1,7]) then a fraction is returned (1463/822) in >> this case. >> >> >> >> Thanks for your help. >> >> >> David >> >> >> >> >> 𝑥+1𝑦+1𝑧 > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/2f902f4d-5b29-49d6-a5a1-be40cc1c8a91%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6Kp0OUfyQdjvi-SaeWkGVPEUq1GB-0mJcrM%2B85xq4ofaA%40mail.gmail.com.
