Lecture 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Solution of algebraic and transcendental equations

Errors and their computations:

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

Solutions of equations in one variable:

The bisection method:

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:

INPUT: endpoints tolerance maximum number of iterations

OUTPUT: approximate solution or message of failure

Step 1:
Solution of algebraic and transcendental equations

Step 2:

Step 3:

Step 4:

Step 5:

Step 6:

Step 7: OUTPUT (method failed after iterations)

C coding:
#include<stdio.h>

#include<math.h>

double bisec(double);

void main()

double a,b,tol,p,fp,fa;

int i,n;

printf("enter value of a and b\n");

scanf("%lf %lf", &a,&b);

printf("enter tol and number of iteration\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)

printf("the root is =%f",p);

break;

else

i=i+1;

if (fa*fp>0)

a=p;

fa=fp;

else

b=p;

printf("%d %lf %lf %lf %lf\n",i,a,b,p,fp);

} while (i<=n);

double bisec (double x)

double fx;
Solution of algebraic and transcendental equations

fx=x*x*x-x-1;

return (fx);

Exercises:

1. Use the Bisection method to find the solution of correct up to 4


significant figures.

You might also like