
(FPCore (x y) :precision binary64 :pre TRUE (* (* (* x 3.0) y) y))
double code(double x, double y) {
return ((x * 3.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 * 3.0d0) * y) * y
end function
public static double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
def code(x, y): return ((x * 3.0) * y) * y
function code(x, y) return Float64(Float64(Float64(x * 3.0) * y) * y) end
function tmp = code(x, y) tmp = ((x * 3.0) * y) * y; end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x * (3)) * y) * y END code
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (* (* (* x 3.0) y) y))
double code(double x, double y) {
return ((x * 3.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 * 3.0d0) * y) * y
end function
public static double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
def code(x, y): return ((x * 3.0) * y) * y
function code(x, y) return Float64(Float64(Float64(x * 3.0) * y) * y) end
function tmp = code(x, y) tmp = ((x * 3.0) * y) * y; end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x * (3)) * y) * y END code
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
(FPCore (x y) :precision binary64 :pre TRUE (fma y (* y x) (* (* (+ y y) x) y)))
double code(double x, double y) {
return fma(y, (y * x), (((y + y) * x) * y));
}
function code(x, y) return fma(y, Float64(y * x), Float64(Float64(Float64(y + y) * x) * y)) end
code[x_, y_] := N[(y * N[(y * x), $MachinePrecision] + N[(N[(N[(y + y), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (y * (y * x)) + (((y + y) * x) * y) END code
\mathsf{fma}\left(y, y \cdot x, \left(\left(y + y\right) \cdot x\right) \cdot y\right)
Initial program 99.7%
Applied rewrites88.4%
Applied rewrites99.8%
(FPCore (x y) :precision binary64 :pre TRUE (* 3.0 (* y (* y x))))
double code(double x, double y) {
return 3.0 * (y * (y * x));
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * (y * (y * x))
end function
public static double code(double x, double y) {
return 3.0 * (y * (y * x));
}
def code(x, y): return 3.0 * (y * (y * x))
function code(x, y) return Float64(3.0 * Float64(y * Float64(y * x))) end
function tmp = code(x, y) tmp = 3.0 * (y * (y * x)); end
code[x_, y_] := N[(3.0 * N[(y * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (3) * (y * (y * x)) END code
3 \cdot \left(y \cdot \left(y \cdot x\right)\right)
Initial program 99.7%
Applied rewrites88.4%
Applied rewrites99.7%
herbie shell --seed 2026092
(FPCore (x y)
:name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, B"
:precision binary64
(* (* (* x 3.0) y) y))