NUMERICAL COMPUTING MATH 4800
Popular in Course
Popular in Mathematics (M)
verified elite notetaker
This 10 page Class Notes was uploaded by Christelle West on Monday October 19, 2015. The Class Notes belongs to MATH 4800 at Rensselaer Polytechnic Institute taught by Yuri Lvov in Fall. Since its upload, it has received 40 views. For similar materials see /class/224793/math-4800-rensselaer-polytechnic-institute in Mathematics (M) at Rensselaer Polytechnic Institute.
Reviews for NUMERICAL COMPUTING
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/19/15
Numerical Computing 12309 Section 2 Homework 1 First Homework on NumComp Due January 23 2009 LVOV Yuri Review questions page 3942 no credit 1 Exercise 16 afer Chapter 1 33 1 Lz l amuse 2 Consider L3quot 3 Calculate OFLUFL How many different numbers are there in this system Draw a number line as on page 19 Consider normalized and and subnormal numbers separately Computer Problem 15 after Chapter 1 4 Computer Problem 110 after Chapter 1 5 Exercise 19 after Chapter 1 Collaborated withz E L 1 Numerical Computi Section 2 3 Exercise 16 The sine function is given by the in nite series 01 a x3 x5 x7 Sinxx T T 7 12309 Homework 1 a What are the forward and backward errors if we approximate the sine function by using only the rst term in the series ie sinxzx for x01 05 and 10 Forward Error Ax 37 39 y Ay y siny 37 Forward Error Ay 1 0998334 166583E394 5 4794255 20574513 2 10 8414710 158529E391 Backward Error Ax r x sinx x r sin 1x Ax sin 1x x x r Backward Error Ax 1 1001674 167421E394 5 5235988 235988E392 10 15707963 570796E 1 b What are the forward and backward errors if we approximate the sine function by using the rst two terms in the series ie sinxzxX36 for x01 05 and 10 Forward Error Ay 37 y M yy36sinyi 37 Forward Error Ay 0998333 0998334 Q833135E 8 4791667 4794255 3258872E 4 8333333 8414710 381376553 Numerical Computing 12309 L Section 2 Homework 1 r Backward Error Ax f x sin5c x x36 a sin 1x x36 Ax sin 1x x36 x X a Backward Error Ax 1 0999999 9837318E 8 5 4997050 G294959E394 10 9851108 9148892132 2 Consider much 9 I 2 8 Calculate OFLUFL How many different numbers are there in this system Draw a number line as on page 19 Consider normalized and and subnormal numbers separately 6Q on 13mm 31 3011 32 E 10 1 UFL 3L 3 1 an Smach jrp 31 2 13 Chopped Smash g l j 31 2 16 rounded Total of 39s 2m map1w L 1 1 23 13210 1 1 1 25 Normal L3 22 21 20 12 11 10 22x3121x3120x3112x3111x311ox31 U10 83 73 2 53 43 1 89 79 23 59 49 13 11 111 1111111 1111111111 111 4 41 7 J O 1 2 3 Subnormal 39 3 021131 01131 10 29 19 7 mlW61 1 L I 1 I 15 I I 1 I l l am quot7 O 71 M I L 39 Numerical Computing 12309 i 1 Section 2 Homework 1 i m f 3 Computer Problem 15 a Consider the function 99 39 fx ex 1x Use l Hopital s Rule to show that Egg f x 1 l Hopital s Rule lim lim H we we was In this case fx ex 1 and gxx b Check this result empirically by writing a program to compute fX for x1039k k1 15 Do your results agree with theoretical expectations Explain why MatLab Code k HE x pnwerlk L3 ExpxIx plntxya titlB39REsults using BAX1V x39 xlahel 39x39 ylabel 39fx39 12309 Homework 1 Numerical Computing Section 2 k 1 2 3 4 5 6 7 10517 10050 1000510000 10000 10000 The results agree with the theoretical expectations up to a point but then deviate from the expected outcome because of error that enters the calculation The rounding error in x magni es the cancellation error in the numerator resulting in larger error for smaller values of X which are seen when kgt11 The rounding and cancellation error are brought about by a lack of the necessary signi cant digits to provide a more accurate result 0 Perform the experiment in part b again this time using the mathematically equivalent formulation f x ex 110g8quot evaluated as indicated with no simpli cation If this works any better can you explain Why MatLab Code k H5 x pnwerl k yh Bxpx lugexpx plutxyh title39Results using BAX1V ngequotx39 xlabel 39x39 ylabel 39fx39 This method works better because it maintains its accuracy for smaller values of x The new denominator improves the equation because when analyzing the equation it can be seen that it reduces to fxfx for smaller values of x because of cancellation of higher terms in the expansion of logex WMQ 63 LC 83 f 3 l 4 12309 Homework 1 Numerical Computing Section 2 Computer Problem 110 4 Write a program to solve the quadratic equation ax2bxc0 using the standard quadratic formula b Vbz 4ac x 2a or the alternative formula 2C x b T Vbz 4ac Your program should accept values for the coef cients a b and c as input and produce the two roots of the equation as output Your program should detect when the roots are not real but need not use complex arithmetic explicitly for example you could return the real and imaginary parts of the complex conjugate roots in this case You should guard against unnecessary over ow under ow and cancellation When should you use each of the two formulas Try to make the program robust when given unusual input values such as a0 or 00 which otherwise would make one of the formulas fail Any root that is within the range of the oatingpoint system should be computed accurately even if the other is out of range See Next Page for MatLab Codegt Numerical Computing Section 2 MatLab Code xp 2eh sqrtl1quot2 4ae xm 2e h sqrthquot2 4ae else ifehsegtllquotlll ehshgtlquotll ehsegtll ll 12309 Homework 1 displ39Ean nut eempute rents 1f the equatien as uverflew will be caused by this ealeuletinn39 else ifehsaltllquotlll II ahshltllquotlll ll abseltlquot ll disp Een net eempute rents ef the equetinn as underflew will be caused by this ealeuletien39 else Xp h sqrthquot2 4ee2e xm lJ sqrthquot2 4HE2e end end end 7 QWM 495 39 x 12309 Homework 1 Numerical Computing Section 2 5 Exercise 19 a Use fourdigit decimal arithmetic and the formula given in Example 11 compute the surface area of the Earth with r63 70km Q 60 A 411 2 41163702 5099x103km2 b Using the same formula and precision compute the difference in surface area if the value for the radius is increased by 1km A2 4an 47r63712 0 Since dAdr87tr the change in surface area is approximated by 87trh Where h is the change in radius Use this formula still with fourdigit arithmetic to compute the difference in surface area due to an increase of 1km in radius How does the value obtained using the approximate formula compare with that obtained from the exac formula in part b dA E 81trh 81r63701 1601x105km2 A AdA 2 dr 5099x108 1601x105 At this level of precision 4digits using the approximate formula produces the same result as using the exact formula 1 Determine which of the previous two answers is more nearly correct by repeating both computations using higher precision say sixdigit decimal arithmetic Six digits A2 4an M63712 dA a 81trh 8n63701 160095x105km2 dA A2 A 509904x108 160095x105 dr The results are still the same using 6digits of precision since 712 A2 m Numerical Computing 12309 39 Section 2 Homework 1 39 Eightdigits A2 47tr2 41163712 dA E snrh 81t63701 16009556x105km2 dA A2 A a 50990436x108 16009556x105 With eightdigits of precision the difference is nally apparent as Hz at A2 e Explain the results you obtained in parts a d The reason for the error and the phenomenon in this problem is due to cancellation If a high enough precision is not used then the difference between two large numbers reduces to 0 even if there is a nonzero difference between them With 4 and 6 digits of precision the nonzero difference is reduced to 0 however when 8 digits of precision are used it can be seen that there is in fact a difference between the two results f Try this problem on a computer How small must the change h in radius be for the same phenomenon to occur Try both single precision and double precision if available For Double Precision Ah 00001km Ah 000001km gtgt a4piEE7llllquot2 gtgt a4pi337l l 2 a a gtgt b4piES7lquot2 gtgt h4piES7lquot2 b b El354353787El7el 8 EHHD43337817EU73DE gtgt c8pi537 ll gtgt u8piES7lllll c 3 IEHEEEIEZEHSEBE LBUUEIEEEIEZEHSEH gtgt xbB gtgt xbc X x i t av t t i a m iu a 39 graph QBMW U5 la 90 lb lO n f T Numerical Computing 12309 Section 2 Homework 1 As can be seen on the chart on the previous page a change in the radius of 00001km will be represented by a nonzero difference so it will take a value of approximately 000001km for the quotphenomenonquot to occur and a nonzero difference to be represented as 0 For Single Precision Ah 01km gtgt a4pil337llquot2 a 5El le3734EBEl723ll8 gtgt Asinglelal A ig i gtgt b4pil337ll 2 b EilElEl43l337Bl7Hl7ellB gtgt Bsingeb E 505334352 gtgt c3pi537ll g lEEIEEElEZEHBEElel4 gtgt Esinglec E lEllHEE7Bl4 gtgt xBE X Ah 001km gtgt a4pi537lllquot2 a 5BEIIJEEIE47SBEESEBIIB gtgt Asin eal A 335385352 gtgt b4piE37l 2 b EHlll43l3378l757ell8 gtgt Esingleb B EDEEID4352 gtgtc3lpo537ntnl B lEHEEEllEZElESEBEll3 gtgt Esinglec l lEEEEEellB gtgtxBE x SBSEUSSE As can be seen in the chart above a difference of approximately 001km is necessary for the phenomenon to occur when using single precision because of the reduction in significant digits