void euler(int *x, int *y, int* y_prima, float h, int n_pasos){ y[0] = 0.0; int i; for(i = 1; i < n_pasos; i ++){ y_prima[i] = f_prima(x[i-1], y[i-1]); x[i] = x[i-1] + h; y[i] = y[i-1] + h*(y_prima[1]); } }
int main(){ double a= 1.2,b=1.4,c; double tolerancia = 0.002; int i=0; double xnuevo, xn=1.2; FILE *fp; //fp = fopen("biseccion.txt", "w"); //fprintf(fp,"i\ta\tb\tc\tabs(a-b)\n\tF(a)\tF(b)\tF(c)\n"); printf("Xnuevo\tXn\n"); do{ xnuevo = xn -(f(xn)/f_prima(xn)); printf("%f\t%f\t%f\n", xnuevo, xn, fabs(xnuevo-xn)); if(fabs(xnuevo-xn)<tolerancia) break; if(i==10)break; xn = xnuevo; i++; }while( f(xnuevo)!=0); //fclose(fp); }