from sympy import *
init_printing()
import math
math.sqrt(2)
sqrt(2)
acos(0.5)
acos(1/2)
acos(Out[6])
x,y,z=symbols('x y z')
alpha,beta,gamma=symbols('alpha,beta,gamma')
sin(alpha)**2+sin(beta)**2
?,?=symbols('? ?')
bell=?
a=Symbol('a')
diff(a*x**3,x)
bell.diff(x)
from sympy.plotting import *
plot(exp(-(x-3)**2),(x,-5,6))
a,b,c,d=symbols('a b c d')
expr=(a-b)*(a+b)**2
expand(expr)
expr.expand()
new_expr=expr.subs([(a,3),(b,d*c/2)])
new_expr
simplify(new_expr)
new_expr.subs([(c,2.4),(d,3)]).evalf()
a,b,c,s=symbols('a,b,c,s')
area=sqrt(s*(s-a)*(s-b)*(s-c))
x,y=symbols('x y')
a=(x-y)**2
b=x**2-2*x*y+y**2
a==b
simplify(a-b)
e=Eq(y,4*x**2-x+3)
e
e.lhs
e.rhs
solve(e,x)
def equality_exercise(a,b):
"""Return a tuple of tow boolean. the first is True if a=b symbolicaly,
the second is True if a==b mathematically.
Examples
========
>>> x=symbols('x')
>>> equality_exercise(x,2)
(False,False)
>>> equality_exercise((x+1)**2,x**2+2*x+1)
(False,True)
>>> equality_exercise(4*x,4*x)
(True,True)
"""
sympify('2*cos(x)')
c=4.2# J/gr-1C
m=150*1000 #gr
T1=23 #C
T2=60 #C
P=2000 #w
Q=c*m*(T2-T1)
t=Q/P
print t, "C"
x,b=symbols('x b')
eq=Eq(x-1/x+b*x,7)
print eq
ans=solve(eq,x)
ans
print ans[0].subs(b,5).n(3), ans[1].subs(b,5).n(3)
x,y=symbols('x,y')
solve([Eq(3*(x-y)**2+x-2,y),Eq(y*x+x/3+y,1)],[x,y])
x,a,b,c=symbols('x,a,b,c')
f=exp(-(x**2-a*x-b)/c)
plot(f.subs([(a,2),(b,1),(c,3)]),(x,-4,5))
solve(f.diff(x),x)
from sympy import *
A,t=symbols('A,t')
c=A*t*exp(-t/3)
from sympy.plotting import *
plot(c.subs(A,5),(t,0,10),title='c vs t graph',xlabel='t(s)',ylabel="c(mg/ml)")
tmax=solve(c.diff(t),t)
tmax
cmax=1#mg/ml
Ac=solve(Eq(c.subs(t,tmax[0]),cmax),A)
Ac
Ac[0].evalf()
plot(c.subs(A,Ac[0]),(t,0,10),title='c vs t graph',xlabel='t(s)',ylabel="c(mg/ml)")