This is code that finds the root of any function that returns a double. I can't find the error, it keeps saying it expects "primary expression before double' the double being the double in front of the function I pass into the function. This is my first time trying to pass a function into a function, so I'm sure that's why I'm getting the error
#include <cmath>
#include <iostream>
double bisection(double start, double end, double tol, double &(f)(double x) ){
double x = end - start;
double num = f(x);
if( num < tol){
return x;
}
if( num == 0){
return x;
}
if( num < 0){
start = num;
bisection(start,end,tol, double &(f)(double x) );
}
else if(num > 0){
end = num;
bisection(start,end,tol, double &(f)(double x) );
}
}
double fn(double x){
return ( (1/sqrt(400 - x*x)) + (1/sqrt(900 - x*x)) - 0.1 ) ;
}