0% found this document useful (0 votes)
34 views

Praktikum Ke-5: Jenis Argumen

The document discusses functions in Mathematica with different argument patterns like _Integer, _Real, etc. It shows how to define functions with different patterns and apply them. It also discusses operations like mapping, modules and replacements.

Uploaded by

Udah dah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Praktikum Ke-5: Jenis Argumen

The document discusses functions in Mathematica with different argument patterns like _Integer, _Real, etc. It shows how to define functions with different patterns and apply them. It also discusses operations like mapping, modules and replacements.

Uploaded by

Udah dah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Praktikum ke-5

Jenis Argumen

MapBHead, :46, 46.2010, , 845, 46<, a>F


210
In[1]:=
211
Out[1]= 8Integer, Real, Rational, List, Symbol<

In[3]:= f@x_D := x^2

In[5]:= f@2D

Out[5]= 4

In[6]:= [email protected]

Out[6]= 12.25

In[7]:= g@x_IntegerD := x^2

In[8]:= g@2D

Out[8]= 4

In[9]:= [email protected]

Out[9]= [email protected]

In[10]:= 5!

Out[10]= 120

In[16]:= faktorialku@n_D := Product@i, 8i, n<D

In[12]:= faktorialku@5D

Out[12]= 120
2 praktikum5.nb

In[13]:= faktorialku@3D

Out[13]= 6

In[14]:= [email protected]

Out[14]= 6

In[18]:= faktorialkuyangbaru@n_IntegerD := Product@i, 8i, n<D

In[19]:= faktorialkuyangbaru@5D

Out[19]= 120

In[20]:= [email protected]

Out[20]= [email protected]

In[21]:= Clear@f, gD

In[25]:= f@x_Integer x_RealD := x2 + 1H*simbol ini maksudnya atau*L

In[23]:= f@2D

Out[23]= 5

In[24]:= [email protected]

Out[24]= 3.25

fB FH*rasional cing*L
1
In[27]:=
2

fB F
1
Out[27]=
2

In[28]:= f@x_Integer x_Real x_RationalD := x2 + 1


praktikum5.nb 3

fB F
1
In[29]:=
3
10
Out[29]=
9

In[30]:= Clear@fD

In[31]:= f@x_D := x + 1

In[35]:= f1@x_RealD := x + 1H*real harus dimasukan bilangan koma*L

In[34]:= [email protected]

Out[34]= 47.201

In[36]:= f2@x_IntegerD := x + 1

In[37]:= f2@-3D

Out[37]= -2

In[38]:= f3@x_RationalD := x + 1

f3B F
1
In[39]:=
2
3
Out[39]=
2

In[40]:= f4@x_Real x_Integer x_RationalD := x + 1

f4B F
1
In[45]:=
2
3
Out[45]=
2

In[51]:= f5@x_RealD := x + 1 ; 0 £ x
4 praktikum5.nb

In[55]:= [email protected]

Out[55]= [email protected]

In[54]:= [email protected]

Out[54]= 4.5

In[86]:= f6@x_IntegerD := x + 1 : x < 0

In[86]:= f6@3D

Out[86]= 4

In[87]:= f6@-3D

Out[87]= -2

In[74]:= f7@x_RealD := x + 1 ; -10 < x < 10

In[75]:= [email protected]

Out[75]= 6.5

In[76]:= [email protected]

Out[76]= [email protected]

In[88]:= f8@x_PrimeQD := x + 1 ; x > 10

In[89]:= f8@5D

Out[89]= f8@5D

In[90]:= f8@11D

Out[90]= 12

In[91]:= f8@14D

Out[91]= f8@14D
praktikum5.nb 5

In[92]:= matMultiply@a_ ? MatrixQ, b_ ? MatrixQD := a.b

In[98]:= a = 881, 2<, 83, 4<<

Out[98]= 881, 2<, 83, 4<<

In[97]:= b = 881, 0<, 80, 1<<

Out[97]= 881, 0<, 80, 1<<

In[99]:= a.b  MatrixForm


Out[99]//MatrixForm=

K O
1 2
3 4

In[100]:= matMultiply@a, bD  MatrixForm


Out[100]//MatrixForm=

K O
1 2
3 4

In[101]:= Clear@xD

In[148]:= x=4

Out[148]= 4

In[149]:= y=6

Out[149]= 6

In[150]:= z=y

Out[150]= 6

In[151]:= y=x

Out[151]= 4

In[152]:= x=z

Out[152]= 6
6 praktikum5.nb

In[153]:= 8x, y<

Out[153]= 86, 4<

In[154]:= ?x

Global`x

x=6

In[116]:= ?y

Global`y

y=4

In[117]:= Clear@x, yD

In[155]:= x = 28; 8Module@8x = x<, x = x + 1; xD, x<

Out[155]= 829, 28<

In[156]:= ?x

Global`x

x = 28

In[157]:= x+3

Out[157]= 31

In[158]:= x + 3 . x ® 2

Out[158]= 31

In[159]:= y=5

Out[159]= 5

In[160]:= SqrtAz2 + y2 E

Out[160]= 61
praktikum5.nb 7

In[173]:= SqrtAz2 + y2 E

Out[173]= 61

In[168]:= Clear@xD

In[169]:= x

Out[169]= x

In[178]:= Clear@a, bD

In[179]:= 3 a + 2.5 a2 + 4 a3 . 9x_Integer ® x2 =

Out[179]= 9 a + 2.5 a4 + 16 a9

In[171]:= Clear@xD

In[180]:= a2 + b2 . a2 ® c + d

Out[180]= b2 + c + d

In[187]:= 8a, a + b, b + b< . a + b ® b

In[188]:= 8a, b, 2 b<

In[189]:= Clear@b, fD

In[190]:= f@aD + g@bD + h@cD . x_@y_D ® x

Out[190]= f+g+h

F sumF
1
nisbahSqr@n_D := ModuleB8sum = 0<, ForBi ³ 1, 1 £ n, i++, sum +=
i2

nisbahSqr@5D

Increment::rvalue : i is not a variable with a value, so its value cannot be changed. ‡

You might also like