Professional Documents
Culture Documents
Lecture 1
Lecture 1
Lecture 1
There are two kinds of numbers, exact and approximate numbers. Examples of exact numbers are 1,
2,3 ,…….1/2, . Approximate numbers are those that represent the numbers to a certain
degree of accuracy. Thus, an approximate value of is 3.1416, or if we desire a better approximation, it
is 3.14159265. But we cannot write the exact value of
Significant digits: the digits that are used to express a number are called significant digits or significant
figures. Thus, t he numbers 3.1416, 0.66667, and 4.0687 contain five significant digits each.
Rounding off: In numerical computations, we come across numbers which have large number of digits
and it will be necessary to cut them to a usable number of figures. This process is called rounding off.
Absolute and relative error: if is an approximation to then the absolute error is and the
relative error is
If a function is continuous between and , and and are of opposite signs, then there
exists at least one root between and . For definiteness, let and . Then the root
lies between and and let its approximate root be given by if we
conclude that is the root of the equation . Otherwise the root lies either between and
or between and depending on whether is negative or positive. We designate this new
interval as . We repeat this process until the latest interval (which contains the root) is as small
as desired.
Example: find a real root of the equation lying between and correct to three places
of decimal by using bisection method.
Algorithm:
To find a solution to given the continuous function on the interval where and
have opposite signs:
Step 1:
Solution of algebraic and transcendental equations
Step 2:
Step 3:
Step 4:
Step 5:
Step 6:
C coding:
#include<stdio.h>
#include<math.h>
double bisec(double);
void main()
double a,b,tol,p,fp,fa;
int i,n;
scanf("%lf %d",&tol,&n);
printf("n a b p fp\n");
i=1;
Solution of algebraic and transcendental equations
fa=bisec(a);
do
p=a+(b-a)/2;
fp=bisec(p);
if (fp==0 ||(b-a)/2<tol)
break;
else
i=i+1;
if (fa*fp>0)
a=p;
fa=fp;
else
b=p;
} while (i<=n);
double fx;
Solution of algebraic and transcendental equations
fx=x*x*x-x-1;
return (fx);
Exercises: