KEMBAR78
Functional Analysis | PDF
0% found this document useful (0 votes)
6 views3 pages

Functional Analysis

The document provides a C program that implements the Newton Bisection method to find the real root of the function f(x) = x log(x) - 1. The program prompts the user for two initial guesses and a tolerable error, then iteratively narrows down the interval to find the root. It outputs the steps taken and the final root value once the error tolerance is met.

Uploaded by

shad09141
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Functional Analysis

The document provides a C program that implements the Newton Bisection method to find the real root of the function f(x) = x log(x) - 1. The program prompts the user for two initial guesses and a tolerable error, then iteratively narrows down the interval to find the root. It outputs the steps taken and the final root value once the error tolerance is met.

Uploaded by

shad09141
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q4: Using Newton Bisection method, Compute the real root of

f ( x )=xlogx−1. R

In C-language, Where ‘R’ is the last digit of your University Roll


number.

Solution:

Code:

#include<stdio.h>

#include<math.h>

#define f(x) ((x) * log(x) – 1.3)

Int main()

Float x0, x1, x2, f0, f1, f2, e;

Int step = 1;

Printf(“\nEnter two initial guesses:\n”);

Scanf(“%f%f”, &x0, &x1);

Printf(“Enter tolerable error:\n”);

Scanf(“%f”, &e);

F0 = f(x0);

F1 = f(x1);

While (f0 * f1 > 0.0) {

Printf(“Incorrect Initial Guesses. Please enter again:\n”);


Scanf(“%f%f”, &x0, &x1);

F0 = f(x0);

F1 = f(x1);

Printf(“\nStep\t\tx0\t\tx1\t\tx2\t\tf(x2)\n”);

Do

X2 = (x0 + x1) / 2;

F2 = f(x2);

Printf(“%d\t\t%f\t%f\t%f\t%f\n”, step, x0, x1, x2, f2);

If (f0 * f2 < 0) {

X1 = x2;

F1 = f2;

} else {

X0 = x2;

F0 = f2;

Step = step + 1;

} while (fabs(f2) > e);

Printf(“\nRoot is: %f\n”, x2);


Return 0;

OUTPUT:

You might also like