Python符号运算sympy

#!/bin/python3
# -*- coding: utf-8 -*-
import sympy

from sympy import *

def p(x): print(x)
"求解一元二次方程"  
x = sympy.solve('x**2 - 5*x + 8')
p(x[0])

p(type(x[0]))

x = Symbol('x')
y = Symbol('y')

f = ((x+y)**2).expand()

p(f)

p(sympy.solve(f))

f = f.subs(x, 1)
f = f.subs(y, 2)
p(f)


发表于:2014-10-13 14:33:45

原文链接(转载请保留): http://www.multisilicon.com/blog/a25314159.html

友情链接: MICROIC
首页