{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Solution-HW1

# Solution-HW1 - Homework#1 Solution 1 Determine machine...

This preview shows pages 1–3. Sign up to view the full content.

Homework #1 Solution 1. Determine machine epsilon in both double and single precision for Excel Visual Basic. SOLUTION: For single precision: Option Explicit Function MachEps() Dim eps As Single, eps1 As Single, eps2 As Single eps = 1 Do eps1 = 1 + eps eps2 = eps1 - 1 If (eps2 <= 0) Then Exit Do End If eps = eps / 2 Loop MachEps = eps End Function MachEps = 5.96046E-08 For double precision: Option Explicit Function MachEps() Dim eps As Double, eps1 As Double, eps2 As Double eps = 1 Do eps1 = 1 + eps eps2 = eps1 - 1 If (eps2 <= 0) Then Exit Do End If eps = eps / 2 Loop

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
MachEps = eps End Function MachEps = 1.11022E-16 4.2 Maclaurin series expansion for cos x is " + + = ! 8 ! 6 ! 4 2 1 cos 8 6 4 2 x x x x x Starting with the simplest version, cosx=1, add terms one at a time to estimate cos( π /4). After each new term is added, compute the true and approximate percent relative errors. Use your pocket calculator to determine the true value. Add terms until the absolute value of the approximate error estimate falls below an error criterion conforming to two significant figures. SOLUTION: We use Eq. 3.7 in the textbook: ( ) % 10 5 . 0 2 n s × = ε We choose n=2 , so ε t =0.5% Zero order: 1 4 cos π ; True value is 707107 . 0 4 cos = π ; % 42 . 41 % 100 707107 . 0 1 707107 . 0 = × = t ε First order: ( ) 691575 . 0 2 4 / 1 4 cos 2 = = π π ; % 19 . 2 % 100 707107 . 0
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

Solution-HW1 - Homework#1 Solution 1 Determine machine...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online