, , . ,
In[4]:= exprod[n_]:= Expand[Product[x+i, {i, 1, n}]]
In[5]:= cex[n_, i_]:= (t = exprod[n]; Coefficient[t, x^i])
x t . Mathematica.
In[6]:= exprod[5]
Out[6]= 120 + 274 x + 225 x2 + 85 x3 + 15 x4 + x5
In[7]:= cex[5, 3]
Out[7]= 85
In[8]:= t t -
Out[8]= 120 + 274 x + 225 x2 + 85 x3 + 15 x4 + x5
In[9]:= x=a; x -
In[10]:= exprond[3]
Out[10]= 6 + 11 a + 6 a2 + a3
Module[{a,b,c,...}, procedure],
a, b, c,... . ncex u.
In[11]:= ncex[n_, i_]:= Module[{u}, u = exprod[n]; Coefficient[u, x^i]] u -
In[12]:= ncex[5, 3]
Out[12]= 85
In[13]:= u
Out[13]= u
Mathematica , .
Goto[tag] - tag.
Label[tag] - tag.
If[conditioon, t, f] - If t, condition=true f, condition=false.
Do[expr, {i, imax}] - Do expr imax - . i 1 imax 1.
Do[expr, {i, imin, imax, di] - i, imin imax di.
Table[expr, {i, imax}] - (list) , expr. imax.
Table[expr, {i, imax},{j, jmax]] - , imax jmax .
While[condition, body] - .
Mathematica , . :
In[1]:= Factorial[n_]:= If[n==0, 1, n*Factorial[n-1]]
In[2]:= Factorial[4]
Out[2]= 24
. . . (Package) ASCII m. PACKAGES Mathematica.
:
BeginPackage["NonLSys`AffinS`"] - NonLSys`AffinS`, AffinS.m.
|
|
f::usage="Text" - f, . , . "Text" , f. ?< > "Text"
Begin["`Private`"] - . .
f[arg]:= < > - .
End[ ] - .
EndPackage[ ] - .
.
BeginPackage["NonLSys`AffinS2`"]
(* *)
GradF::usage="GradF[h, x] returns the gradient dh={dh/dx1...
dh/dxn} of function h. x={x1... xn} is array of state space
variables."
Jacobi::usage="Jacoby[f, x] returns the Jacobi matrix J=df/dx
of vector f. f={{f1(x)},{f2(x)},...} is vector colums"
Begin["`Private`"]
GradF[hh_, xx_]:=Module[{i}, Table[D[hh, xx[[i]] ], {i, Length[xx]}]]
Jacobi[ff_, xx_]:= Module[{i, j},
Table[D[ff[[i, 1]], xx[[j]]], {i, Length[ff]}, {j, Length[xx]}]]
End[ ]
EndPackage[ ] (* NonLSys`AffinS2` *)
. .
In[1]:= <<NonLSys`AffinS2`
Mathematica , , . (, , ..).
Plot[f[x], {x, xmin, xmax}],
f[x] , x , xmin x, xmax x.
In[1]:= Plot[Sin[x], {x, 0, 2*Pi}]
Out[1] = Graphics
, Frame, GridLines, GridLines.
In[2]:= Plot[Sin[x^2], {x, 0, 3}, Frame -> True, GridLines -> Automatic,
AxesLabel -> {"x", "Sin[x]"}]
Out[2] = Graphics
PlotRange .
In[3]:= Plot[Sin[x^2], {x, 0, 3}, PlotRange -> {0, 1.2}]
Out[3] = Graphics
Show , .
In[4]:= Show[Out[2], Out[3]]
Out[4] = Graphics