This file contains one solution from
Bisection
Secant
Regular False
Newton
Fixed Point Iteration
Synthetic Division
QD Method
Link for online file: https://docs.google.com/spreadsheet/ccc?key=0Arryl0I1PQbVdEFuM1k0YVBTZF9SS21SUUpvZjc3aXc
This file contains one solution from
Bisection
Secant
Regular False
Newton
Fixed Point Iteration
Synthetic Division
QD Method
Link for online file: https://docs.google.com/spreadsheet/ccc?key=0Arryl0I1PQbVdEFuM1k0YVBTZF9SS21SUUpvZjc3aXc
x0 = 5; x1 = x0; fx0 = (3*x0+sin(x0)-exp(x0)) fx1 = (3+cos(x0)-exp(x0)) if(fx0 ~= 0 && fx1 ~= 0) while(abs(x1 - x0) < 0.0000001 || abs(fx1) < 0.000001) x1 = x0 x0 = x0 - (fx0/fx1) end end
#include<iostream.h> #include<conio.h> #include<math.h> float f (float x) { float fx1; fx1 = pow(x,3) + pow(x,2) - (3*x) - 3; // f(x) = x^3 - x^2 - 3x - 3; return (fx1); } void main() { float x1,x2,x3; int count = 0; int iter; cout <<"Enter x1 = "; cin >> x1; cout <<"Enter x2 = "; cin >> x2; cout <<"Enter number of iterations = "; cin >> iter; // int fx1 = (x1^3) + (x1^2) - (3x1) - 3; // int fx2 = (x2^3) + (x2^2) - (3x2) - 3; do { if(count == iter) { break; } x3 = x1 - (f(x1)*((x1 - x2) / f(x1) - f(x2))); //This is formula of Regular false method cout <<"x1=" << x1 <<" | x2="<< x2 <<" | x3=" << x3 <<" | " << " f(x1)=" << f(x1) << " | f(x2)=" << f(x2) << " | f(x3)=" << f(x3) << endl << endl; //float temp1 = f(x1); //float temp2 = f(x3); if( f(x1) * f(x3) < 0 ) { x2 = x3; } else { x1 = x3; } count++; } while ( abs(x1 - x2) < 0.0000001 || f(x3) == 0 ); }
#include<iostream.h> #include<conio.h> #include<math.h> double f(double x) { return ((3*x)+ sin(x) - exp(x)); // f(x) = x^3 + sin(x) - e^x } void main(void) { double x0 = 1, x1 = 2, x2 = 0; cout<<"x0 = " << x0 << " | x1 = " << x1 << " | x2 = " << x2 << endl; if(abs(f(x0)) < abs(x1)) { x0 = x1; } cout<<"x0 = " << x0 << " | x1 = " << x1 << " | x2 = " << x2 << endl; do { x2 = x0 - f(x0)*(x0 - x1) / f(x0) - f(x1); x0 = x1; x1 = x2; cout<<"x0 = " << x0 << " | x1 = " << x1 << " | x2 = " << x2 << endl; } while(abs(f(x2)) < 0.000000000001); }
x1 = 1 x2 = 2 fx1 = (x1^3) + (x1^2) - (3*x1) - 3; fx2 = (x2^3) + (x2^2) - (3*x2) - 3; while(abs(x1 -x2)> 0.00001) x3 = (x1 +x2)/2; fx3 = (x3^3) + (x3^2) - (3*x3) - 3; if (fx1 * fx3 < 0) x2 = x3; fx2 = fx3; else x1 = x3; fx1 = fx3; end end x3
format long; x = sym('x'); expr = input('Please enter the equation : '); fx = sym(expr); x1 = input('Please enter value of X1 : '); x2 = input('Please enter value of X2 : '); iter = input('Please enter number of Iterations : '); fx1 = subs(fx,x,x1); fx2 = subs(fx,x,x2); x3 = 0; counter = 0; fid=fopen('c:\bisection.csv','w'); fprintf(fid,'%s\n','Iteration,x1,x2,x3,F(x1),F(x2),F(x3),Max Errors'); if fx1*fx2 >= 0 message = 'x1 and x2 values are not valid for desired root'; disp(message) else while ((counter == 0 || abs(x1-x2) > 0.000001 || subs(fx,x,x3) == 0) && counter <= iter) counter = counter + 1; x3 = (x1 + x2) / 2; fprintf(fid,'%d,',counter); fprintf(fid,'%5.8f,',x1); fprintf(fid,'%5.8f,',x2); fprintf(fid,'%5.8f,',x3); fprintf(fid,'%5.8f,',subs(fx,x,x1)); fprintf(fid,'%5.8f,',subs(fx,x,x2)); fprintf(fid,'%5.8f,',subs(fx,x,x3)); fprintf(fid,'%5.8f\n',abs((x2-x1)/(2^counter))); x3 = (x1 + x2) / 2; if subs(fx,x,x3) * subs(fx,x,x1)< 0 x2 = x3; else x1 = x3; end end end sprintf('The root of the equation using Bisection method is :: %d', x3) fclose(fid);
#include<iostream.h> #include<conio.h> #include<math.h> float f (float x) { float fx1; fx1 = pow(x,3) + pow(x,2) - (3*x) - 3; return (fx1); } void main() { float x1,x2,x3; int count = 0; int iter; cout <<"Enter x1 = "; cin >> x1; cout <<"Enter x2 = "; cin >> x2; cout <<"Enter number of iterations = "; cin >> iter; // int fx1 = (x1^3) + (x1^2) - (3x1) - 3; // int fx2 = (x2^3) + (x2^2) - (3x2) - 3; do { if(count == iter) { break; } x3 = (x1 + x2)/2; cout <<"x1=" << x1 <<" | x2="<< x2 <<" | x3=" << x3 <<" | " << " f(x1)=" << f(x1) << " | f(x2)=" << f(x2) << " | f(x3)=" << f(x3) << endl << endl; //float temp1 = f(x1); //float temp2 = f(x3); if( f(x1) * f(x3) < 0 ) { x2 = x3; } else { x1 = x3; } count++; } while ( abs(x1 - x2) < 0.0000001 || f(x3) == 0 ); }
Numerical analysis is the study of algorithms that use numerical approximation (as opposed to general symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics).
The ever-increasing advances in computer technology has enabled many in science and engineering to apply numerical methods to simulate physical phenomena. Numerical methods are often divided into elementary ones such as finding the root of an equation, integrating a function or solving a linear system of equations to intensive ones like the finite element method. Intensive methods are often needed for the solution of practical problems and they often require the systematic application of a range of elementary methods, often thousands or millions of times over.
In the development of numerical methods, simplifications need to be made to progress towards a solution: for example general functions may need to be approximated by polynomials and computers cannot generally represent numbers exactly anyway. As a result, numerical methods do not usually give the exact answer to a given problem, or they can only tend towards a solution getting closer and closer with each iteration. Numerical methods are generally only useful when they are implemented on computer using a computer programming language.
In the study of numerical methods, we can make a general distinction between a set of methods such as solving linear systems of equations , solving matrix eigenvalue problems , interpolation , numerical integration andfinding the roots or zeros of equations , which can be somewhat considered as the building blocks for larger that arise in engineering/applied mathematics/physics. For example the problem of solving ordinary differential equations , optimisation and solving integral equations . But from the point of view of aplied mathematics or engineering, erhaps the most significant problems in numerical methods is the solution of partial differential equations by Finite Difference Methods , Finite Element Methods or Boundary Element Methods .
The study of the behaviour of numerical methods is called numerical analysis. This is a mathematical subject that considers the modelling of the error in the processing of numerical methods and the subsequent re-design of methods.