Upload presentasi
Presentasi sedang didownload. Silahkan tunggu
Diterbitkan olehCharles Lantang Telah diubah "10 tahun yang lalu
1
bilqis1 Pertemuan 7 2009
2
bilqis2 Sequences and Summations Deret (urutan) dan Penjumlahan
3
bilqis3 Deret: Adalah sebuah fungsi dari himpunan bagian integer ke suatu himpunan S. Himpunan bagian integer yang dimaksud adalah {0, 1, 2, …} atau {1, 2, 3, …} S = { a 0, a 1, a 2, a 3, …, a n } atau { a 1, a 2, a 3, …, a n } Geometric progression: a, ar, ar 2, ar 3, …, ar n r = ratio Arithmetic progression: a, a+d, a+2d, …, a+nd d = different String: a 1 a 2 a 3 … a n empty string =
4
bilqis4 Sequence Sequence = urutan Sequence : –Struktur diskrit yg digunakan untuk merepresentasikan urutan elemen –Fungsi dari N ke S –A n image dari integer n Example: subset of N: 1 2 3 4 5 … S: 2 4 6 8 10 … f N dimulai dari 1
5
bilqis5 Sequences We use the notation {a n } to describe a sequence. Important: Do not confuse this with the {} used in set notation. It is convenient to describe a sequence with a formula. For example, the sequence on the previous slide can be specified as {a n }, where a n = 2n.
6
bilqis6 The Formula Game 1, 3, 5, 7, 9, … a n = 2n - 1 -1, 1, -1, 1, -1, … a n = (-1) n 2, 5, 10, 17, 26, … a n = n 2 + 1 0.25, 0.5, 0.75, 1, 1.25 … a n = 0.25n 3, 9, 27, 81, 243, … a n = 3 n What are the formulas that describe the following sequences a 1, a 2, a 3, … ?
7
bilqis7 Strings Finite sequences are also called strings, denoted by a 1 a 2 a 3 …a n. String kumpulan sequence –Ex : 2 4 6 8 10 The length of a string S is the number of terms that it consists of. Length jumlah elemen pada string The empty string contains no terms at all. It has length zero. Empty string string yang tidak ada element –Length = 0
8
bilqis8 Contoh The sequence {bn} dgn bn=(-1) n adalah geometric progression. Kita mulai pada n=0, maka b0, b1, b2, b3 ….adalah 1, -1, 1, -1, ……… The sequence {Sn} dgn Sn = -1 + 4n adalah aritmatic progression. Kita mulai pada n=0, maka S0, S1, S2, S3 ….adalah -1, 3, 7, 11, ……
9
bilqis9
10
10
11
bilqis11
12
bilqis12
13
bilqis13 Penjumlahan (summation): a j = a m + a m+1 + a m+2 + … + a n m disebut batas bawah n disebut batas atas j disebut indeks n j = m
14
bilqis14 Summations It is 1 + 2 + 3 + 4 + 5 + 6 = 21. We write it as. What is the value of ? It is so much work to calculate this… What is the value of ? How can we express the sum of the first 1000 terms of the sequence {a n } with a n =n 2 for n = 1, 2, 3, … ?
15
bilqis15 Summations It is said that Friedrich Gauss came up with the following formula: When you have such a formula, the result of any summation can be calculated much more easily, for example:
16
bilqis16 Double Summations Corresponding to nested loops in C or Java, there is also double (or triple etc.) summation: Example:
17
bilqis17 Double Summations Table 2 in Section 3.2 (4 th edition: Section 1.7) contains some very useful formulas for calculating sums. Exercises 15 and 17 make a nice homework.
18
bilqis18
19
bilqis19
20
bilqis20
21
bilqis21
22
bilqis22
23
bilqis23
24
bilqis24 Definisi Rekursif
25
bilqis25 Rekursif Rekursif –perulangan terhadap diri sendiri, dengan ukuran lebih kecil –Ada titik berhenti, apakah pada 0 atau pada 1 –Secara prinsip mirip dengan induksi : Ada nilai awal Ada rumus untuk selanjutnya Ex : 1 hal 203 – misal f didefinisikan sbb : F(0) = 3 F(n+1) = 2 f(n) + 3 Tentukan f(1), f(2), f(3), f(4) Jawab : f(1) = 2f(0) + 3 = 2 3 + 3 = 9 f(2) = 2f(1) + 3 = 2 9 + 3 = 21 f(3) = 2f(2) + 3 = 2 21 + 3 = 45 f(4) = 2f(3) + 3 = 2 45 + 3 = 93
26
bilqis26 Recursively Defined Functions How can we recursively define the factorial function f(n) = n! ? f(0) = 1 f(n + 1) = (n + 1)f(n) Hitung f(4) Jawab : f(4) = 4f(3) = 4 6 = 24 f(3) = 3f(2) = 3 2 = 6 f(2) = 2f(1) = 2 1 = 2 f(1) = 1f(0) = 1 1 = 1 f(0) = 1
27
bilqis27 Recursively Defined Functions A famous example: The Fibonacci numbers f(0) = 0, f(1) = 1 f(n) = f(n – 1) + f(n - 2) Hitung f(6) f(6) = f(5) + f(4) = 5 + 3 = 8 f(5) = f(4) + f(3) = 3 + 2 = 5 f(4) = f(3) + f(2) = 2 + 1 = 3 f(3) = f(2) + f(1) = 1 + 1 = 2 f(2) = f(1) + f(0) = 1 + 0 = 1 f(1) = 1 f(0) = 0
28
bilqis28 Fungsi rekursif: Fungsi yang dinyatakan dengan “diri sendiri” dalam ukuran yang lebih kecil (secara rekursif), dan nilai eksplisit untuk nilai(-nilai) basis. Contoh: fungsi Fibonacci Basis: fib(0) = 0; fib(1) = 1 Rekursif:fib(n) = fib(n – 1) + fib(n – 2) Ditulis dengan cara lain: n jika n = 0, 1 fib(n) = fib (n – 1) + fib (n – 2) jika n > 1
29
bilqis29 PR (lihat buku) 3.2 5, 9, 13, 15, 17, 31 3.4 3, 7
Presentasi serupa
© 2024 SlidePlayer.info Inc.
All rights reserved.