
(FPCore (x y) :precision binary64 :pre TRUE (* x (+ 1.0 (* y y))))
double code(double x, double y) {
return x * (1.0 + (y * y));
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (y * y))
end function
public static double code(double x, double y) {
return x * (1.0 + (y * y));
}
def code(x, y): return x * (1.0 + (y * y))
function code(x, y) return Float64(x * Float64(1.0 + Float64(y * y))) end
function tmp = code(x, y) tmp = x * (1.0 + (y * y)); end
code[x_, y_] := N[(x * N[(1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x * ((1) + (y * y)) END code
x \cdot \left(1 + y \cdot y\right)
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* x (+ 1.0 (* y y))))
double code(double x, double y) {
return x * (1.0 + (y * y));
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (y * y))
end function
public static double code(double x, double y) {
return x * (1.0 + (y * y));
}
def code(x, y): return x * (1.0 + (y * y))
function code(x, y) return Float64(x * Float64(1.0 + Float64(y * y))) end
function tmp = code(x, y) tmp = x * (1.0 + (y * y)); end
code[x_, y_] := N[(x * N[(1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x * ((1) + (y * y)) END code
x \cdot \left(1 + y \cdot y\right)
(FPCore (x y) :precision binary64 :pre TRUE (fma y (* y x) x))
double code(double x, double y) {
return fma(y, (y * x), x);
}
function code(x, y) return fma(y, Float64(y * x), x) end
code[x_, y_] := N[(y * N[(y * x), $MachinePrecision] + x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (y * (y * x)) + x END code
\mathsf{fma}\left(y, y \cdot x, x\right)
Initial program 94.5%
Applied rewrites99.9%
(FPCore (x y) :precision binary64 :pre TRUE (fma x (* y y) x))
double code(double x, double y) {
return fma(x, (y * y), x);
}
function code(x, y) return fma(x, Float64(y * y), x) end
code[x_, y_] := N[(x * N[(y * y), $MachinePrecision] + x), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (x * (y * y)) + x END code
\mathsf{fma}\left(x, y \cdot y, x\right)
Initial program 94.5%
Applied rewrites94.5%
(FPCore (x y) :precision binary64 :pre TRUE (* x 1.0))
double code(double x, double y) {
return x * 1.0;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * 1.0d0
end function
public static double code(double x, double y) {
return x * 1.0;
}
def code(x, y): return x * 1.0
function code(x, y) return Float64(x * 1.0) end
function tmp = code(x, y) tmp = x * 1.0; end
code[x_, y_] := N[(x * 1.0), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x * (1) END code
x \cdot 1
Initial program 94.5%
Taylor expanded in y around 0
Applied rewrites51.9%
herbie shell --seed 2026092
(FPCore (x y)
:name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"
:precision binary64
(* x (+ 1.0 (* y y))))