
(FPCore (x y z) :precision binary64 :pre TRUE (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * y) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (((x * y) + (z * z)) + (z * z)) + (z * z) END code
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * y) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (((x * y) + (z * z)) + (z * z)) + (z * z) END code
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
(FPCore (x y z) :precision binary64 :pre TRUE (fma x y (* 3.0 (* z z))))
double code(double x, double y, double z) {
return fma(x, y, (3.0 * (z * z)));
}
function code(x, y, z) return fma(x, y, Float64(3.0 * Float64(z * z))) end
code[x_, y_, z_] := N[(x * y + N[(3.0 * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * y) + ((3) * (z * z)) END code
\mathsf{fma}\left(x, y, 3 \cdot \left(z \cdot z\right)\right)
Initial program 98.1%
Applied rewrites99.3%
Applied rewrites99.3%
(FPCore (x y z) :precision binary64 :pre TRUE (fma 3.0 (* z z) (* y x)))
double code(double x, double y, double z) {
return fma(3.0, (z * z), (y * x));
}
function code(x, y, z) return fma(3.0, Float64(z * z), Float64(y * x)) end
code[x_, y_, z_] := N[(3.0 * N[(z * z), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = ((3) * (z * z)) + (y * x) END code
\mathsf{fma}\left(3, z \cdot z, y \cdot x\right)
Initial program 98.1%
Applied rewrites98.2%
(FPCore (x y z) :precision binary64 :pre TRUE (if (<= (* z z) 5e+109) (* x y) (* (* z z) 3.0)))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+109) {
tmp = x * y;
} else {
tmp = (z * z) * 3.0;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d+109) then
tmp = x * y
else
tmp = (z * z) * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+109) {
tmp = x * y;
} else {
tmp = (z * z) * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 5e+109: tmp = x * y else: tmp = (z * z) * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+109) tmp = Float64(x * y); else tmp = Float64(Float64(z * z) * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e+109) tmp = x * y; else tmp = (z * z) * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+109], N[(x * y), $MachinePrecision], N[(N[(z * z), $MachinePrecision] * 3.0), $MachinePrecision]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET tmp = IF ((z * z) <= (50000000000000001178468375708512791662476639752844093156495626963414083423308086629915468079622475513115705344)) THEN (x * y) ELSE ((z * z) * (3)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+109}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot z\right) \cdot 3\\
\end{array}
if (*.f64 z z) < 5.0000000000000001e109Initial program 98.1%
Applied rewrites98.2%
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites53.7%
Taylor expanded in x around inf
Applied rewrites52.5%
if 5.0000000000000001e109 < (*.f64 z z) Initial program 98.1%
Applied rewrites98.2%
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites53.7%
Applied rewrites54.0%
(FPCore (x y z) :precision binary64 :pre TRUE (if (<= (* z z) 5e+109) (* x y) (* z (* 3.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+109) {
tmp = x * y;
} else {
tmp = z * (3.0 * z);
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d+109) then
tmp = x * y
else
tmp = z * (3.0d0 * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+109) {
tmp = x * y;
} else {
tmp = z * (3.0 * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 5e+109: tmp = x * y else: tmp = z * (3.0 * z) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+109) tmp = Float64(x * y); else tmp = Float64(z * Float64(3.0 * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e+109) tmp = x * y; else tmp = z * (3.0 * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+109], N[(x * y), $MachinePrecision], N[(z * N[(3.0 * z), $MachinePrecision]), $MachinePrecision]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET tmp = IF ((z * z) <= (50000000000000001178468375708512791662476639752844093156495626963414083423308086629915468079622475513115705344)) THEN (x * y) ELSE (z * ((3) * z)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+109}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(3 \cdot z\right)\\
\end{array}
if (*.f64 z z) < 5.0000000000000001e109Initial program 98.1%
Applied rewrites98.2%
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites53.7%
Taylor expanded in x around inf
Applied rewrites52.5%
if 5.0000000000000001e109 < (*.f64 z z) Initial program 98.1%
Applied rewrites98.2%
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites53.7%
Applied rewrites54.0%
(FPCore (x y z) :precision binary64 :pre TRUE (* x y))
double code(double x, double y, double z) {
return x * y;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * y
end function
public static double code(double x, double y, double z) {
return x * y;
}
def code(x, y, z): return x * y
function code(x, y, z) return Float64(x * y) end
function tmp = code(x, y, z) tmp = x * y; end
code[x_, y_, z_] := N[(x * y), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = x * y END code
x \cdot y
Initial program 98.1%
Applied rewrites98.2%
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites53.7%
Taylor expanded in x around inf
Applied rewrites52.5%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
:precision binary64
(+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))