
(FPCore (x y z) :precision binary64 :pre TRUE (- (- (+ (* x y) (* y y)) (* y z)) (* y y)))
double code(double x, double y, double z) {
return (((x * y) + (y * y)) - (y * z)) - (y * 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) + (y * y)) - (y * z)) - (y * y)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (y * y)) - (y * z)) - (y * y);
}
def code(x, y, z): return (((x * y) + (y * y)) - (y * z)) - (y * y)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(y * y)) - Float64(y * z)) - Float64(y * y)) end
function tmp = code(x, y, z) tmp = (((x * y) + (y * y)) - (y * z)) - (y * y); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision] - N[(y * y), $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) + (y * y)) - (y * z)) - (y * y) END code
\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (- (- (+ (* x y) (* y y)) (* y z)) (* y y)))
double code(double x, double y, double z) {
return (((x * y) + (y * y)) - (y * z)) - (y * 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) + (y * y)) - (y * z)) - (y * y)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (y * y)) - (y * z)) - (y * y);
}
def code(x, y, z): return (((x * y) + (y * y)) - (y * z)) - (y * y)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(y * y)) - Float64(y * z)) - Float64(y * y)) end
function tmp = code(x, y, z) tmp = (((x * y) + (y * y)) - (y * z)) - (y * y); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision] - N[(y * y), $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) + (y * y)) - (y * z)) - (y * y) END code
\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y
(FPCore (x y z) :precision binary64 :pre TRUE (* y (- x z)))
double code(double x, double y, double z) {
return y * (x - 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 = y * (x - z)
end function
public static double code(double x, double y, double z) {
return y * (x - z);
}
def code(x, y, z): return y * (x - z)
function code(x, y, z) return Float64(y * Float64(x - z)) end
function tmp = code(x, y, z) tmp = y * (x - z); end
code[x_, y_, z_] := N[(y * N[(x - 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 = y * (x - z) END code
y \cdot \left(x - z\right)
Initial program 63.5%
Applied rewrites100.0%
Applied rewrites100.0%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (- (* z y))))
(if (<= z -1.5998878487717716e-87)
t_0
(if (<= z 1.4132947115915006e-40) (* x y) t_0))))double code(double x, double y, double z) {
double t_0 = -(z * y);
double tmp;
if (z <= -1.5998878487717716e-87) {
tmp = t_0;
} else if (z <= 1.4132947115915006e-40) {
tmp = x * y;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = -(z * y)
if (z <= (-1.5998878487717716d-87)) then
tmp = t_0
else if (z <= 1.4132947115915006d-40) then
tmp = x * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -(z * y);
double tmp;
if (z <= -1.5998878487717716e-87) {
tmp = t_0;
} else if (z <= 1.4132947115915006e-40) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -(z * y) tmp = 0 if z <= -1.5998878487717716e-87: tmp = t_0 elif z <= 1.4132947115915006e-40: tmp = x * y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-Float64(z * y)) tmp = 0.0 if (z <= -1.5998878487717716e-87) tmp = t_0; elseif (z <= 1.4132947115915006e-40) tmp = Float64(x * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(z * y); tmp = 0.0; if (z <= -1.5998878487717716e-87) tmp = t_0; elseif (z <= 1.4132947115915006e-40) tmp = x * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(z * y), $MachinePrecision])}, If[LessEqual[z, -1.5998878487717716e-87], t$95$0, If[LessEqual[z, 1.4132947115915006e-40], N[(x * y), $MachinePrecision], t$95$0]]]
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 t_0 = (- (z * y)) IN LET tmp_1 = IF (z <= (14132947115915006468182910235642061199906833362565967651395812855413318177857125598375794078304482317867511731446228395725484006106853485107421875e-185)) THEN (x * y) ELSE t_0 ENDIF IN LET tmp = IF (z <= (-159988784877177164685523371169830722870522374072384409119026858684832480050318864005140114871679013601761552483193181404403016128515199488354968070059220853336754264519220820635743157089849151568897638446024723319315030689580225953250192105770111083984375e-341)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := -z \cdot y\\
\mathbf{if}\;z \leq -1.5998878487717716 \cdot 10^{-87}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.4132947115915006 \cdot 10^{-40}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -1.5998878487717716e-87 or 1.4132947115915006e-40 < z Initial program 63.5%
Taylor expanded in x around 0
Applied rewrites54.2%
Applied rewrites54.2%
if -1.5998878487717716e-87 < z < 1.4132947115915006e-40Initial program 63.5%
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites53.8%
(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 63.5%
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites53.8%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Linear.Quaternion:$c/ from linear-1.19.1.3, C"
:precision binary64
(- (- (+ (* x y) (* y y)) (* y z)) (* y y)))