0% found this document useful (0 votes)
97 views30 pages

L03 NMCP Lecture03-1588102457

Here are some key points about convergence of numerical algorithms: - Convergence means that as the number of iterations increases, the solution gets arbitrarily close to the true solution. - The rate of convergence describes how quickly the error decreases with each iteration. Faster rates of convergence are preferable. - Linear convergence means the error is reduced by a constant factor each iteration. Quadratic or higher order convergence is faster. - Monotonic convergence means the error is strictly decreasing at each step. Some algorithms like bisection are monotonically convergent. - An algorithm may fail to converge if the initial guesses are too far from the solution or if the problem has certain mathematical properties. Proper initialization helps ensure convergence.

Uploaded by

jorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views30 pages

L03 NMCP Lecture03-1588102457

Here are some key points about convergence of numerical algorithms: - Convergence means that as the number of iterations increases, the solution gets arbitrarily close to the true solution. - The rate of convergence describes how quickly the error decreases with each iteration. Faster rates of convergence are preferable. - Linear convergence means the error is reduced by a constant factor each iteration. Quadratic or higher order convergence is faster. - Monotonic convergence means the error is strictly decreasing at each step. Some algorithms like bisection are monotonically convergent. - An algorithm may fail to converge if the initial guesses are too far from the solution or if the problem has certain mathematical properties. Proper initialization helps ensure convergence.

Uploaded by

jorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Métodos Numéricos y

Programación
Unidad 01 - Sesión 03

MSc. Ing. Fernando Valdivia


1. Raices de polinomios de una variable
2. Metodo de Biseccion - Bisection method
3. Metodo de regla falsa - Regula Falsi
4. Metodo de la secante - Secant Method
5. Algoritmos para implementacion en computador
6. Convergencia de algoritmos numericos
7. Scripting and Coding
1. Raices de polinomios de una variable
➢ Method for finding the root of any polynomial
f(x) = axn + bxn-1 + cxn-2 + ... + z
➢ Abel–Ruffini theorem: La imposibilidad de soluciones
algebraicas, grado superior al cuarto. 1799 - 1824.
➢ Solucion numerica computacional, 1960s +
➢ Algoritmos matematicos basicos.
https://iq.opengenus.org/tag/mathematical-algorithm/
Generacion analitica de Polinomios especiales
"Probabilists' Hermite polynomials" Hen ;
“Physicists' Hermite polynomials" Hn ; ecuaciones:

Para n=5:

Se verifica ortogonalidad:
para m=n;

En caso m ≠ n

Para n = 5;
2. Metodo de Biseccion - Bisection method
- Given a continuous function f(x). Find a number x = c such that f(c) = 0.
- The number x = c such that f(c) = 0 is called a root of the equation f(x) = 0 or a zero
of the function f(x).
- Analytical formulas do not exist for polynomials of degree 5 or greater as stated by
Abel–Ruffini theorem
- Most computational methods for the root-finding problem have to be iterative in nature
- The Bisection Method is based on the Bolzano’s theorem for continuous functions
(corollary of Intermediate value theorem).
- Theorem (Bolzano) : If the function f(x) is continuous in [a, b] and f(a)f(b) < 0 (i.e. f(x)
has opposite signs signs at a and b) then a value c ∈ (a, b) exists such that f(c) = 0.
The Bisection Method looks to find the value c for
which the plot of the function f crosses the x-axis.
The c value is in this case is an approximation of
the root of the function f(x). How close the value of
c gets to the real root depends on the value of the
tolerance we set for the algorithm.
Limitations Bisection method
While Bisection Method is always convergent, there are some drawbacks when this algorithm
is used.

Slow rate of convergence. The convergence of the bisection method is slow as it is simply based
on halving the interval.

Relies on sign changes. If a function f (x) is such that it just touches the x -axis for example
say f(x) = x2 then it will not be able to find lower guess (a) such that f(a)*f(b) < 0

Cannot detect Multiple Roots. The Bisection method fails to identify multiple different roots,
which makes it less desirable to use compared to other methods that can identify multiple roots.
When an equation has multiple roots, it is the choice of the initial interval provided by the user
which determines which root is located.
3. Metodo de regla falsa - Regula Falsi
- Resolver ecuaciones de una variable, similar al metodo de biseccion
- desarrollado para mejorar la velocidad de convergencia
- tecnica de ensayo y error de usar valores (falsos) de prueba para la variable y
luego ajustar el valor de prueba de acuerdo a la respuesta
- Similar al metodo de biseccion, para una funcion continua f(x) se asume que f(a)
y f(b) tienen signos opuestos ( a = lower guess, b = upper guess). Condicion
que satisface el Teorema de Bolzano para funciones continuas.
- Una mejor aproximacion se obtiene si encontramos el punto (c,0) donde la linea
secante L que junta los puntos (a, f(a)) y (b, f(b)) cruza el eje x.
- Para encontrar el valor de c, se define 02 versiones de la pendiente m y linea L
We first use points (a, f (a)) and (b, f (b)) to get equation 1 (below), and then use the points
(c, 0) and (b, f (b)) to get equation 2 (below). Equating these two equation we get equation
3 (below) which is easily solved for c to get equation 4 (below):
The three possibilities are the same
as before in the bisection method:

If f (a) and f (c) have opposite


signs, a zero lies in [a, c].
If f (c) and f (b) have opposite
signs, a zero lies in [c, b].
If f (c) = 0, then the zero is c.
Limitations, Regula Falsi
While Regula Falsi Method like Bisection Method is always convergent, meaning that it is always
leading towards a definite limit and relatively simple to understand but there are also some drawbacks
when this algorithm is used. As both regula falsi and bisection method are similar there are some
common limitations both the algorithms have.
Rate of convergence
The convergence of the regula falsi method can be very slow in some cases(May converge slowly for
functions with big curvatures) as explained above.
Relies on sign changes
If a function f (x) is such that it just touches the x -axis for example say f(x) = x2 then it will not be
able to find lower guess (a) such that f(a)*f(b) < 0
Cannot detect Multiple Roots
Like Bisection method, Regula Falsi Method fails to identify multiple different roots, which makes it
less desirable to use compared to other methods that can identify multiple roots.
4. Metodo de la secante - Secant Method

Secant Method is a numerical method for solving an equation in one unknown. It is


quite similar to Regula falsi method algorithm. One drawback of Newton’s method is
that it is necessary to evaluate f´(x) at various points, which may not be practical for
some choices of f(x). The secant method avoids this issue by using a finite difference
to approximate the derivative. As a result, root of f(x) is approximated by a secant
line through two points on the graph of f(x), rather than a tangent line through one
point on the graph.

As stated above, in Secant method root of f(x) is approximated by a secant line


through two points on the graph of f(x), rather than a tangent line through one point
on the graph.
Since a secant line is defined using two points on the graph of f(x), as opposed to a
tangent line that requires information at only one point on the graph, it is necessary
to choose two initial iterates x0 and x1. Then, as in Newton’s method, the next
iterate x2 is then obtained by computing the x-value at which the secant line passing
through the points (x0, f(x0)) and (x1, f(x1)) has a y-coordinate of zero. This yields
the equation

As you can see above that the equation for new estimate is same as in Regula falsi
Mehtod but unlike in regula falsi method we don't check if the inital two estimates
statisfy the condition that function sign at both points should be opposite.
Limitations, Metodo Secante
Secant Method is faster when compared to Bisection and Regula Falsi methods as
the order of convergence is higher in Secant Method. But there are some drawbacks
too as follow:

It may not converge.

It is likely to have difficulty if f´(a) = 0. This means the x-axis is tangent to the
graph of y = f(x) at x = a.

Newton’s method generalizes more easily to new methods for solving simultaneous
systems of nonlinear equations.
5. Algoritmos para implementacion en computador

- Permiten establecer criterios para la programacion computacional


- Definir parametros y variables pertinentes segun requerimientos
- Se busca calidad, orden y estetica de los codigos a escribir
- Establecer estrategias para transferir el algoritmo matematico hacia los
lenguajes de programacion
- La simplicidad se orienta a la ejecucion eficiente de los codigos
- Los criterios son generales, y aplicables tanto a lenguajes basicos asi como
lenguajes avanzados
- Criterios de convergencia
- “Everything should be made as simple as possible, but no simpler.”
Algoritmo metodo biseccion.
1. Start
2. Define function f(x)
3. Input
a. Lower and Upper guesses a and b
b. tolerable error e
4. If f(a)*f(b) > 0
print "Incorrect initial guesses"
goto 3
End If
5. Do
c = (a+b)/2
If f(a)*f(c) < 0
b=c
Else
a=c
End If

while (fabs(f(c)) > e) // fabs -> returns absolute value

6. Print root as c
7. Stop
Regula Falsi Method algorithm
1. Start
2. Define function f(x)
3. Input
a. Lower and Upper guesses a and b
b. tolerable error e

4. If f(a)*f(b) > 0
print "Incorrect initial guesses"
goto 3
End If
5. Do
c = b -(f(b)*(b-a))/(f(b)-f(a))

If f(a)*f(c) < 0
b=c
Else
a=c
End If

while (fabs(f(c)) > e) // fabs -> returns


absolute value
6. Print root as c
7. Stop
Secant Method algorithm
1. Start
2. Define function f(x)
3. Input
a. initial guesses x0 and x1
b. tolerable error e

5. Do

x_new = x1 -(f(x1)*(x1-x0))/(f(x1)-f(x0))
x0 = x1
x1 = x_new

while (fabs(f(x_new)) > e) // fabs ->


returns absolute value

6. Print root as x_new

7. Stop
Programacion, uso de for y while
- Bucle while para repetir cuando la condición es verdadera

while expression

statements

end

- for loop para repetir el número especificado de veces

for index = values

statements

end
Function_handles - Anonymous Functions
- Function handles @function-name
- Ejemplo f = @sin;
- feval (f, pi/4) ⇒ 0.70711
- f (pi/4) ⇒ 0.70711
- Anonymous Functions @(argument-list) expression
- Ejemplo f = @(x) x.^2;
- f = @(x) x.^3 + 4*x.^2 - 10
- f = @(x,y) (x^2 + y^2 + x*y);
- f = @(x) sin(x.^2) + 3*x - 2
- f = @(x, y) x + y; f = @plus; definicion general de suma
- g = @(c) (integral(@(x) (x.^2 + c*x + 1),0,1));
6. Convergencia de algoritmos numericos

What does it mean for an algorithm to converge?

- An iterative algorithm is said to converge when, as the iterations proceed, the


output gets closer and closer to some specific value. More precisely, no matter
how small an error range you choose, if you continue long enough the function
will eventually stay within that error range around the final value.
- In some circumstances, an algorithm will not converge, having an output that
always varies by some amount. It could even diverge, where its output will
undergo larger and larger value swings, never approaching a useful result. More
precisely, no matter how long you continue, the function value will never settle
down within a range of any "final" value.
Convergencia: What is convergence, in general

- The "converge to a global optimum" phrase in your first sentence is a reference to


algorithms which may converge, but not to the "optimal" value (e.g. a hill-climbing
algorithm which, depending on the function and initial conditions, may converge to a
local maximum, never reaching the global maximum).
- The concept of convergence is a well defined mathematical term. It essentially means
that "eventually" a sequence of elements get closer and closer to a single value. We
call this single value the "limit".
- The formal definition goes something like this:
- Given (infinite) sequence of real numbers X0, X1, X2, ... Xn ... we say Xn converges
to a given number L if for every positive error that you think, there is a Xm such
that every element Xn that comes after Xm differs from L by less than that error.
Convergencia: What is convergence, in general

Example: Imagine a sequence as such:

X0 = 1; X1 = 0.1; X2 = 0.01; X3 = 0.001; X4 =0.0001...Xn = 1/(10^n)

Does Xn converge to zero? Yes! Why?


Think of an error E (for example, E = 0.0025). Is there a element in the sequence that after
that every element is below 0.025? Yes! That element is X3 = 0.001. After X2, every XN is
below 0.0025. Can this be done to every E > 0? Yes. For every positive error that we choose,
we can see how many zeroes it has before its first decimal point and the sequence will be lower
that it starting from the element that has the same number of zeroes.
This means that Xn = 1/(10^5) converges to 0. As in "it can get closer and closer to zero" as
much as we want.
What does it mean for an algorithm to converge?
"Technically" what converges is not the algorithm, but a value the algorithm is
manipulating or iterating. For example, lets say we are writing an algorithm that
prints all the digits of PI. The algorithm starts printing numbers like:

X0 = 3.14; X1 = 3.141; X2 = 3.1415; X3 = 3.14159; ...

We could ask ourselves: does the algorithm print numbers every increasingly close to
PI? In other words, does the sequence X0, X1, ... XN ... that our algorithm prints
converges to PI?

If so, we say our algorithm converges to PI.


7. Scripting and Coding Is There a Difference between
Scripting and Coding?

The main difference that you have


to know is that a code can be
executed alone to give you a
logical outcome.

Coding is an umbrella term like


digital marketing. ...

On the other hand, a script lets


you control the program that you
created with coding.

Thousands of lines of code are


compiled to run a program.
Preguntas
Questions
- After one iteration of the Bisection Method, by how much did our interval that might
contain a zero of the function decrease?

Less than 50% - More than 50% - 50%

- If you look at the equation for new estimate in Regula Falsi Method and Secant
method. We see that both of them are same. What is the major difference between
the two methods?

Regula falsi checks if Intermediate Value Theorem is satisfied


Secant method requires different inputs
Regula falsi is not guaranteed to converge

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy