L03 NMCP Lecture03-1588102457
L03 NMCP Lecture03-1588102457
Programación
Unidad 01 - Sesión 03
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:
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 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
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
5. Do
x_new = x1 -(f(x1)*(x1-x0))/(f(x1)-f(x0))
x0 = x1
x1 = x_new
7. Stop
Programacion, uso de for y while
- Bucle while para repetir cuando la condición es verdadera
while expression
statements
end
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
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 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?