Numerical method for calculations of odd roots or to find zeroes of function



#include <iostream.h>

#include <math.h>

#include <iomanip.h>


double f(double x){

return tan(ALFA)-ALFA-Y;}

// ALFA is an angle that we are calculating and Y is free article seen (calculated) on right side of equation


main(){

double xl, xd, es,xn;

int maxit;

cout << " Podaj levi priblizek : ";

cin >>xl;

cout << " Podaj desni priblizek : ";

cin >>xd;

if(f(xl)*f(xd)>0){

cout <<" Podaj dopustno relativno napako : ";

cin >>es;

cout <<" Podaj maksimalno stevilo iteracij : ";

cin >>maxit;

double ea=1.1*es;

cout <<setw(6)<<"xl"<<setw(14)<<"xn"<<setw(14)<<"f(xn)" <<endl;

cout.flags(cout.left);

double xs=xd;

for( int i=0;i<=maxit;i++){

}

cout <<" koren = " <<xn <<endl;

cout <<" ocena napake= " <<ea <<endl;

cout <<" stevilo iteracij= " <<i <endl;

if(i

cout <<" napacni rezultat ";

return 0;

}

<- BACK (Nazaj)

From: Duplicated lecture notes for a particular course of Numerical methods and programming - Jože Petrišič, Ljubljana 1996

Davorin Pajk, 15.02.2001