Python では sympy を使う
WolframAlpha の「高等学校 数学」の例題 3 題を解いてみる
>>> from sympy import *
>>> var('a:z')
(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
問題 1. y=-x^2+2x+8の頂点の座標
>>> expr = -x**2 + 2*x + 8
>>> a = solve(diff(expr))[0]
>>> b = expr.subs(x, a)
>>> [a, b]
[1, 9]
問題 2. log(4,x+4)=log(2,2x-7)+log(8,1/(5√5))を解く ※ 第1引数が底
>>> expr = log(x + 4, 4) - log(2 * x - 7, 2) - log(1 / (5 * sqrt(5)), 8)
>>> expr
log(x + 4)/log(4) - log(2*x - 7)/log(2) - log(sqrt(5)/25)/log(8)
>>> solve(expr)
[29/4]
問題 3. x が 0 に近付くときの (sin x - x)/x^3 の極限
>>> limit((sin(x) - x) / x**3, x, 0)
-1/6
>>> var('a:z')
(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
問題 1. y=-x^2+2x+8の頂点の座標
>>> expr = -x**2 + 2*x + 8
>>> a = solve(diff(expr))[0]
>>> b = expr.subs(x, a)
>>> [a, b]
[1, 9]
問題 2. log(4,x+4)=log(2,2x-7)+log(8,1/(5√5))を解く ※ 第1引数が底
>>> expr = log(x + 4, 4) - log(2 * x - 7, 2) - log(1 / (5 * sqrt(5)), 8)
>>> expr
log(x + 4)/log(4) - log(2*x - 7)/log(2) - log(sqrt(5)/25)/log(8)
>>> solve(expr)
[29/4]
問題 3. x が 0 に近付くときの (sin x - x)/x^3 の極限
>>> limit((sin(x) - x) / x**3, x, 0)
-1/6