
(FPCore (x y) :precision binary64 :pre TRUE (+ (+ (* x 2.0) (* x x)) (* y y)))
double code(double x, double y) {
return ((x * 2.0) + (x * x)) + (y * y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) + (x * x)) + (y * y)
end function
public static double code(double x, double y) {
return ((x * 2.0) + (x * x)) + (y * y);
}
def code(x, y): return ((x * 2.0) + (x * x)) + (y * y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) + Float64(x * x)) + Float64(y * y)) end
function tmp = code(x, y) tmp = ((x * 2.0) + (x * x)) + (y * y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x * (2)) + (x * x)) + (y * y) END code
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (+ (+ (* x 2.0) (* x x)) (* y y)))
double code(double x, double y) {
return ((x * 2.0) + (x * x)) + (y * y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) + (x * x)) + (y * y)
end function
public static double code(double x, double y) {
return ((x * 2.0) + (x * x)) + (y * y);
}
def code(x, y): return ((x * 2.0) + (x * x)) + (y * y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) + Float64(x * x)) + Float64(y * y)) end
function tmp = code(x, y) tmp = ((x * 2.0) + (x * x)) + (y * y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x * (2)) + (x * x)) + (y * y) END code
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
(FPCore (x y) :precision binary64 :pre TRUE (fma y y (* (- x -2.0) x)))
double code(double x, double y) {
return fma(y, y, ((x - -2.0) * x));
}
function code(x, y) return fma(y, y, Float64(Float64(x - -2.0) * x)) end
code[x_, y_] := N[(y * y + N[(N[(x - -2.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (y * y) + ((x - (-2)) * x) END code
\mathsf{fma}\left(y, y, \left(x - -2\right) \cdot x\right)
Initial program 99.9%
Applied rewrites100.0%
(FPCore (x y) :precision binary64 :pre TRUE (fma y y (* 2.0 x)))
double code(double x, double y) {
return fma(y, y, (2.0 * x));
}
function code(x, y) return fma(y, y, Float64(2.0 * x)) end
code[x_, y_] := N[(y * y + N[(2.0 * x), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (y * y) + ((2) * x) END code
\mathsf{fma}\left(y, y, 2 \cdot x\right)
Initial program 99.9%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites66.8%
herbie shell --seed 2026092
(FPCore (x y)
:name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"
:precision binary64
(+ (+ (* x 2.0) (* x x)) (* y y)))