NeoDevin said:
You should be able to write a while loop that runs until you reach your target accuracy/bracket size, using if statements to check your conditions.
Write some code, test it on some function, and if it doesn't work, post it here. I, or someone else here, will look it over and offer suggestions.
this is my source code
# Include <stdio.h>
# Include <math.h>
float f (float x)
(
return x + cos (x);
)
main ()
(
float a, b, c, T, error, e, iteration, the root;
int i;
char answer;
do
(
answer = 'y';
i = 1;
printf ("======================================== \ n");
printf ("Program Not Linear Equations Bisection \ n");
printf ("Version 1.0 =- -= \ n");
printf ("======================================== \ n");
printf ("Equation Function F (x) = x + cos (x) \ n");
printf ("Enter the initial guess of a ="); scanf ("% f", & a);
printf ("Input initial guesses b ="); scanf ("% f", & b);
printf ("f (a) =% f \ n", f (a));
printf ("f (b) =% f \ n", f (b));
if (f (a) * f (b) <0)
(
printf ("Enter the value of epsilon ="); scanf ("% f", & error);
printf ("iteration count -"); scanf ("% f", & iterations);
for (i = 1; i <= iterations; i + +)
(
e = abs, (b-a);
c = (a + b) / 2;
T = c + cos (c);
if (f (a) * T <0)
(
b = c;
)
else
(
a = c;
)
if (e <= error)
(
root = c;
)
)
printf ("The root of the equation x =% f \ n", c);
)
else
(
printf ("sorry calculation process is not subject to the terms \ n");
)
printf ("Do you want to repeat the y / t ="); scanf ("% s", & answer);
) While (answer == "y");
return 0;
)
I feel this is a very simple program, and all I want is a more complex program, like I could enter the function manually. My example program using the functions return x + cos (x);
My question how can I be able to enter the function as input.
It used to be, there are still many who need me ask again later.
thanks before