Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

How to compute functions

In[3]:= Sin [Pi / 2]


Out[3]= 1

In[4]:= Binomial [8, 3]


Out[4]= 56

In[5]:= FactorInteger [1200 ]


Out[5]= {{2, 4}, {3, 1}, {5, 2}}

In[6]:= Table [Prime [n], {n, 1, 10 }]


Out[6]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }

In[8]:= N[Exp [1]]


Out[8]= 2.71828

In[9]:= Log [E]


Out[9]= 1

In[10]:= Log [10, 100 ]


Out[10]= 2

In[11]:= Mod [183, 89 ]


Out[11]= 5

In[12]:= Sum [i, {i, 1, n}]


1
Out[12]= n (1 + n)
2

In[14]:= Sum [i ^ 2, {i, 1, 10 }]


Out[14]= 385

In[15]:= Sum [i ^ 2, {i, 1, n}]


1
Out[15]= n (1 + n) × (1 + 2 n)
6

In[16]:= Product [i ^ 2, {i, 1, 8}]


Out[16]= 1 625 702 400

In[18]:= f[x_] := x ^ 3 + Sin [x]

In[19]:= f[x]
Out[19]= x3 + Sin [x]
2

In[20]:= f[0]
Out[20]= 0

In[21]:= f[1]
Out[21]= 1 + Sin [1]

In[22]:= D[f[x], x]
Out[22]= 3 x2 + Cos [x]

In[23]:= Integrate [f[x], x]


x4
Out[23]= - Cos [x]
4

In[24]:= Integrate [f[x], {x, 0, Pi }]


1 4
Out[24]= × 8 + π 
4

In[25]:= g[x_] := Log [x] - Exp [x ^ 2]

In[26]:= g[x]
x2
Out[26]= -ⅇ + Log [x]

In[27]:= Integrate [g[x], x]


1
Out[27]= -x - π Erfi [x] + x Log [x]
2

In[28]:= f[0] = 1;
f[1] = 1;
f[n_] := f[n] = f[n - 1] + f[n - 2];
Table [f[n], {n, 0, 10 }]

Out[31]= {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }

How to make graphs


Qus: Draw the graph of y = sin(x), for 0 ≤ x ≤ 2π.
3

In[32]:= Plot [Sin [x], {x, 0, 2 Pi }]


1.0

0.5

Out[32]=
1 2 3 4 5 6

-0.5

-1.0

In[36]:= Plot [Log [x], {x, 1, 10 }]

2.0

1.5

Out[36]=
1.0

0.5

2 4 6 8 10

In[37]:= Plot [Abs [x], {x, - 1, 1}]

1.0

0.8

0.6

Out[37]=

0.4

0.2

-1.0 -0.5 0.5 1.0


4

In[38]:= Plot [{Cos [x], Sin [x], x}, {x, 0, 2 Pi }]

Out[38]=

1 2 3 4 5 6

Qus: Draw the graph of z = x^2+y^2, -2 ≤ x,y ≤ 2.

In[40]:= Plot3D [x ^ 2 + y ^ 2, {x, - 2, 2}, {y, - 2, 2}]

Out[40]=
5

In[41]:= Plot3D [Exp [- (x ^ 2 + y ^ 2)], {x, - 2, 2}, {y, - 2, 2}]

Out[41]=

You might also like