0
0

「sympyのMathML」を調べました。ChatGPT先生に、変換をみてもらいました。

Last updated at Posted at 2023-09-20

DOC

MathML<

1 と 1+1

入力

from sympy import *
print_mathml( 1 ,printer='presentation')
print_mathml( 1 )
print_mathml("1",printer='presentation')
print_mathml("1")                       
print_mathml( 1+1 ,printer='presentation')
print_mathml( 1+1)
print_mathml("1+1",printer='presentation')
print_mathml("1+1")

出力

<mn>1</mn>

<cn>1</cn>

<mn>1</mn>

<cn>1</cn>

<mn>2</mn>

<cn>2</cn>

<mn>2</mn>

<cn>2</cn>

有理数 と "有理数"

文字列です。

入力:

from sympy import *
print_mathml(有理数,printer='presentation')
print_mathml(有理数 )

出力(エラー):

...NameError: name '有理数' is not defined

入力:

from sympy import *
print_mathml("有理数",printer='presentation')
print_mathml("有理数" )

出力:

<mi>有理数</mi>

<ci>有理数</ci>

Integrate(x**2*log(x),(x,1,E)) 

・オリジナル
2023 産業医科大学 医学部MathJax【3】< 大学入試数学問題集成 様
https://mathexamtest.web.fc2.com/2023/202316025/2023160250100mj.html#top-0115

・wolframalphaで
https://ja.wolframalpha.com/input?i=integrate%28x**2*log%28x%29%2C%28x%2C1%2CE%29%29
定積分= 1/9 (1 + 2 e^3)≈4.5746

・積分(計算)する・しない。  
 なんのため、積分関数が2種類(integral,Integrate)あるか、今回わかりました。
 止めて!!!でした

入力:

from sympy import *
var('x',real=True)
f=Integral(x**2*log(x),(x,1,E))
print       (f)
pprint      (f)
print_mathml(f,printer='presentation')

・出力(改行追加しています。切り離しをしました。)
・SymPy Live Shell の結果をコピーする時は、 全選択後,コピーです。

Integral(x**2*log(x), (x, 1, E))

ℯ             
⌠             
⎮  2          
⎮ x ⋅log(x) dx
⌡             
1             

ここで、切り離しをしました。

<mrow>
        <msubsup>
                <mo>&#x222B;</mo>
                <mn>1</mn>
                <mi>&ExponentialE;</mi>
        </msubsup>
        <mrow>
                <msup>
                        <mi>x</mi>
                        <mn>2</mn>
                </msup>
                <mo>&InvisibleTimes;</mo>
                <mrow>
                        <mi>log</mi>
                        <mfenced>
                                <mi>x</mi>
                        </mfenced>
                </mrow>
        </mrow>
        <mo>&dd;</mo>
        <mi>x</mi>
</mrow>

(以下、余計な事をChatGPT-3.5先生にお願いしました。)

mathml様式の計算です。

入力1(テキスト):できました。

次の積分を計算しなさい。
integrate(x**2*log(x),(x,1,E))

出力:

与えられた積分を計算するために、SymPyを使用します。SymPyはPythonの数式処理ライブラリです。..
...以下がコードの例です:

出力:
コード(表示の省略)をSymPy Live Shellで計算しました。

# 結果を表示します
print(result)
1/9 + 2*exp(3)/9

ありがとうございました。
ChatGPT-3.5先生にソースをもらってから、コーディングしたほうがよかったですか。

入力2(sympyのprint_mathmlの結果) できませんでした。

ホンのあと一歩です。

次の積分を計算しなさい。
(既出)

出力:

与えられた積分を計算するために、部分積分を使用します。部分積分の公式は次のように表されます。
...
したがって、与えられた積分の値は次のようになります:
(8/9) e^3 + (1/9)

入力3(オリジナル 様) できませんでした。

以下、オリジナル(大学入試数学問題集成 様)の「ページのソースを表示」より

<p class="s1level"><span 
class="shomon1">(10)</span> 次の積分を計算しなさい.</p>
<p class="equation"><math>
<mrow><mstyle displaystyle="true"><msubsup><mo>&int;</mo>
<mn>1</mn><mi>e</mi></msubsup></mstyle><msup><mi>x</mi>
<mn>2</mn></msup><mo>&it;</mo><mi>log</mi><mo>&af;</mo>
<mi>x</mi><mo>&it;</mo><mi mathvariant="italic">dx</mi></mrow></math>
</p>

出力:

...
ここで C は積分定数です。

以下、いつもの?おすすめです。

いつもと違うおすすめです

積分する・しない

2023/12/14

①Qiitaで数式を書きましょう

上と同じ

・フランスの会社

>We started off as a small company in Nantes, France. For many years, there were less than 15 employees. We are now over 100 people and lately celebrated our 20th anniversary.

https://www.deepl.com/ja/translator#en/ja/We%20started%20off%20as%20a%20small%20company%20in%20Nantes%2C%20France.%20For%20many%20years%2C%20there%20were%20less%20than%2015%20employees.%20We%20are%20now%20over%20100%20people%20and%20lately%20celebrated%20our%2020th%20anniversary.

②そろそろ MathML について本気で勉強するべきではないか

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0