/** * Create a lambda-style function representing the secant line through two points * * @see create_function(), Math_PolynomialOp::createFunction() * * @access public * * @param object $p * @param float $x1 * @param float $x2 * @return string */ function createSecantFunction($p, $x1, $x2) { $m = Math_PolynomialOp::getSecantSlopeAt($p, $x1, $x2); $y1 = Math_PolynomialOp::evaluate($p, $x1); $b = -1 * $m * $x1 + $y1; return create_function('$x', 'return (' . $m . ' * $x) + ' . $b . ';'); }