
(FPCore (x y z) :precision binary64 :pre TRUE (/ (* x y) z))
double code(double x, double y, double z) {
return (x * y) / 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
end function
public static double code(double x, double y, double z) {
return (x * y) / z;
}
def code(x, y, z): return (x * y) / z
function code(x, y, z) return Float64(Float64(x * y) / z) end
function tmp = code(x, y, z) tmp = (x * y) / z; end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / z), $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 END code
\frac{x \cdot y}{z}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (/ (* x y) z))
double code(double x, double y, double z) {
return (x * y) / 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
end function
public static double code(double x, double y, double z) {
return (x * y) / z;
}
def code(x, y, z): return (x * y) / z
function code(x, y, z) return Float64(Float64(x * y) / z) end
function tmp = code(x, y, z) tmp = (x * y) / z; end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / z), $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 END code
\frac{x \cdot y}{z}
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (fmax (fabs x) (fabs y))) (t_1 (fmin (fabs x) (fabs y))))
(*
(copysign 1.0 x)
(*
(copysign 1.0 y)
(*
(copysign 1.0 z)
(if (<= (fabs z) 5.993716184525197e-31)
(* t_0 (/ t_1 (fabs z)))
(/ t_1 (/ (fabs z) t_0))))))))double code(double x, double y, double z) {
double t_0 = fmax(fabs(x), fabs(y));
double t_1 = fmin(fabs(x), fabs(y));
double tmp;
if (fabs(z) <= 5.993716184525197e-31) {
tmp = t_0 * (t_1 / fabs(z));
} else {
tmp = t_1 / (fabs(z) / t_0);
}
return copysign(1.0, x) * (copysign(1.0, y) * (copysign(1.0, z) * tmp));
}
public static double code(double x, double y, double z) {
double t_0 = fmax(Math.abs(x), Math.abs(y));
double t_1 = fmin(Math.abs(x), Math.abs(y));
double tmp;
if (Math.abs(z) <= 5.993716184525197e-31) {
tmp = t_0 * (t_1 / Math.abs(z));
} else {
tmp = t_1 / (Math.abs(z) / t_0);
}
return Math.copySign(1.0, x) * (Math.copySign(1.0, y) * (Math.copySign(1.0, z) * tmp));
}
def code(x, y, z): t_0 = fmax(math.fabs(x), math.fabs(y)) t_1 = fmin(math.fabs(x), math.fabs(y)) tmp = 0 if math.fabs(z) <= 5.993716184525197e-31: tmp = t_0 * (t_1 / math.fabs(z)) else: tmp = t_1 / (math.fabs(z) / t_0) return math.copysign(1.0, x) * (math.copysign(1.0, y) * (math.copysign(1.0, z) * tmp))
function code(x, y, z) t_0 = fmax(abs(x), abs(y)) t_1 = fmin(abs(x), abs(y)) tmp = 0.0 if (abs(z) <= 5.993716184525197e-31) tmp = Float64(t_0 * Float64(t_1 / abs(z))); else tmp = Float64(t_1 / Float64(abs(z) / t_0)); end return Float64(copysign(1.0, x) * Float64(copysign(1.0, y) * Float64(copysign(1.0, z) * tmp))) end
function tmp_2 = code(x, y, z) t_0 = max(abs(x), abs(y)); t_1 = min(abs(x), abs(y)); tmp = 0.0; if (abs(z) <= 5.993716184525197e-31) tmp = t_0 * (t_1 / abs(z)); else tmp = t_1 / (abs(z) / t_0); end tmp_2 = (sign(x) * abs(1.0)) * ((sign(y) * abs(1.0)) * ((sign(z) * abs(1.0)) * tmp)); end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z], $MachinePrecision], 5.993716184525197e-31], N[(t$95$0 * N[(t$95$1 / N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(N[Abs[z], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|x\right|, \left|y\right|\right)\\
t_1 := \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\\
\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, z\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 5.993716184525197 \cdot 10^{-31}:\\
\;\;\;\;t\_0 \cdot \frac{t\_1}{\left|z\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\frac{\left|z\right|}{t\_0}}\\
\end{array}\right)\right)
\end{array}
if z < 5.9937161845251967e-31Initial program 92.0%
Applied rewrites92.0%
if 5.9937161845251967e-31 < z Initial program 92.0%
Applied rewrites91.9%
Applied rewrites91.8%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (fmax (fabs x) (fabs y))) (t_1 (fmin (fabs x) (fabs y))))
(*
(copysign 1.0 x)
(*
(copysign 1.0 y)
(*
(copysign 1.0 z)
(if (<= (fabs z) 1.8715037001475357e-84)
(* t_0 (/ t_1 (fabs z)))
(* t_1 (/ t_0 (fabs z)))))))))double code(double x, double y, double z) {
double t_0 = fmax(fabs(x), fabs(y));
double t_1 = fmin(fabs(x), fabs(y));
double tmp;
if (fabs(z) <= 1.8715037001475357e-84) {
tmp = t_0 * (t_1 / fabs(z));
} else {
tmp = t_1 * (t_0 / fabs(z));
}
return copysign(1.0, x) * (copysign(1.0, y) * (copysign(1.0, z) * tmp));
}
public static double code(double x, double y, double z) {
double t_0 = fmax(Math.abs(x), Math.abs(y));
double t_1 = fmin(Math.abs(x), Math.abs(y));
double tmp;
if (Math.abs(z) <= 1.8715037001475357e-84) {
tmp = t_0 * (t_1 / Math.abs(z));
} else {
tmp = t_1 * (t_0 / Math.abs(z));
}
return Math.copySign(1.0, x) * (Math.copySign(1.0, y) * (Math.copySign(1.0, z) * tmp));
}
def code(x, y, z): t_0 = fmax(math.fabs(x), math.fabs(y)) t_1 = fmin(math.fabs(x), math.fabs(y)) tmp = 0 if math.fabs(z) <= 1.8715037001475357e-84: tmp = t_0 * (t_1 / math.fabs(z)) else: tmp = t_1 * (t_0 / math.fabs(z)) return math.copysign(1.0, x) * (math.copysign(1.0, y) * (math.copysign(1.0, z) * tmp))
function code(x, y, z) t_0 = fmax(abs(x), abs(y)) t_1 = fmin(abs(x), abs(y)) tmp = 0.0 if (abs(z) <= 1.8715037001475357e-84) tmp = Float64(t_0 * Float64(t_1 / abs(z))); else tmp = Float64(t_1 * Float64(t_0 / abs(z))); end return Float64(copysign(1.0, x) * Float64(copysign(1.0, y) * Float64(copysign(1.0, z) * tmp))) end
function tmp_2 = code(x, y, z) t_0 = max(abs(x), abs(y)); t_1 = min(abs(x), abs(y)); tmp = 0.0; if (abs(z) <= 1.8715037001475357e-84) tmp = t_0 * (t_1 / abs(z)); else tmp = t_1 * (t_0 / abs(z)); end tmp_2 = (sign(x) * abs(1.0)) * ((sign(y) * abs(1.0)) * ((sign(z) * abs(1.0)) * tmp)); end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z], $MachinePrecision], 1.8715037001475357e-84], N[(t$95$0 * N[(t$95$1 / N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(t$95$0 / N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|x\right|, \left|y\right|\right)\\
t_1 := \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\\
\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, z\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 1.8715037001475357 \cdot 10^{-84}:\\
\;\;\;\;t\_0 \cdot \frac{t\_1}{\left|z\right|}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{t\_0}{\left|z\right|}\\
\end{array}\right)\right)
\end{array}
if z < 1.8715037001475357e-84Initial program 92.0%
Applied rewrites92.0%
if 1.8715037001475357e-84 < z Initial program 92.0%
Applied rewrites91.9%
(FPCore (x y z) :precision binary64 :pre TRUE (* x (/ y z)))
double code(double x, double y, double z) {
return x * (y / 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)
end function
public static double code(double x, double y, double z) {
return x * (y / z);
}
def code(x, y, z): return x * (y / z)
function code(x, y, z) return Float64(x * Float64(y / z)) end
function tmp = code(x, y, z) tmp = x * (y / z); end
code[x_, y_, z_] := N[(x * N[(y / 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) END code
x \cdot \frac{y}{z}
Initial program 92.0%
Applied rewrites91.9%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
(/ (* x y) z))