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