View source code
Display the source code in std/numeric.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Template std.numeric.secantMethod
Implements the secant method for finding a
root of the function fun
starting from points [xn_1, x_n]
(ideally close to the root). Num
may be float
, double
,
or real
.
Arguments
template secantMethod(alias fun);
Functions
Function name | Description |
---|---|
secantMethod |
Example
float f(float x) { return cos(x) - x*x*x; } auto x = secantMethod!(f)(0f, 1f); assert(approxEqual(x, 0.865474));
Authors
Andrei Alexandrescu, Don Clugston, Robert Jacques