Help us understand the problem. What is going on with this article?

Jupyter Notebook上でSymPyの数式とLaTeXコマンドを組み合わせて表示

More than 1 year has passed since last update.

はじめに

Jupyter Notebook上でSymPyの数式とLaTeXコマンドを組み合わせて表示したい

import sympy

# おまじない
sympy.init_printing()

x = sympy.Symbol('x')
x**2

Screen Shot 2019-01-19 at 11.19.24.png

display

from IPython.display import display

for i in range(5):
    f = 1/x**i
    display(f)

Screen Shot 2019-01-19 at 11.22.00.png

SymPyからLaTeXへの変換

display(f)
sympy.latex(f)

Screen Shot 2019-01-19 at 11.22.17.png

 LaTeXの表示

from IPython.display import Math
display(Math(r'f_n(x) = \frac{1}{x^n}'))

Screen Shot 2019-01-19 at 11.31.16.png

 組み合わせる

for i in range(5):
    f = 1/x**i
    display(Math(r'f_{%d}(x) = %s' % (i, sympy.latex(f))))

Screen Shot 2019-01-19 at 11.32.34.png

おまけ

Screen Shot 2019-01-19 at 11.33.28.png
Screen Shot 2019-01-19 at 11.33.36.png
Screen Shot 2019-01-19 at 11.33.47.png
Screen Shot 2019-01-19 at 11.33.54.png

コード

https://nbviewer.jupyter.org/gist/ceptreee/63fef1b9fe3a6c06cb5e90808cbc4aa3

参考

https://gist.github.com/7shi/2a7181c7e432f8f08f12ed1ffce0abab

Is it possible to show print output as LaTeX in jupyter notebook?
https://stackoverflow.com/questions/48422762/is-it-possible-to-show-print-output-as-latex-in-jupyter-notebook

謝辞

@7shi さん、教えて頂きありがとうございました.

ceptree
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした