--- file_format: mystnb kernelspec: name: python3 hide-toc: true --- # 数式の整形表示 Jupyter Notebook, Visual Studio Code など、LaTeX による数式表示に対応した IPython のフロントエンド環境では Amplify SDK の数式は自動的に LaTeX で描画されます。 多項式、多項式配列、係数行列、制約条件、モデルは次のように数式として表示されます。 ## 変数配列 ```{code-cell} import amplify gen = amplify.VariableGenerator() q = gen.array("Binary", shape=(4, 4)) q ``` ## 多項式 ```{code-cell} p = 2 * (q[0] * q[1]).sum() p ``` ## 多項式配列 ```{code-cell} q[0:2] + q[2:] ``` ## 制約条件 ```{code-cell} c1 = amplify.one_hot(q, axis=1) c1 ``` ## 係数行列 ```{code-cell} import numpy as np m = gen.matrix("Binary", 4) m.quadratic = np.array([[1, 2, 3, 4], [0, 5, 6, 7], [0, 0, 8, 9], [0, 0, 0, 10]]) m.linear = np.array([1, 2, 3, 4]) c2 = amplify.one_hot(m.variable_array) m ``` ## モデル ```{code-cell} model = p + c1 model ``` ```{code-cell} model = m + c2 model ```