I'm working on a function that performs some numerical methods - let's say for now, I want to write a function that performs Newton's Method and it takes three parameters:
1. double f(x) - some function
2. double df(x) - the derivative of that function
3. int initial_guess
f(x) and df(x) should be written/defined by the user
Newton's method takes these parameters and iteratively finds a root for f(x) closest to the initial guess.
Is it possible for me to define such a function Newton()? If so, how do I go about doing it? And what if I want parameter 1 to be f(x,y,z) instead of f(x) - in the case I want to perform something other than Newton's Method?
Currently, I have to write a new program each time I want to perform such a numerical method - I'm trying to find a way to generalize it.