cise301 unit 1a term123
TRANSCRIPT
-
7/27/2019 CISE301 Unit 1a Term123
1/24
1
CISE301: Numerical Methods
Unit 1:Introduction to Numerical methods and
Review of Taylor Series
Lectures 1-3:
Dr.Sayyid Anas Vaqar
Dr.Sayyid Anas Vaqar OfficeHours
UTR8:009:00AMand11:0011:11:30AM ,
orbyappointment
Office 221481
Tel 8607876
Email:
usetheBlackboardemail
9/9/2013 2
-
7/27/2019 CISE301 Unit 1a Term123
2/24
2
GradingPolicy Standard
Grading
policy
will
be
adapted
Attendance 5%(1%perabsence)
Quizzes 10%
HWs/CompWork 10%
MajorI 20% topics1,2,3(Date: Monday24th ofJune2013
Time: 4:30PM 6:30PM)
MajorII 25% topics4,5,6(Date: Saturday13th ofJuly 2013
Time: 9:30PM 11:30PM)
Final
30%
topics
7,8,9
(DatesetbyRegistrar,Duration=2hoursTime: 7:00PM9:00PM)
Range Grade
[95,100] A+
A
B+
B
C+
C
D+
D
[0,50 ) F9/9/2013 3
RulesandRegulations
Nomakeupquizzes/exams
DNgrade 4 unexcusedabsences
HomeworkAssignments
are
due
to
the
beginningofthelectures.Absenceisnotanexcusefornotsubmitting
theHomework. Latesubmissionmaynotbeaccepted
9/9/2013 4
-
7/27/2019 CISE301 Unit 1a Term123
3/24
3
LearningObjectives
DefinenumericalmethodsandlisttopicscoveredinthecourseCompareanalyticsolutionsandnumericalsolutions;DiscusstheneedfornumericalmethodsDiscusstheneedforanalyzingthequalityofnumericalsolutions;
Reading
Assignment:pages310oftextbook
AnalyticalSolutions Analyticalmethodsgiveexactsolutions
Example:Analyticalmethodtoevaluatetheintegral
Numericalmethodsaremathematicalprocedurestocalculateapproximatesolution
(TrapezoidMethod)
3
1
3
0
3
1
3
1
0
31
0
2 x
dxx
21)1()0(
201 221
0
2 dxx
9/9/2013 6
-
7/27/2019 CISE301 Unit 1a Term123
4/24
4
Numerical
MethodsNumericalMethods:Algorithmsthatareusedtoobtainapproximatesolutions ofamathematicalproblem.
Whydoweneedthem?
1.Noanalyticalsolutionexists,
2.Ananalyticalsolutionisdifficulttoobtain
ornotpractical.
9/9/2013 7
WhatdoweneedBasicNeedsintheNumericalMethods:
Practical:canbecomputedinareasonableamountoftime.
Accurate:
Goodapproximatetothetruevalue
Informationabouttheapproximation error
(Bounds,error
order,
)is
available
9/9/2013 8
-
7/27/2019 CISE301 Unit 1a Term123
5/24
5
Outlines
of
the
Course1.TaylorTheorem,NumberRepresentation,Errors
2.SolutionofnonlinearEquations
3.SolutionoflinearEquations
4.LeastSquarescurvefitting
5.Interpolation
6.NumericalDifferentiation
7.NumericalIntegration
8.Solution
of
ordinary
differential
equations
9.SolutionofPartialdifferentialequations
9/9/2013 9
SolutionofNonlinearEquations Somesimpleequationscanbesolvedanalytically
Many
other
equations
have
no
analytical
solution
9/9/2013 10
31
)1(2
)3)(1(444:solutionAnalytic
034
2
2
xandx
roots
xx
solutionanalyticNo052 29
xex
xx
-
7/27/2019 CISE301 Unit 1a Term123
6/24
6
MethodsforsolvingNonlinearEquationso BisectionMethod
o NewtonRaphsonMethod
o SecantMethod
9/9/2013 11
SolutionofSystemsofLinearEquations
9/9/2013 12
unknowns?1000inequations1000
haveweifdoWhat to
123,2
523,3
asitsolvecanWe
52
3
12
2221
21
21
xx
xxxx
xx
xx
-
7/27/2019 CISE301 Unit 1a Term123
7/24
7
Cramers
Rule
is
not
practical
9/9/2013 13
compute.toyears10thanmoreneedscomputersuperA
needed.aretionsmultiplica102.38system,30by30asolveTo
tions.multiplica1)N!1)(N(NneedweunknownsNinequationsNsolveTo
2
21
11
51
31
,1
21
11
25
13
52
3
systemthesolvetousedbecanRulesCramer'
20
35
21
21
21
xx
xx
xx
Cramers Ruleis not practicalfor largeproblems
MethodsforsolvingSystemsofLinearEquations
o NaiveGaussianElimination
o GaussianEliminationwithScaledPartialpivoting
o AlgorithmforTridiagonalEquations
9/9/2013 14
-
7/27/2019 CISE301 Unit 1a Term123
8/24
8
CurveFitting
Givenasetofdata
Selectacurvethatbestfitthedata.
Onechoiceisfindthecurvesothat thesumofthe
square
of
the
error
is
minimized.
9/9/2013 15
xi 0 1 2
yi 0.5 10.3 15.3
Interpolation
Givenasetofdata
findapolynomial
P(x)whosegraphpasses
throughalltabulatedpoints.
9/9/2013 16
xi 0 1 2
yi 0.5 10.3 15.3
tablein theis)( iii xifxPy
-
7/27/2019 CISE301 Unit 1a Term123
9/24
9
Methodsfor
Curve
Fitting
o LeastSquares
o LinearRegression
o NonlinearleastSquaresProblems
o Interpolation
o Newtonpolynomialinterpolation
o Lagrangeinterpolation
9/9/2013 17
Integration
Somefunctionscanbeintegratedanalytically
9/9/2013 18
?
solutionsanalyticalnohavefunctionsmanyBut
dxe
xxdx
a
x
0
3
1
23
1
2
42
1
2
9
2
1
-
7/27/2019 CISE301 Unit 1a Term123
10/24
10
Methodsfor
Numerical
Integration
o UpperandLowerSums
o TrapezoidMethod
o RombergMethod
o GaussQuadrature
9/9/2013 19
SolutionofOrdinaryDifferentialEquations
9/9/2013 20
onlycasesspecial
foravailablearesolutionsAnalytical*
equationsthesatisfiesthatfunctionais
0)0(;1)0(
0)(2)(3)(
equationaldifferentitheosolution tA
x(t)
xx
txtxtx
-
7/27/2019 CISE301 Unit 1a Term123
11/24
11
SolutionofPartialDifferential
EquationsPartialDifferentialEquationsaremoredifficulttosolve
thanordinarydifferentialequations
9/9/2013 21
)sin()0,(,0),1(),0(
022
2
2
2
xxututu
t
u
x
u
Summary
NumericalMethods:
Algorithmsthatareusedtoobtainnumericalsolutionofamathematicalproblem.
Weneedthemwhen
Noanalyticalsolutionexistor itisdifficulttoobtain
analyticalsolution.
1. Introduction
2. SolutionofnonlinearEquations
3. SolutionoflinearEquations
4. LeastSquaresCurvefitting
5. Interpolation
6. NumericalIntegration
7. Numerical
Differentiation
8. Solutionofordinarydifferentialequations
9. SolutionofPartialdifferentialequations
9/9/2013 22
Topics Covered in the Course
-
7/27/2019 CISE301 Unit 1a Term123
12/24
12
NumberRepresentation NormalizedFloatingPointRepresentation SignificantDigits AccuracyandPrecision RoundingandChopping
Readingassignment:Chapter3
RepresentingRealNumbers
Youarefamiliarwiththedecimalsystem
DecimalSystem Base=10,Digits(0,1,9)
StandardRepresentations
21012 10510410210110345.312
partpart
fractionintegralsign
54.213
9/9/2013 24
-
7/27/2019 CISE301 Unit 1a Term123
13/24
13
NormalizedFloatingPointRepresentation
NormalizedFloating
Point
Representation
Nointegralpart,
Advantage Efficientinrepresentingverysmallorverylargenumbers
integer:,0
exponentmantissasign
10.0
1
4321
nd
ddddn
9/9/2013 25
CalculatorExample supposeyouwanttocompute
3.578*2.139
usingacalculatorwithtwodigitfractions
9/9/2013 26
3.57 * 2.13 7.60=
7.653342True answer
-
7/27/2019 CISE301 Unit 1a Term123
14/24
14
BinarySystem
BinarySystem Base=2,Digits{0,1}
10 11 bb
exponentmantissasign
21.0 432n
bbb
9/9/2013 27
1010
321
2 )625.0()212021()101.0(
Fact
Numberthathavefiniteexpansioninonenumberingsystemmayhaveaninfiniteexpansioninanothernumberingsystem
Youcanneverrepresent0.1exactlyinanycomputer
9/9/2013 28
210 ...)011000001100110.0()1.0(
-
7/27/2019 CISE301 Unit 1a Term123
15/24
15
ConvertingDecimalFractionstoBinary
A simple,stepbystepmethodforcomputingthebinaryexpansionontherighthandsideofthepoint.Wewillillustratethemethodbyconvertingthedecimalvalue.625toabinaryrepresentation..
Step1:Beginwiththedecimalfractionandmultiplyby2.Thewholenumberpartoftheresultisthefirstbinarydigittotherightofthepoint.
Because.625x2= 1.25,thefirstbinarydigittotherightofthepointisa 1.Sofar,wehave.625=.1???...(base2).
Step2:Nextwedisregardthewholenumberpartofthepreviousresult(the1inthiscase)andmultiplyby2onceagain.Thewholenumberpartofthisnewresultisthe secondbinarydigittotherightofthepoint.Wewillcontinuethisprocessuntilwegetazeroasourdecimalpartoruntilwerecognizeaninfiniterepeatingpattern.Because.25x2= 0.50,thesecondbinarydigittotherightofthepointisa 0.Sofar,wehave.625=.10??...(base2).
Step3:Disregardingthewholenumberpartofthepreviousresult(thisresultwas.50sothereactuallyisnowholenumberparttodisregardinthiscase),wemultiplyby2onceagain.Thewholenumberpartoftheresultisnowthenextbinarydigittotherightofthepoint.
Because.50x2= 1.00,thethirdbinarydigittotherightofthepointisa 1.Sonowwehave.625=.101??...(base2).
Step4:Infact,wedonotneedaStep4.WearefinishedinStep3,becausewehad0asthefractionalpartofourresultthere.
Hencetherepresentationof.625=.101(base2).
9/9/2013 29
ConvertingDecimalFractionstoBinary InfiniteBinaryFractions
Themethodwejustexploredcanbeusedtodemonstrate howsomedecimalfractionswillproduceinfinite binaryfractionexpansions.Weillustrate byusingthatmethodtoseethatthebinaryrepresentation ofthedecimalfraction1/10is,infact,infinite.
Step1:Beginwiththedecimalfractionandmultiplyby2.Thewholenumberpartoftheresultisthefirstbinarydigittotherightofthepoint.Because.1x2= 0.2,thefirstbinarydigittotherightofthepointisa 0.Sofar,wehave.1(decimal)=.0???...(base2).
Step2:Nextwedisregardthewholenumberpartofthepreviousresult(0inthiscase)andmultiplyby2onceagain.Thewholenumberpartofthisnewresultisthe secondbinarydigittotherightofthepoint.Wewillcontinuethisprocessuntilwegetazeroasourdecimalpartoruntilwerecognizeaninfiniterepeatingpattern. Because.2x2= 0.4,thesecondbinarydigittotherightofthepointisalsoa 0.Sofar,wehave.1(decimal)=.00??...(base2).
Step3:Disregardingthewholenumberpartoftheprevious result(againa0),wemultiplyby2onceagain.Thewholenumberpartoftheresultisnowthenextbinarydigittotherightofthepoint.Because.4x2= 0.8,thethirdbinarydigittotherightofthepointisalsoa 0.
So
now
we
have
.1
(decimal)
=
.000??
.
.
.
(base
2)
. Step4:Wemultiplyby2onceagain,disregarding thewholenumberpartofthepreviousresult(againa0inthiscase).Because
.8x2= 1.6,thefourthbinarydigittotherightofthepointisa 1.Sonowwehave.1(decimal)=.0001??...(base2).
Step5:Wemultiplyby2onceagain,disregarding thewholenumberpartofthepreviousresult(a1inthiscase).Because.6x2= 1.2,thefifthbinarydigittotherightofthepointisa 1.Sonowwehave.1(decimal)=.00011??...(base2).
Step6:Wemultiplyby2onceagain,disregarding thewholenumberpartofthepreviousresult.Let'smakeanimportantobservationhere.Noticethatthisnextsteptobeperformed(multiply2.x2)is exactlythesameactionwehadinstep2.Wearethenboundtorepeatsteps25,thenreturntoStep2againindefinitely.Inotherwords,wewillnevergeta0asthedecimalfractionpartofourresult.Insteadwewilljustcyclethroughsteps25forever.Thismeanswewillobtainthesequence ofdigitsgeneratedinsteps25,namely0011,overandover.Hence,thefinalbinaryrepresentation willbe.
.1(decimal)=.00011001100110011...(base2).
9/9/2013 30
-
7/27/2019 CISE301 Unit 1a Term123
16/24
16
7BitRepresentation(sign:1bit,Mantissa3bits,exponent3bits)
9/9/2013 31
exponentmantissasign
21.0 432n
bbb
7Bit
Representation
(sign:1bit,Mantissa3bits,exponent3bits)
9/9/2013 32
-
7/27/2019 CISE301 Unit 1a Term123
17/24
17
Representation
9/9/2013 33
Hypothetical Machine (real computers use 23 bit mantissa)
Mantissa 2 bits exponent 2 bit sign 1 bit
Possible machine numbers
.25 .3125 .375 .4375 .5 .625 .75 .875
1 1.25 1.5 1.75
Remarks
Numbersthatcanbeexactlyrepresentedarecalledmachinenumbers
Differencebetweenmachinenumbersisnotuniform sumofmachinenumbersisnotnecessarilyamachinenumber
0.25+.3125=0.5625
9/9/2013 34
Machinenumber
Machinenumber
NOTMachinenumber
-
7/27/2019 CISE301 Unit 1a Term123
18/24
18
Significant
Digits
9/9/2013 35
Significant digits are those digits that can beused with confidence.
0 1 2 3 4
Length of green rectangle = 3.45
significant
LossofSignificance Mathematicaloperationsmayleadtoreducingthe
numberofsignificantdigits
9/9/2013 36
0.123466 E+02 6 significant digits
0.123445 E+02 6 significant digits
0.000021E+02 2 significant digits
0. 210000E-02
Subtracting nearly equal numbers causes loss of significance
-
7/27/2019 CISE301 Unit 1a Term123
19/24
19
Accuracy
and
Precision
9/9/2013 37
Accuracy is related to closeness to the true value
Precision is related to the closeness to other estimatedvalues
AccuracyandPrecision
9/9/2013 38
Accuracy isrelated tocloseness to thetrue value
Precision isrelated to thecloseness to
other estimatedvalues
-
7/27/2019 CISE301 Unit 1a Term123
20/24
20
AccuracyandPrecision
9/9/2013 39
Better
Precision
Betteraccuracy
Accuracy isrelated tocloseness to thetrue value
Precision isrelated to thecloseness toother estimatedvalues
RoundingandChopping Rounding: Replacethenumberbythenearest
machinenumber
Chopping:Throwallextradigits
9/9/2013 40
0 1 2
True 1.1681
Rounding (1.2) Chopping (1.1)
-
7/27/2019 CISE301 Unit 1a Term123
21/24
21
ErrorDefinitions
TrueError
canbe
computed
if
the
true
value
is
known
100*valuetrue
ionapproximatvaluetrue
ErrorelativePercent RAbsolute
ionapproximatvaluetrue
ErrorTrueAbsolute
t
tE
9/9/2013 41
100*valuetrue
ionapproximatvaluetrue
ErrorRelativeTrue
ionapproximatvaluetrue
ErrorTrue
t
tE
ErrorDefinitionsEstimatederrorUsedwhenthetruevalueisnotknown
100*estimatecurrent
estimateprevoiusestimatecurrent
ErrorelativePercent RAbsoluteEstimated
estimateprevoiusestimatecurrent
ErrorAbsoluteEstimated
a
aE
9/9/2013 42
100*estimatecurrent
estimateprevoiusestimatecurrent
ErrorRelativePercenteApproximat
estimateprevoiusestimatecurrent
ErrorA
a
aE
pproximate
-
7/27/2019 CISE301 Unit 1a Term123
22/24
22
Errorasstoppingcriterion
9/9/2013 43
Itis
often
useful
to
employ
the
absolute
value
error
as
astoppingcriterion.
Weareinterestedinwhetherthepercentabsoluteerrorislowerthanaprespecifiedpercenttolerance s
sa
Notation
Wesaytheestimateiscorrecttondecimaldigitsif
Wesaytheestimateiscorrecttondecimaldigitsrounded if
n 1021Error
n 10Error
9/9/2013 44
Wesaytheestimateiscorrecttondecimaldigitsif
Wesaytheestimateiscorrecttondecimaldigitsrounded if
n 10Error
n 102
1Error
-
7/27/2019 CISE301 Unit 1a Term123
23/24
23
Notation
Wesay
the
estimate
is
correct
to
ndecimal
digits
if
Wesaytheestimateiscorrecttondecimaldigitsrounded if
n 102
1Error
n 10Error
9/9/2013 45
Wesaytheestimateiscorrecttoatleastnsignificantdigitsif:
Summary
9/9/2013 46
Number Representation
Number that have finite expansion in one numbering system may
have an infinite expansion in another numbering system.
Normalized Floating Point Representation Efficient in representing very small or very large numbers
Difference between machine numbers is not uniform Representation error depends on the number of bits used in the
mantissa.
-
7/27/2019 CISE301 Unit 1a Term123
24/24
Summary Accuracy Precision
Rounding Chopping
ErrorDefinitions:
Absolutetrueerror
TruePercentrelativeerror
Estimatedabsoluteerror
Estimatedpercentrelativeerror
9/9/2013 47