* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download ASSIGNMENT ON NUMERIC ANALYSIS FOR ENGINEERS
Mathematical optimization wikipedia , lookup
Computational phylogenetics wikipedia , lookup
Corecursion wikipedia , lookup
Genetic algorithm wikipedia , lookup
Perturbation theory wikipedia , lookup
Travelling salesman problem wikipedia , lookup
Least squares wikipedia , lookup
Simulated annealing wikipedia , lookup
Horner's method wikipedia , lookup
Computational chemistry wikipedia , lookup
Strähle construction wikipedia , lookup
Simplex algorithm wikipedia , lookup
Numerical continuation wikipedia , lookup
Multiple-criteria decision analysis wikipedia , lookup
Expectation–maximization algorithm wikipedia , lookup
Computational fluid dynamics wikipedia , lookup
Computational electromagnetics wikipedia , lookup
Newton's method wikipedia , lookup
ASSIGNMENTON NUMERICANALYSIS FORENGINEERS Submitted by: Tarek Salah Uddin Mahmud BSSE0508 Details about the methods of finding roots in a nonlinear equation Methods To Find The Roots Of A Function: The solution or the values of ‘x’ of a given function f(x) are called the roots of the equation f(x)=0. To solve this problem, there are some methods devided into two catagories: 1. Bracating methods 2. Open methods Bracating Methods: These methods require the limits between which the root lies. Example: 1. Bisection Method 2. Method of False Position (Regular Falsi Method) Open Methods: These methods require the initial estimation of the solution. Example: 3. Newton-Raphson Method (Newton’s method) 4. Successive Approximation Method. Let’s discuss the methods in a short brief. BISECTION METHOD: Bisection method After a root of f Bisection method accomplishes this sufficiently small. is also known as the interval halving method. Because (x) = 0 has been bracketed in the interval (a, b). can be used to close in on it. The Bisection method by successfully halving the interval until it becomes Algorithm: First Step: Define the first interval (a, b) such that solution exists between them. Check f (a) * f (b) < 0. Second Step: Compute the first estimate of the numerical solution ‘c’ by c = (a+b)/2 Third Step: Determine whether the true solution is between ‘a’ and ‘c’ or between ‘c’ and ‘b’ If f (a) * f (c) < 0, the true solution is between a and c. If f (a) * f (c) > 0, the true solution is between c and b. If |f(c)| = ∈, then accept c as the root and stop. ∈ is the error tolerance, ∈ > 0. Fourth Step: Choose the subinterval that contains the true solution (a to c or c to b) as the new interval (a, b) and go back to ‘Second Step’. ‘Second Step’ to ‘fourth Step’ are repeated until a specified tolerance or error bound is attained. Program: A program to solve the corresponding problem is given below: #include <stdio.h> #define f(x) ((x)*(x)*(x)-4*(x)-8.95) int main () { double a=2, b=3, eps=1.0e-3,c; if((f(a)*f(b))>=0) return 0; while(1){ c = (a+b)/2.0; if(f(c)>-eps && f(c)<eps){ printf("%lf\n",c); break; } if((f(a))*(f(c))<0) b=c; else a=c; } return 0; } METHOD OF FALSE POSITION: It is very similar to Bisection method. But rather than bisecting the interval (a, b), it locates the root by joining f (a1) and f (b1) with a straight line. The intersection of this line with the x-axis represents an improved estimate of the root. Algorithm: First Step: Define the first interval (a, b) such that solution exists between them. Check f (a) f (b) < 0. Second Step: Compute the first estimate of the numerical solution ‘c’ by c = ((a*f(b))-(b*f(a)))/(f(b)-f(a)) Third Step: Determine whether the true solution is between ‘a’ and ‘c’ or between ‘c’ and ‘b’ If f (a) f (c) < 0, the true solution is between a and c. If f (a) f (c) > 0, the true solution is between c and b. If |f(c)| = ∈, then accept c as the root and stop. ∈ is the error tolerance, ∈ > 0. Fourth Step: Choose the subinterval that contains the true solution (a to c or c to b) as the new interval (a, b) and go back to ‘Second Step’. ‘Second Step’ to ‘fourth Step’ are repeated until a specified tolerance or error bound is attained. Program: A program to solve the corresponding problem is given below: #include <stdio.h> #define f(x) ((x)*(x)*(x)-4*(x)-8.95) int main () { double a=2, b=3, eps=1.0e-3,c; if((f(a)*f(b))>=0) return 0; while(1){ c = ((a*f(b))-(b*f(a)))/(f(b)-f(a)); if(f(c)>-eps && f(c)<eps) { printf("%lf\n",c); break; } if((f(a))*(f(c))<0) b=c; else a=c; } return 0; } NEWTON-RAPHSON METHOD: The Newton-Raphson method is the best-known method of finding roots of a function f (x) as it is simple and fast. This method is used only in problems where f '(x)can be readily computed. The solution process starts by selecting point x1 as the first estimate of the solution. The second estimate x2 is found by drawing the tangent line to f (x) at the point (x1, f (x1)) and determining the intersection point of the tangent line with the x-axis. Thus the process goes on. The slope, f '(x1) = (f(x1)-0)/(x1-x2) Algorithm: First Step: Select a point x1 as an initial guess of the solution. Second Step: For i =1,2,3... Compute Xi+1 by Xi+1 = (Xi - ((f(Xi))/( f ' (Xi)))) This step runs until the error is smaller than a specified value. That means, |( Xi+1 - Xi )/ Xi | <= ∈ Program: A program to solve the corresponding problem is given below: #include <stdio.h> #define f(x) ((x)*(x)*(x)*(x)-11*(x)+8) #define df(x) (4*(x)*(x)*(x)-11) int main () { double eps=1.0e-3, x1=2.0,x2; while(1) { x2 = x1 - (f(x1)/df(x1)) ; if(f(x2)>-eps && f(x2)<eps) { printf("%lf\n",x2); break; } x1 = x2; } return 0; } SUCCESSIVE APPROXIMATION METHOD: If an equation f(x) = 0 is given whose roots are to be determined, it can be written in the form x = f(x) Let x = Xi be an initial approximation to the desired root. Then, the first approximation Xi+1 is given by Xi+1 = g(Xi) This iterative sequence of solution is called Successive Approximation Method. Algorithm: First Step: Select a point x1 as an initial guess of the solution. Second Step: Compute Xi+1 by Xi+1 = g(Xi) This step runs until the error is smaller than a specified value. That means, |( Xi+1 - Xi )/ Xi | <= ∈ Program: A program to solve the corresponding problem is given below: #include <stdio.h> #define f(x) ((x)*(x)*(x)*(x)-11*(x)+8) #define g(x) ((x)*(x)*(x)*(x)+8)/11 int main () { double eps=1.0e-6, x1=2,x2; while(1) { x2 = g(x1); if(f(x2)>-eps && f(x2)<eps){ printf("%lf\n",x2); break; } x1 = x2; } return 0; }