SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
9-Month Program, Intake40, CEI Track
SCIENTIFIC COMPUTING II
NUMERICAL TOOLS & ALGORITHMS
Ahmed Gamal Abdel Gawad
CONTENTS
ABOUT ME
Bisection Method using C#
False Position Method using C#
Gauss Seidel Method using MATLAB
Secant Mod Method using MATLAB
Report on Numerical Errors
Optimization using Golden-Section Algorithm
with Application on MATLAB
 TEACHING ASSISTANT AT MENOUFIYA UNIVERSITY.
 GRADE: EXCELLENT WITH HONORS.
 BEST MEMBER AT ‘UTW-7 PROGRAM’, ECG.
 ITI 9-MONTH PROGRAM, INT40, CEI TRACK STUDENT.
 AUTODESK REVIT CERTIFIED PROFESSIONAL.
 BACHELOR OF CIVIL ENGINEERING, 2016.
 LECTURER OF ‘DESIGN OF R.C.’ COURSE, YOUTUBE.
ABOUT ME
Bisection Method C#
static double Bisection(double x1, double x2, int maxIterations, double tolerance, out int count)
{
double f1 = Function(x1);
double f2 = Function(x2);
double xm = 0.0;
double fm;
if (f1 * f2 > 0.0) throw new InvalidOperationException("No Bracket");
count = 0;
for (int i = 0; i < maxIterations; i++)
{
count++;
xm = (x1 + x2) / 2;
fm = Function(xm);
if (Math.Abs(fm) <= tolerance) break;
if (f1 * fm > 0)
{
x1 = xm;
f1 = fm;
}
else
{
x2 = xm;
f2 = fm;
}
}
return xm;
}
False Position Method C#
static double FalsePosition(double x1, double x2, int maxIterations, double tolerance, out int count)
{
double f1 = Function(x1);
double f2 = Function(x2);
double xp = 0.0;
double fp;
double s;
if (f1 * f2 > 0.0) throw new InvalidOperationException("No Bracket");
count = 0;
for (int i = 0; i < maxIterations; i++)
{
count++;
s = (f2 - f1) / (x2 - x1);
xp = x1 - f1 / s;
fp = Function(xp);
if (Math.Abs(fp) <= tolerance) break;
if (f1 * fp > 0)
{
x1 = xp;
f1 = fp;
}
else
{
x2 = xp;
f2 = fp;
}
}
return xp;
}
Gauss Seidel
function[x,nit] = gseidel(A,b,nmax,tol)
% Function to run gseidel method
[nr, nc] = size(A);
if (nc ~= nr), error('A is NOT Square'); end % check square matrix
x = zeros(nr,1); % Vector of inital values of x
for k = 1:nr
x(k) = b(k)/A(k,k); % Initial values of x
end
err = zeros(nr,1); % Vector of errors
errmax = 1; % Initial value for errmax > tolerance
nit=0.0; % No of iterations
while (errmax > tol && nit < nmax)
xold = x; % Set xold to the previous values of x
nit = nit + 1; % Increse No of iterations by 1
for k = 1:nr
sum = A(k,:)*x; % Calculate the sum term
sum = sum - A(k,k)*x(k); % Exclude akk and xk from calculations
x(k) = (b(k) - sum)/A(k,k); % Calculate x new values
err(k) = abs(x(k)) - abs(xold(k)); % Record vector of errors
end
errmax = max(abs(err));
end
end
Secant Mod
function [xr,nit]= secantmod(func,xo,deltax,kmax,etol)
% Secant method to find root of function “func” using
% one starting point xo and small perturbation ?x for
% max iterations kmax
xv1 = xo;
xv2 = xo + deltax;
nit = 0;
for k = 1:kmax
nit = nit +1;
vf1 = func(xv1);
vf2 = func(xv2);
vsec = (vf2 - vf1) / deltax;
if (abs(vsec) <= 10^(-15)),error('Zero Secant Slope');end
xnew = xv1 - vf1/vsec;
vfnew = func(xnew);
if abs(vfnew) <= etol
xr = xnew;
break
end
xv1 = xnew;
xv2 = xnew + deltax;
end
end
Report on Numerical Error
Truncation Error
The word 'Truncate' means 'to shorten'. Truncation error refers to
an error in a method, which occurs because some number/series
of steps (finite or infinite) is truncated (shortened) to a fewer
number. Such errors are essentially algorithmic errors and we can
predict the extent of the error that will occur in the method. For
instance, if we approximate the sine function by the first two non-
zero term of its Taylor series, as in sin 𝑥 = 𝑥 −
1
6
𝑥3 for small x,
the resulting error is a truncation error. It is present even with
infinite-precision arithmetic, because it is caused by truncation of
the infinite Taylor series to form the algorithm.
Report on Numerical Error
Roundoff Error
A roundoff error, also called rounding error, is the difference
between the result produced by a given algorithm using exact
arithmetic and the result produced by the same algorithm using
finite-precision, rounded arithmetic. Rounding errors are due to
inexactness in the representation of real numbers and the
arithmetic operations done with them. This is a form of
quantization error. When using approximation equations or
algorithms, especially when using finitely many digits to
represent real numbers (which in theory have infinitely many
digits), one of the goals of numerical analysis is to estimate
computation errors. Computation errors, also called numerical
errors, include both truncation errors and roundoff errors.
Report on Numerical Error
Notation Representation Approximation Error
1/7 0.142 857 142 857 142 857……. 0.142 857 0.000 000 142 857
ln 2
0.693 147 180 559 945 309 41...
0.693 147
0.000 000 180 559 945 309 41..
.
log10 2
0.301 029 995 663 981 195 21...
0.3010
0.000 029 995 663 981 195 21..
.
3√2
1.259 921 049 894 873 164 76...
1.25992
0.000 001 049 894 873 164 76..
.
√2
1.414 213 562 373 095 048 80...
1.41421
0.000 003 562 373 095 048 80..
.
e
2.718 281 828 459 045 235 36...
2.718 281 828 459 045
0.000 000 000 000 000 235 36..
.
π
3.141 592 653 589 793 238 46...
3.141 592 653 589 793
0.000 000 000 000 000 238 46..
.
Report on Numerical Error
Accuracy and Precision
Measurements and calculations can be characterized with regard
to their accuracy and precision. Accuracy refers to how closely a
value agrees with the true value. Precision refers to how closely
values agree with each other. The following figures illustrate the
difference between accuracy and precision. In the first figure, the
given values (black dots) are more accurate; whereas in the
second figure, the given values are more precise. The term error
represents the imprecision and inaccuracy of a numerical
computation.
Report on Numerical Error
Accuracy Precision
Report on Numerical Error
Real world example: Patriot missile failure due to
magnification of roundoff error
On 25 February 1991, during the Gulf
War, an American Patriot missile
battery in Dharan, Saudi Arabia, failed
to intercept an incoming Iraqi Scud
missile. The Scud struck an American
Army barracks and killed 28 soldiers.
It turns out that the cause was an
inaccurate calculation of the time
since boot due to computer
arithmetic errors.
Optimization using Golden-
Section Algorithm
Euclid’s definition of the golden ratio is based
on dividing a line into two segments so that
the ratio of the whole line to the larger
segment is equal to the ratio of the larger
segment to the smaller segment. This ratio is
called the golden ratio.
Optimization using Golden-
Section Algorithm
The actual value of the golden ratio can be
derived by expressing Euclid’s definition as
𝑙1+𝑙2
𝑙1
=
𝑙1
𝑙2
Multiplying by
𝑙1
𝑙2
and collecting terms yields
∅2 − ∅ − 1 = 0
Where ∅ = 𝑙1/𝑙2 .The positive root of this
equation is the golden ratio:
∅ =
1+ 5
2
= 1.61803398874989
Optimization using Golden-
Section Algorithm
The golden-section search is similar in spirit to
the bisection approach for locating roots. Recall
that bisection hinged on defining an interval,
specified by a lower guess (xl) and an upper
guess (xu) that bracketed a single root. The
presence of a root between these bounds was
verified by determining that f (xl) and f (xu) had
different signs. The root was then estimated as
the midpoint of this interval:
𝑥 𝑟 =
𝑥 𝑢 + 𝑥𝑙
2
Optimization using Golden-
Section Algorithm
The key to making this approach efficient is the
wise choice of the intermediate points. As in
bisection, the goal is to minimize function
evaluations by replacing old values with new
values. For bisection, this was accomplished by
choosing the midpoint. For the golden-section
search, the two intermediate points are chosen
according to the golden ratio:
𝑥1 = 𝑥𝑙 + 𝑑
𝑥2 = 𝑥 𝑢 − 𝑑
where
𝑑 = (∅ − 1)(𝑥 𝑢 − 𝑥𝑙)
Optimization using Golden-
Section Algorithm
The function is evaluated at these two interior
points. Two results can occur:
1. If, as in Fig. 7.6a, f (x1)< f (x2), then f (x1) is
the minimum, and the domain of x to the
left of x 2, from xl to x2, can be eliminated
because it does not contain the minimum.
For this case, x2 becomes the new xl for the
next round.
2. If f (x2)< f (x1), then f (x2) is the minimum
and the domain of x to the right of x1, from
x 1 to xu would be eliminated. For this case,
x1 becomes the new xu for the next round.
Optimization using Golden-
Section Algorithm
Optimization using Golden-
Section Algorithm
function [x,fx,ea,iter]=goldmin(f,xl,xu,es,maxit)
% goldmin: minimization golden section search
% uses golden section search to find the minimum of f
if nargin<3,error('at least 3 input arguments required'),end
if nargin<4||isempty(es), es=0.0001;end
if nargin<5||isempty(maxit), maxit=50;end
phi=(1+sqrt(5))/2;
iter=0;
while(1)
d = (phi-1)*(xu - xl);
x1 = xl + d;
x2 = xu - d;
if f(x1) < f(x2)
xopt = x1;
xl = x2;
else
xopt = x2;
xu = x1;
end
iter=iter+1;
if xopt~=0, ea = (2 - phi) * abs((xu - xl) / xopt) * 100;end
if ea <= es || iter >= maxit,break,end
end
x=xopt;fx=f(xopt);
MATLAB Function
Optimization using Golden-
Section Algorithm
Use the following parameter values for your calculation: g =
9.81 m/s2, z0 = 100 m, v0 = 55 m/s, m = 80 kg, and c = 15 kg/s.
Example
Optimization using Golden-
Section Algorithm
Command Window
>> g=9.81;v0=55;m=80;c=15;z0=100;
>> z=@(t) -(z0+m/c*(v0+m*g/c)*(1-exp(-c/m*t))-m*g/c*t);
>> [xmin,fmin,ea,iter]=goldmin(z,0,8)
xmin =
3.8317
fmin =
-192.8609
ea =
6.9356e-05
iter =
29
Notice how because this is a maximization, we have
entered the negative of the equation. Consequently,
fmin corresponds to a maximum height of 192.8609.
THANK YOU 
linkedin.com/in/aGaabdelgawad/

Mais conteúdo relacionado

Mais procurados

03 truncation errors
03 truncation errors03 truncation errors
03 truncation errorsmaheej
 
Numerical method-Picards,Taylor and Curve Fitting.
Numerical method-Picards,Taylor and Curve Fitting.Numerical method-Picards,Taylor and Curve Fitting.
Numerical method-Picards,Taylor and Curve Fitting.Keshav Sahu
 
Curve fitting
Curve fittingCurve fitting
Curve fittingdusan4rs
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fittingAmeen San
 
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)Minhas Kamal
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3Yasser Ahmed
 
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING Anu Bhatt
 
Bisection method in maths 4
Bisection method in maths 4Bisection method in maths 4
Bisection method in maths 4Vaidik Trivedi
 
Maxima & Minima of Functions - Differential Calculus by Arun Umrao
Maxima & Minima of Functions - Differential Calculus by Arun UmraoMaxima & Minima of Functions - Differential Calculus by Arun Umrao
Maxima & Minima of Functions - Differential Calculus by Arun Umraossuserd6b1fd
 

Mais procurados (20)

Curvefitting
CurvefittingCurvefitting
Curvefitting
 
statistics assignment help
statistics assignment helpstatistics assignment help
statistics assignment help
 
ilovepdf_merged
ilovepdf_mergedilovepdf_merged
ilovepdf_merged
 
Probability Assignment Help
Probability Assignment HelpProbability Assignment Help
Probability Assignment Help
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errors
 
Numerical method-Picards,Taylor and Curve Fitting.
Numerical method-Picards,Taylor and Curve Fitting.Numerical method-Picards,Taylor and Curve Fitting.
Numerical method-Picards,Taylor and Curve Fitting.
 
Curve fitting
Curve fittingCurve fitting
Curve fitting
 
Numerical approximation
Numerical approximationNumerical approximation
Numerical approximation
 
Programming Assignment Help
Programming Assignment HelpProgramming Assignment Help
Programming Assignment Help
 
Numerical method
Numerical methodNumerical method
Numerical method
 
algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
 
Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fitting
 
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3
 
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
 
Bisection method in maths 4
Bisection method in maths 4Bisection method in maths 4
Bisection method in maths 4
 
Maxima & Minima of Functions - Differential Calculus by Arun Umrao
Maxima & Minima of Functions - Differential Calculus by Arun UmraoMaxima & Minima of Functions - Differential Calculus by Arun Umrao
Maxima & Minima of Functions - Differential Calculus by Arun Umrao
 
probability assignment help (2)
probability assignment help (2)probability assignment help (2)
probability assignment help (2)
 
Statistics Homework Help
Statistics Homework HelpStatistics Homework Help
Statistics Homework Help
 

Semelhante a Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA

Data_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptData_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptISHANAMRITSRIVASTAVA
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
Sparse data formats and efficient numerical methods for uncertainties in nume...
Sparse data formats and efficient numerical methods for uncertainties in nume...Sparse data formats and efficient numerical methods for uncertainties in nume...
Sparse data formats and efficient numerical methods for uncertainties in nume...Alexander Litvinenko
 
C language numanal
C language numanalC language numanal
C language numanalaluavi
 
Opt Assgnment #-1 PPTX.pptx
Opt Assgnment #-1 PPTX.pptxOpt Assgnment #-1 PPTX.pptx
Opt Assgnment #-1 PPTX.pptxAbdellaKarime
 
Decimation and Interpolation
Decimation and InterpolationDecimation and Interpolation
Decimation and InterpolationFernando Ojeda
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyappasami
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsAmol Gaikwad
 
Count-Distinct Problem
Count-Distinct ProblemCount-Distinct Problem
Count-Distinct ProblemKai Zhang
 
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...Naoki Shibata
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxskilljiolms
 
DAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptxDAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptxvaishnavi339314
 
PMHMathematicaSample
PMHMathematicaSamplePMHMathematicaSample
PMHMathematicaSamplePeter Hammel
 

Semelhante a Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA (20)

Data_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptData_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.ppt
 
99995320.ppt
99995320.ppt99995320.ppt
99995320.ppt
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Sparse data formats and efficient numerical methods for uncertainties in nume...
Sparse data formats and efficient numerical methods for uncertainties in nume...Sparse data formats and efficient numerical methods for uncertainties in nume...
Sparse data formats and efficient numerical methods for uncertainties in nume...
 
C language numanal
C language numanalC language numanal
C language numanal
 
Daa chapter11
Daa chapter11Daa chapter11
Daa chapter11
 
Opt Assgnment #-1 PPTX.pptx
Opt Assgnment #-1 PPTX.pptxOpt Assgnment #-1 PPTX.pptx
Opt Assgnment #-1 PPTX.pptx
 
Decimation and Interpolation
Decimation and InterpolationDecimation and Interpolation
Decimation and Interpolation
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Regression
RegressionRegression
Regression
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 
Count-Distinct Problem
Count-Distinct ProblemCount-Distinct Problem
Count-Distinct Problem
 
Algorithms DM
Algorithms DMAlgorithms DM
Algorithms DM
 
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
DAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptxDAA - UNIT 4 - Engineering.pptx
DAA - UNIT 4 - Engineering.pptx
 
PMHMathematicaSample
PMHMathematicaSamplePMHMathematicaSample
PMHMathematicaSample
 
Slide2
Slide2Slide2
Slide2
 
Error analysis
Error analysisError analysis
Error analysis
 
Hamlet_Khachatryan_57--61
Hamlet_Khachatryan_57--61Hamlet_Khachatryan_57--61
Hamlet_Khachatryan_57--61
 

Mais de Ahmed Gamal Abdel Gawad

QGIS Plugins - GIS II Advanced - CEI40 - AGA
QGIS Plugins - GIS II Advanced - CEI40 - AGAQGIS Plugins - GIS II Advanced - CEI40 - AGA
QGIS Plugins - GIS II Advanced - CEI40 - AGAAhmed Gamal Abdel Gawad
 
Application of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGA
Application of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGAApplication of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGA
Application of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGAAhmed Gamal Abdel Gawad
 
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...Ahmed Gamal Abdel Gawad
 
الفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحةالفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحةالفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحة
الفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحةالفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحة
الفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحة
الفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحةالفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحة
الفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحة
الفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحةالفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحة
الفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحة
الفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحةالفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحة
الفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحة
الفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحةالفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحة
الفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحةالفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحةالفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 
الفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحة
الفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحةالفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحة
الفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحةAhmed Gamal Abdel Gawad
 

Mais de Ahmed Gamal Abdel Gawad (16)

Revit Sheets Plugin - CEI40 - AGA
Revit Sheets Plugin - CEI40 - AGARevit Sheets Plugin - CEI40 - AGA
Revit Sheets Plugin - CEI40 - AGA
 
QGIS Plugins - GIS II Advanced - CEI40 - AGA
QGIS Plugins - GIS II Advanced - CEI40 - AGAQGIS Plugins - GIS II Advanced - CEI40 - AGA
QGIS Plugins - GIS II Advanced - CEI40 - AGA
 
Application of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGA
Application of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGAApplication of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGA
Application of GIS in Flood Hazard Mapping - GIS I Fundamentals - CEI40 - AGA
 
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
Structural Optimization using Genetic Algorithms - Artificial Intelligence Fu...
 
Information Delivery Manual
Information Delivery ManualInformation Delivery Manual
Information Delivery Manual
 
Industry Foundation Classes
Industry Foundation ClassesIndustry Foundation Classes
Industry Foundation Classes
 
الفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحةالفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث عشر - القواعد المنفصلة - تصميم المنشآت الخرسانية المسلحة
 
الفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحةالفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني عشر - الأعمدة - تصميم المنشآت الخرسانية المسلحة
 
الفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحة
الفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحةالفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحة
الفصل الحادي عشر - السلالم - تصميم المنشآت الخرسانية المسلحة
 
الفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحة
الفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحةالفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحة
الفصل العاشر - البلاطات المسطحة - تصميم المنشآت الخرسانية المسلحة
 
الفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحة
الفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحةالفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحة
الفصل التاسع - بلاطات الكمرات المتقاطعة - تصميم المنشآت الخرسانية المسلحة
 
الفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحة
الفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحةالفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحة
الفصل الثامن - بلاطات القوالب المفرغة - تصميم المنشآت الخرسانية المسلحة
 
الفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحة
الفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحةالفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحة
الفصل السابع - البلاطات المصمتة - تصميم المنشآت الخرسانية المسلحة
 
الفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحةالفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحة
الفصل الثالث - طريقة إجهادات التشغيل - تصميم المنشآت الخرسانية المسلحة
 
الفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحةالفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحة
الفصل الثاني - المقاطع تحت تأثير عزوم الانحناء - تصميم المنشآت الخرسانية المسلحة
 
الفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحة
الفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحةالفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحة
الفصل الأول - مقدمة في الخرسانة المسلحة - تصميم المنشآت الخرسانية المسلحة
 

Último

Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringJuanCarlosMorales19600
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 

Último (20)

Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineering
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 

Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA

  • 1. 9-Month Program, Intake40, CEI Track SCIENTIFIC COMPUTING II NUMERICAL TOOLS & ALGORITHMS Ahmed Gamal Abdel Gawad
  • 2. CONTENTS ABOUT ME Bisection Method using C# False Position Method using C# Gauss Seidel Method using MATLAB Secant Mod Method using MATLAB Report on Numerical Errors Optimization using Golden-Section Algorithm with Application on MATLAB
  • 3.  TEACHING ASSISTANT AT MENOUFIYA UNIVERSITY.  GRADE: EXCELLENT WITH HONORS.  BEST MEMBER AT ‘UTW-7 PROGRAM’, ECG.  ITI 9-MONTH PROGRAM, INT40, CEI TRACK STUDENT.  AUTODESK REVIT CERTIFIED PROFESSIONAL.  BACHELOR OF CIVIL ENGINEERING, 2016.  LECTURER OF ‘DESIGN OF R.C.’ COURSE, YOUTUBE. ABOUT ME
  • 4. Bisection Method C# static double Bisection(double x1, double x2, int maxIterations, double tolerance, out int count) { double f1 = Function(x1); double f2 = Function(x2); double xm = 0.0; double fm; if (f1 * f2 > 0.0) throw new InvalidOperationException("No Bracket"); count = 0; for (int i = 0; i < maxIterations; i++) { count++; xm = (x1 + x2) / 2; fm = Function(xm); if (Math.Abs(fm) <= tolerance) break; if (f1 * fm > 0) { x1 = xm; f1 = fm; } else { x2 = xm; f2 = fm; } } return xm; }
  • 5. False Position Method C# static double FalsePosition(double x1, double x2, int maxIterations, double tolerance, out int count) { double f1 = Function(x1); double f2 = Function(x2); double xp = 0.0; double fp; double s; if (f1 * f2 > 0.0) throw new InvalidOperationException("No Bracket"); count = 0; for (int i = 0; i < maxIterations; i++) { count++; s = (f2 - f1) / (x2 - x1); xp = x1 - f1 / s; fp = Function(xp); if (Math.Abs(fp) <= tolerance) break; if (f1 * fp > 0) { x1 = xp; f1 = fp; } else { x2 = xp; f2 = fp; } } return xp; }
  • 6. Gauss Seidel function[x,nit] = gseidel(A,b,nmax,tol) % Function to run gseidel method [nr, nc] = size(A); if (nc ~= nr), error('A is NOT Square'); end % check square matrix x = zeros(nr,1); % Vector of inital values of x for k = 1:nr x(k) = b(k)/A(k,k); % Initial values of x end err = zeros(nr,1); % Vector of errors errmax = 1; % Initial value for errmax > tolerance nit=0.0; % No of iterations while (errmax > tol && nit < nmax) xold = x; % Set xold to the previous values of x nit = nit + 1; % Increse No of iterations by 1 for k = 1:nr sum = A(k,:)*x; % Calculate the sum term sum = sum - A(k,k)*x(k); % Exclude akk and xk from calculations x(k) = (b(k) - sum)/A(k,k); % Calculate x new values err(k) = abs(x(k)) - abs(xold(k)); % Record vector of errors end errmax = max(abs(err)); end end
  • 7. Secant Mod function [xr,nit]= secantmod(func,xo,deltax,kmax,etol) % Secant method to find root of function “func” using % one starting point xo and small perturbation ?x for % max iterations kmax xv1 = xo; xv2 = xo + deltax; nit = 0; for k = 1:kmax nit = nit +1; vf1 = func(xv1); vf2 = func(xv2); vsec = (vf2 - vf1) / deltax; if (abs(vsec) <= 10^(-15)),error('Zero Secant Slope');end xnew = xv1 - vf1/vsec; vfnew = func(xnew); if abs(vfnew) <= etol xr = xnew; break end xv1 = xnew; xv2 = xnew + deltax; end end
  • 8. Report on Numerical Error Truncation Error The word 'Truncate' means 'to shorten'. Truncation error refers to an error in a method, which occurs because some number/series of steps (finite or infinite) is truncated (shortened) to a fewer number. Such errors are essentially algorithmic errors and we can predict the extent of the error that will occur in the method. For instance, if we approximate the sine function by the first two non- zero term of its Taylor series, as in sin 𝑥 = 𝑥 − 1 6 𝑥3 for small x, the resulting error is a truncation error. It is present even with infinite-precision arithmetic, because it is caused by truncation of the infinite Taylor series to form the algorithm.
  • 9. Report on Numerical Error Roundoff Error A roundoff error, also called rounding error, is the difference between the result produced by a given algorithm using exact arithmetic and the result produced by the same algorithm using finite-precision, rounded arithmetic. Rounding errors are due to inexactness in the representation of real numbers and the arithmetic operations done with them. This is a form of quantization error. When using approximation equations or algorithms, especially when using finitely many digits to represent real numbers (which in theory have infinitely many digits), one of the goals of numerical analysis is to estimate computation errors. Computation errors, also called numerical errors, include both truncation errors and roundoff errors.
  • 10. Report on Numerical Error Notation Representation Approximation Error 1/7 0.142 857 142 857 142 857……. 0.142 857 0.000 000 142 857 ln 2 0.693 147 180 559 945 309 41... 0.693 147 0.000 000 180 559 945 309 41.. . log10 2 0.301 029 995 663 981 195 21... 0.3010 0.000 029 995 663 981 195 21.. . 3√2 1.259 921 049 894 873 164 76... 1.25992 0.000 001 049 894 873 164 76.. . √2 1.414 213 562 373 095 048 80... 1.41421 0.000 003 562 373 095 048 80.. . e 2.718 281 828 459 045 235 36... 2.718 281 828 459 045 0.000 000 000 000 000 235 36.. . π 3.141 592 653 589 793 238 46... 3.141 592 653 589 793 0.000 000 000 000 000 238 46.. .
  • 11. Report on Numerical Error Accuracy and Precision Measurements and calculations can be characterized with regard to their accuracy and precision. Accuracy refers to how closely a value agrees with the true value. Precision refers to how closely values agree with each other. The following figures illustrate the difference between accuracy and precision. In the first figure, the given values (black dots) are more accurate; whereas in the second figure, the given values are more precise. The term error represents the imprecision and inaccuracy of a numerical computation.
  • 12. Report on Numerical Error Accuracy Precision
  • 13. Report on Numerical Error Real world example: Patriot missile failure due to magnification of roundoff error On 25 February 1991, during the Gulf War, an American Patriot missile battery in Dharan, Saudi Arabia, failed to intercept an incoming Iraqi Scud missile. The Scud struck an American Army barracks and killed 28 soldiers. It turns out that the cause was an inaccurate calculation of the time since boot due to computer arithmetic errors.
  • 14. Optimization using Golden- Section Algorithm Euclid’s definition of the golden ratio is based on dividing a line into two segments so that the ratio of the whole line to the larger segment is equal to the ratio of the larger segment to the smaller segment. This ratio is called the golden ratio.
  • 15. Optimization using Golden- Section Algorithm The actual value of the golden ratio can be derived by expressing Euclid’s definition as 𝑙1+𝑙2 𝑙1 = 𝑙1 𝑙2 Multiplying by 𝑙1 𝑙2 and collecting terms yields ∅2 − ∅ − 1 = 0 Where ∅ = 𝑙1/𝑙2 .The positive root of this equation is the golden ratio: ∅ = 1+ 5 2 = 1.61803398874989
  • 16. Optimization using Golden- Section Algorithm The golden-section search is similar in spirit to the bisection approach for locating roots. Recall that bisection hinged on defining an interval, specified by a lower guess (xl) and an upper guess (xu) that bracketed a single root. The presence of a root between these bounds was verified by determining that f (xl) and f (xu) had different signs. The root was then estimated as the midpoint of this interval: 𝑥 𝑟 = 𝑥 𝑢 + 𝑥𝑙 2
  • 17. Optimization using Golden- Section Algorithm The key to making this approach efficient is the wise choice of the intermediate points. As in bisection, the goal is to minimize function evaluations by replacing old values with new values. For bisection, this was accomplished by choosing the midpoint. For the golden-section search, the two intermediate points are chosen according to the golden ratio: 𝑥1 = 𝑥𝑙 + 𝑑 𝑥2 = 𝑥 𝑢 − 𝑑 where 𝑑 = (∅ − 1)(𝑥 𝑢 − 𝑥𝑙)
  • 18. Optimization using Golden- Section Algorithm The function is evaluated at these two interior points. Two results can occur: 1. If, as in Fig. 7.6a, f (x1)< f (x2), then f (x1) is the minimum, and the domain of x to the left of x 2, from xl to x2, can be eliminated because it does not contain the minimum. For this case, x2 becomes the new xl for the next round. 2. If f (x2)< f (x1), then f (x2) is the minimum and the domain of x to the right of x1, from x 1 to xu would be eliminated. For this case, x1 becomes the new xu for the next round.
  • 20. Optimization using Golden- Section Algorithm function [x,fx,ea,iter]=goldmin(f,xl,xu,es,maxit) % goldmin: minimization golden section search % uses golden section search to find the minimum of f if nargin<3,error('at least 3 input arguments required'),end if nargin<4||isempty(es), es=0.0001;end if nargin<5||isempty(maxit), maxit=50;end phi=(1+sqrt(5))/2; iter=0; while(1) d = (phi-1)*(xu - xl); x1 = xl + d; x2 = xu - d; if f(x1) < f(x2) xopt = x1; xl = x2; else xopt = x2; xu = x1; end iter=iter+1; if xopt~=0, ea = (2 - phi) * abs((xu - xl) / xopt) * 100;end if ea <= es || iter >= maxit,break,end end x=xopt;fx=f(xopt); MATLAB Function
  • 21. Optimization using Golden- Section Algorithm Use the following parameter values for your calculation: g = 9.81 m/s2, z0 = 100 m, v0 = 55 m/s, m = 80 kg, and c = 15 kg/s. Example
  • 22. Optimization using Golden- Section Algorithm Command Window >> g=9.81;v0=55;m=80;c=15;z0=100; >> z=@(t) -(z0+m/c*(v0+m*g/c)*(1-exp(-c/m*t))-m*g/c*t); >> [xmin,fmin,ea,iter]=goldmin(z,0,8) xmin = 3.8317 fmin = -192.8609 ea = 6.9356e-05 iter = 29 Notice how because this is a maximization, we have entered the negative of the equation. Consequently, fmin corresponds to a maximum height of 192.8609.