thanks... i'll look into the code u gave me...
oh yeah... i better explain how the values in the example i gave came about so that u guys cud understand wat i want to do more...
1) the polynomial equation that the user will enter will be the f(x) which is always equal to 0 (hence the example equation i used before was equal to 0)
2) the interval that the user will enter is the 1st x and 2nd x (respectively) which the program will evaluate giving a new value that will be shown under the column of f(x sub n)
[in the example, the interval was [-0.25 , 0] and these were substituted to the polynomial equation thus giving the values of 3.876953 (for x=-0.25) and 4 (for x=0)]
3) the new x that will be used for evaluation is obtained through the secant formula which is:
http://i33.tinypic.com/1zfsbhc.jpg
[in the example, the 3rd x in the column under x sub n is obtained through the secant formula:
http://i35.tinypic.com/o7j6s7.jpg
this new x will be evaluated (substituting it to the polynomial equation and getting a value of 2325.374361]
4) the 3rd step is repeated until the number of iterations is satisfied (in the example, the intervals, which are -0.25 and 0 are iteration 0 and iteration 1 respectively)
is what i want possible?..
by the way, i was able to make a program that does wat i want with the exception of entering the polynomial equation... this program solves the equation x - 2 + ln x = 0... however i dont know how to construct the part wherein the program could do the number of iterations that the user wants... i hope this gives you an idea...
Code:
#include <stdio.h>
#include <math.h>
double f(double);
int main()
{
double k, x1, x2;
int n;
double y;
printf("Enter the interval [x1,x2]: ");
scanf("%lf, %lf", &x2, &x1);
printf("Checking the boundaries:\n");
printf("Xn\t\tf(Xn)\n");
printf("%.6lf\t%.6lf\n", x1, f(x1));
printf("%.6lf\t%.6lf\n", x2, f(x2));
for (n = 1; n<=4; n++)
{
y = (x1 - x2) / (f(x1) - f(x2)) * f(x1);
x2 = x1;
x1 = x1 - y;
printf("%.6lf\t%.6lf\n", x1, f(x1));
}
scanf("%lf", &k);
return 0;
}
double f(double x)
{
return((x-2)+log(x));
}
please if u cud, help me... i wud really really appreciate it...