Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15.

Similar presentations


Presentation on theme: "Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15."— Presentation transcript:

1 Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Email: rama.oktavian@ub.ac.id Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15

2 Outlines 1. Number series : Basic Theory 2. Taylor series 3. Number series in Excel 4. Application in chem.eng

3 Number series (basic theory) Numbers  Integer numbers  Binary numbers

4 Number series (basic theory) Integer Numbers We represent integers using a base-10 positional notation. So the number 90210 means: 910 4 + 010 3 + 210 2 + 110 1 + 010 0

5 Number series (basic theory) Binary Numbers Representing integers using a base-2 positional notation. So the number 101011 means: 12 5 + 02 4 + 12 3 + 02 2 + 12 1 + 12 0 132 + 016 + 18 + 04 + 12 + 11 43

6 Number series (basic theory) Converting decimal to binary 123 ÷2 61remainder 1 ÷2 30remainder 1 ÷2 15remainder 0 ÷2 7remainder 1 ÷2 3remainder 1 ÷2 1remainder 1 ÷2 0remainder 1

7 Number series (basic theory) Converting decimal to binary 123 ÷2 61  remainder 1 ÷2 30  remainder 1 ÷2 15  remainder 0 ÷2 7  remainder 1 ÷2 3  remainder 1 ÷2 1  remainder 1 ÷2 0  remainder 1

8 Number series (basic theory) Converting decimal to binary 1231111011 ÷2 61  remainder 1 ÷2 30  remainder 1 ÷2 15  remainder 0 ÷2 7  remainder 1 ÷2 3  remainder 1 ÷2 1  remainder 1 ÷2 0  remainder 1

9 Number series (basic theory) Number series  Arithmetic series  Geometric series

10 Number series (basic theory) Arithmetic Sequences  Monday : $150  Tuesday: $300  Wednesday: $450  Thursday:$600  Friday:$750 These prize amounts form a sequence, more specifically each amount is a term in an arithmetic sequence. To find the next term we just add $150.

11 Number series (basic theory) Definition Sequence: a list of numbers in a specific order. Term: each number in a sequence Arithmetic Sequence: a sequence in which each term after the first term is found by adding a constant, called the common difference (d), to the previous term.

12 Number series (basic theory) Example 150, 300, 450, 600, 750… The first term of our sequence is 150, we denote the first term as a 1. What is a 2 ? a 2 : 300 (a 2 represents the 2nd term in our sequence) To find the common difference (d), just subtract any term from the term that follows it.

13 Number series (basic theory) Formula Formula for finding any term in an arithmetic sequence is a n = a 1 + d(n-1). All you need to know to find any term is the first term in the sequence (a 1 ) and the common difference.

14 Number series (basic theory) Arithmetic series 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28 Series: the sum of the terms in a sequence. Arithmetic Series: the sum of the terms in an arithmetic sequence.

15 Number series (basic theory) Arithmetic series Arithmetic sequence:2, 4, 6, 8, 10 Corresponding arith. series: 2 + 4 + 6 + 8 + 10 Arith. Sequence: -8, -3, 2, 7 Arith. Series: -8 + -3 + 2 + 7 S n is the symbol used to represent the first ‘n’ terms of a series. Given the sequence 1, 11, 21, 31, 41, 51, 61, 71, … find S 4 We add the first four terms 1 + 11 + 21 + 31 = 64

16 Number series (basic theory) Formula S n = n / 2 (a 1 + a n ) Find the sum of the first 10 terms of the arithmetic series with a 1 = 6 and a 10 =51 S 10 = 10/2(6 + 51) = 5(57) = 285

17 Number series (basic theory) Formula To write out a series and compute a sum can sometimes be very tedious. Mathematicians often use the Greek letter sigma & summation notation to simplify this task. last value of n formula used to find sequence First value of n This means to find the sum of the sums n + 1 where we plug in the values 1 - 5 for n

18 Number series (basic theory) Geometric sequence Geometric Sequence: a sequence in which each term after the first is found by multiplying the previous term by a constant value called the common ratio. Find the first five terms of the geometric sequence with a 1 = -3 and common ratio (r) of 5. -3, -15, -75, -375, -1875

19 Number series (basic theory) Geometric sequence-Formula Formula for finding any term of a geometric sequence is a n = a 1 r n-1 Find the 10th term of the geometric sequence with a 1 = 2000 and a common ratio of 1 / 2. a 10 = 2000 ( 1 / 2 ) 9 = 2000 1 / 512 = 2000 / 512 = 500 / 128 = 250 / 64 = 125 / 32

20 Number series (basic theory) Geometric series Geometric Series - the sum of the terms of a geometric sequence. Geo. Sequence: 1, 3, 9, 27, 81 Geo. Series: 1+3 + 9 + 27 + 81 What is the sum of the geometric series? 1 + 3 + 9 + 27 + 81 = 121 The formula for the sum S n of the first n terms of a geometric series is given by

21 Number series (basic theory) Fibonacci series and the golden ratio let's examine an interesting sequence (or list) of numbers. Actually the series starts with 0, 1 but to make it easier we’ll just start with: 1, 1 To get the next number we add the previous two numbers together. So now our sequence becomes 1, 1, 2. The next number will be 3. What do you think the next number in the sequence will be? Remember, we add the previous two numbers to get the next. So the next number should be 2+3, or 5. Here is what our sequence should look like if we continue on in this fashion for a while: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610… Fibonacci sequence

22 Number series (basic theory) Fibonacci series and the golden ratio The relationship of this sequence to the Golden Ratio lies not in the actual numbers of the sequence, but in the ratio of the consecutive numbers. Let's look at some of the ratios of these numbers: Notice that as we continue down the sequence, the ratios seem to be converging upon one number (from both sides of the number)! 2/1 = 2.0 (bigger) 3/2 = 1.5 (smaller) 5/3 = 1.67(bigger) 8/5 = 1.6(smaller) 13/8 = 1.625 (bigger) 21/13 = 1.615 (smaller) 34/21 = 1.619 (bigger) 55/34 = 1.618(smaller) 89/55 = 1.618

23 Number series (basic theory) Fibonacci series and the golden ratio The Golden Ratio is what we call an irrational number: it has an infinite number of decimal places and it never repeats itself! Generally, we round the Golden Ratio to 1.618.

24 Number series (basic theory) Fibonacci series and the golden ratio The Golden Ratio is not just some number that math teachers think is cool. The interesting thing is that it keeps popping up in strange places - places that we may not ordinarily have thought to look for it. It is important to note that Fibonacci did not "invent" the Golden Ratio; he just discovered one instance of where it appeared naturally and it incorporates into art, architecture, and designs. The Golden Ratio seems to be Nature's perfect number.

25 Number series (basic theory) Count the number of keys (notes) in each of the brackets… You will see the numbers 2,3,5,8,13….coincidence? Does it look like the Fibonacci sequence…it should because it is!

26 Number series (basic theory)

27

28 Taylor series How does a CPU compute the following functions for a specific x value? cos(x) sin(x) e x log(x) etc. Non-elementary functions such as trigonometric, exponential, and others are expressed in an approximate fashion using Taylor series when their values, derivatives, and integrals are computed. Taylor series provides a means to predict the value of a function at one point in terms of the function value and its derivatives at another point.

29 Taylor series Taylor Series (n th order approximation): Define the step size as h=(x i+1 - x i ), the series becomes: The Reminder term, R n, accounts for all terms from (n+1) to infinity.

30 Taylor series Any smooth function can be approximated as a polynomial. Take x = x i+1 Then f(x) ≈ f(x i ) zero order approximation first order approximation Second order approximation: n th order approximation: Each additional term will contribute some improvement to the approximation. Only if an infinite number of terms are added will the series yield an exact result. In most cases, only a few terms will result in an approximation that is close enough to the true value for practical purposes

31 Taylor series Example Approximate the function f(x) = 1.2 - 0.25x - 0.5x 2 - 0.15x 3 - 0.1x 4 from x i = 0 with h = 1 and predict f(x) at x i+1 = 1.

32 Taylor series Example: computing f(x) = e x using Taylor Series expansion (1) Choose x = x i+1 and x i = 0 Then f(x i+1 ) = f(x) and (x i+1 – x i ) = x Since First Derivative of e x is also e x : (2.) (e x ) ” = e x (3.) (e x ) ”’ = e x, … (n th.) (e x ) (n) = e x As a result we get:

33 Taylor series Yet another example: computing f(x) = cos(x) using Taylor Series expansion Choose x= x i+1 and x i =0 Then f(x i+1 ) = f(x) and ( x i+1 – x i ) = x Derivatives of cos(x): (1.) (cos(x) ) ’ = -sin(x) (2.) (cos(x) )” = -cos(x), (3.) (cos(x) ) ”’ = sin(x) (4.) (cos(x) ) ”” = cos(x), …… As a result we get:

34 Number series in excel Evaluating function

35 Number series in excel Taylor series in Excel With : at x = 1, F(x) = 16.25 Evaluating F(x) at x = 1.6 using Taylor series

36 Number series in excel Taylor series in Excel With : Evaluating F(x) at x = 1.6 using Taylor series

37 Taylor series (application) The application of Taylor series Solving differential equation Subject to at Example The concentration of salt x in a home made soap maker is given as a function of time by at initial time, t = 0, the salt concentration in the tank is 50 g/L, Using Taylor series expansion, what is the salt concentration after 3 minutes

38


Download ppt "Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15."

Similar presentations


Ads by Google