Thursday, August 20, 2009

Mathematica速查

自定义函数:
In[1]:= f[x_]:=x^2+1

求解方程:
In[1]:= Solve[x^2+2x-a == b, x]

求极限:
In[1]:= Limit[Sin[x]/x, x->0]
In[2]:= Limit[1/x, x->Infinity]

求导数:
In[1]:= D[Exp[x],x]
二阶导数
In[2]:= D[Exp[x],{x,2}]

求和:
In[1]:= Sum[a^i/i, {i,1,M}]

绘图:
In[1]:= Plot[Sin[x],{x,0, Pi}]
In[1]:= Plot[{Sin[x], Cos[x]},{x,0, Pi}]

删除符号的赋值:
In[1]:= M=.

删除符号:
In[1]:= Remove[M]

导入数据:
In[1]:= Import["foo.dat","Table"]

拟合:
In[1]:= Fit[{{1,10},{2,25},{3,31},{4,40}}, {1,x}, x]
In[1]:= Fit[Import["foo.dat","Table"], {1,x}, x]

多项式展开:
In[1]:= Expand[(1 + x + x^2) (1 + x)]
Out[1]:= 1 + 2 x + 2 x^2 + x^3

分解因式:
In[1]:= Factor[1 + x^3]
Out[1]:= (1 + x) (1 - x + x^2)

多项式化简:
In[1]:= Simplify[(1 + x)^2 - (1 - x)^2]
Out[1]:=  4x

No comments: