P
pauldepstein
Let double NR( double x, double(*)(const double&) f ) be the
signature of a Newton-Raphson function NR.
Here, f is a function which returns a double and accepts a const
double&. The aim of the game is to find a zero of this function f
(the point at which f crosses the x-axis). This zero-of-f which
solves our problem is the double which NR returns. It remains to
explain what the "double x" represents. This is the starting-guess
that is required in Newton-Raphson implementations.
In my case, I have the following amended Newton-Raphson situation. I
have a function of the form
double MyFunc(double x1, double x2, double x3, double x4, double x5)
I want to solve the following problem: Fix x1, x2, x3, and x4. Then
use Newton Raphson to return the double y such that MyFunc(x1, x2, x3,
x4, y) = 0.
I was unable to find a way of using the ready-made function NR because
it assumes f accepts 1 double and returns 1 double, whereas My Func
accepts 5 doubles and returns 1 double.
My very-inelegant solution was to copy-paste the NR code and adapt it
so that the pointer-to-function parameter was of the type I needed.
Is there a more elegant approach that calls on the NR function already
present?
Thank for your help.
Paul Epstein
signature of a Newton-Raphson function NR.
Here, f is a function which returns a double and accepts a const
double&. The aim of the game is to find a zero of this function f
(the point at which f crosses the x-axis). This zero-of-f which
solves our problem is the double which NR returns. It remains to
explain what the "double x" represents. This is the starting-guess
that is required in Newton-Raphson implementations.
In my case, I have the following amended Newton-Raphson situation. I
have a function of the form
double MyFunc(double x1, double x2, double x3, double x4, double x5)
I want to solve the following problem: Fix x1, x2, x3, and x4. Then
use Newton Raphson to return the double y such that MyFunc(x1, x2, x3,
x4, y) = 0.
I was unable to find a way of using the ready-made function NR because
it assumes f accepts 1 double and returns 1 double, whereas My Func
accepts 5 doubles and returns 1 double.
My very-inelegant solution was to copy-paste the NR code and adapt it
so that the pointer-to-function parameter was of the type I needed.
Is there a more elegant approach that calls on the NR function already
present?
Thank for your help.
Paul Epstein