Hard-to-find tips on otherwise easy-to-do tasks involving everyday technology, with some advanced insight on history and culture thrown in. Brought to you by a master dabbler. T-S T-S's mission is to boost your competitiveness with every visit. This blog is committed to the elimination of the rat from the tree of evolution and the crust of the earth.
Friday, December 28, 2018
Hans Fangohr++ aka A Better Spyder Tutorial
He says, set IPython Console to do symbolic math (Tools > Preferences) and then you'll see cuter stuff.
He doesn't say :
Start a new console.
What happens if you run into ..
These commands were executed:
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
Warning: pylab (numpy and matplotlib) and symbolic math (sympy) are both
enabled at the same time. Some pylab functions are going to be overrided by
the sympy module (e.g. plot)
expr = (x + y) ** 3
Traceback (most recent call last):
File "<ipython-input-1-530ade24fb9f>", line 1, in <module>
expr = (x + y) ** 3
NameError: name 'x' is not defined
In short, what an ass!
Fortunately, we have some online angels :
https://github.com/spyder-ide/spyder/issues/3255
https://stackoverflow.com/questions/43915513/how-to-get-latex-style-output-from-sympy-in-spyder-ipython-console
https://github.com/nteract/hydrogen/issues/1119
I go to Start > Anaconda > Anaconda Prompt and then do
> conda install -c conda-forge miktex
Dat fix it? No!!
What did?
The commands that *IT* (see above) says *were* executed apparently weren't! So, you have to manually do :
x, y, z, t = symbols( 'x y z t')
only to find that
NameError: name 'symbols' is not defined
And then,
from sympy import symbols
That gets
expr = (x + y)**3
To NOT complain.
Now, when you do expr, you get the Unicode formatted pretty thing with the 3 really looking like a superscript. Not what you want obviously :)
So, what does work :
from sympy import init_printing
init_printing()
Now, when you do
expr
You get
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment