我怎样才能说服Sympy简化SAINT来解决1961年MIT本科生微积分问题呢? [英] How can I convince Sympy to come to the same simplification SAINT does for the 1961 MIT undergrad calculus problem?

查看:67
本文介绍了我怎样才能说服Sympy简化SAINT来解决1961年MIT本科生微积分问题呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

詹姆士·R·斯莱格(James R Slagle)的MIT论文程序解决大一新生微积分中的符号积分问题的启发式程序,符号自动积分器(SAINT)是著名的成为第一个实用的专家系统"符号集成器,并且能够解决MIT本科微积分测试中的所有问题(从传统上讲,虽然错过了一对,但可以解决;在这里详细说明

简化符号

 从sympy导入*x = symbols("x",real = True)#应该假定吗?expr_inner =(x ** 4)/((1-x ** 2)**理性(5,2))expr_integral =积分((expr_inner),x)打印(简化(expr_integral))(x ** 4 * asin(x)+ 4 * x ** 3 * sqrt(1-x ** 2)/3-2 * x ** 2 * asin(x)-x * sqrt(1-x ** 2)+ asin(x))/(x ** 4-2 * x ** 2 +1) 

平等证明

 从sympy导入*x = symbols("x",real = True)#应该假定吗?expr_saint = asin(x)+ Rational(1,3)* tan(asin(x))** 3-tan(asin(x))expr_sympy =(x ** 4 * asin(x)+ 4 * x ** 3 * sqrt(1-x ** 2)/3-2 * x ** 2 * asin(x)-x * sqrt(1-x ** 2)+ asin(x))/(x ** 4-2 * x ** 2 +1)expr_saint.equals(expr_sympy)#或者简化(expr_saint-expr_sympy)https://stackoverflow.com/a/37115190/真的 

方程显示

解决方案

主要部分是分解出 asin(x)并将其与分数分离.之后,sympy可以证明两个表达式相等:

 从sympy导入*从IPython.display导入Math,displayx = symbols("x",real = True)#应该假定吗?expr_saint = asin(x)+ Rational(1,3)* tan(asin(x))** 3-tan(asin(x))expr_sympy =(x ** 4 * asin(x)+ 4 * x ** 3 * sqrt(1-x ** 2)/3-2 * x ** 2 * asin(x)-x * sqrt(1-x ** 2)+ asin(x))/(x ** 4-2 * x ** 2 +1)r = []r.append(latex(expr_sympy))expr_sympy = expr_sympy.collect(asin(x))r.append(latex(expr_sympy))expr_sympy =分开(expr_sympy,asin(x))r.append(latex(expr_sympy))display(Math("\\ Longrightarrow" .join(r)))显示(简化(expr_saint-expr_sympy)) 

输出:

The program for James R Slagle's MIT thesis A heuristic program that solves symbolic integration problems in freshman calculus, symbolic automatic integrator (SAINT) is famous(ish) for being the first practical "expert system" symbolic integrator and able to solve all of the problems on the MIT Undergraduate Calculus test (pedantically, a couple were missed, but it could have solved them; detailed here in this excellent YouTube video)

His thesis is freely available here: https://dspace.mit.edu/handle/1721.1/11997

I was excited to try Sympy on this because it looked approachable and was a reasonably difficult simplification I happened to already have an answer to .. however, Sympy doesn't simplify the integral to such a good(subjective?) simplification as the 1961 program (though it does return an equivalent result!)


Question and Speculation

How can I convince Sympy to simplify to the same equation?
Why doesn't it come to the same, seemingly-simpler result?

Perhaps it chooses the first possible outcome, or tan**3 is determined to be worse? if so, why doesn't it simplify SAINT's output?)

Perhaps it sets off down a different branch when it finds some matching Fu-routine?

Exam problem 3c

Sympy simplification

from sympy import *
x = symbols("x", real=True)  # should this be assumed?
expr_inner = (x**4) / ((1 - x**2)**Rational(5,2))
expr_integral = integrate((expr_inner), x)
print(simplify(expr_integral))

(x**4*asin(x) + 4*x**3*sqrt(1 - x**2)/3 - 2*x**2*asin(x) - x*sqrt(1 - x**2) + asin(x))/(x**4 - 2*x**2 + 1)

Proof of Equality

from sympy import *
x = symbols("x", real=True)  # should this be assumed?
expr_saint = asin(x) + Rational(1,3)*tan(asin(x))**3 - tan(asin(x))
expr_sympy = (x**4*asin(x) + 4*x**3*sqrt(1 - x**2)/3 - 2*x**2*asin(x) - x*sqrt(1 - x**2) + asin(x))/(x**4 - 2*x**2 + 1)
expr_saint.equals(expr_sympy)  # alternatively simplify(expr_saint - expr_sympy) https://stackoverflow.com/a/37115190/

True

Equations Display

解决方案

The main part is factoring out asin(x) and pulling it separate from the fraction. After this, sympy can prove the two expressions are equal:

from sympy import *
from IPython.display import Math, display
x = symbols("x", real=True)  # should this be assumed?
expr_saint = asin(x) + Rational(1,3)*tan(asin(x))**3 - tan(asin(x))
expr_sympy = (x**4*asin(x) + 4*x**3*sqrt(1 - x**2)/3 - 2*x**2*asin(x) - x*sqrt(1 - x**2) + asin(x))/(x**4 - 2*x**2 + 1)

r=[]
r.append(latex(expr_sympy))
expr_sympy = expr_sympy.collect(asin(x))
r.append(latex(expr_sympy))
expr_sympy = apart(expr_sympy,asin(x))
r.append(latex(expr_sympy))

display(Math(" \\Longrightarrow ".join(r)))

display(simplify(expr_saint - expr_sympy))

Output:

这篇关于我怎样才能说服Sympy简化SAINT来解决1961年MIT本科生微积分问题呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆