
(FPCore (x y z t) :precision binary64 :pre TRUE (* x (/ (* (/ y z) t) t)))
double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * (((y / z) * t) / t)
end function
public static double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
function code(x, y, z, t) return Float64(x * Float64(Float64(Float64(y / z) * t) / t)) end
function tmp = code(x, y, z, t) tmp = x * (((y / z) * t) / t); end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = x * (((y / z) * t) / t) END code
x \cdot \frac{\frac{y}{z} \cdot t}{t}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (* x (/ (* (/ y z) t) t)))
double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * (((y / z) * t) / t)
end function
public static double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
function code(x, y, z, t) return Float64(x * Float64(Float64(Float64(y / z) * t) / t)) end
function tmp = code(x, y, z, t) tmp = x * (((y / z) * t) / t); end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = x * (((y / z) * t) / t) END code
x \cdot \frac{\frac{y}{z} \cdot t}{t}
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (fmax (fabs x) (fabs y)))
(t_2 (/ t_1 (fabs z)))
(t_3 (fmin (fabs x) (fabs y))))
(*
(copysign 1.0 x)
(*
(copysign 1.0 y)
(*
(copysign 1.0 z)
(if (<= t_2 5e+265) (* t_3 t_2) (/ t_1 (/ (fabs z) t_3))))))))double code(double x, double y, double z, double t) {
double t_1 = fmax(fabs(x), fabs(y));
double t_2 = t_1 / fabs(z);
double t_3 = fmin(fabs(x), fabs(y));
double tmp;
if (t_2 <= 5e+265) {
tmp = t_3 * t_2;
} else {
tmp = t_1 / (fabs(z) / t_3);
}
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) {
double t_1 = fmax(Math.abs(x), Math.abs(y));
double t_2 = t_1 / Math.abs(z);
double t_3 = fmin(Math.abs(x), Math.abs(y));
double tmp;
if (t_2 <= 5e+265) {
tmp = t_3 * t_2;
} else {
tmp = t_1 / (Math.abs(z) / t_3);
}
return Math.copySign(1.0, x) * (Math.copySign(1.0, y) * (Math.copySign(1.0, z) * tmp));
}
def code(x, y, z, t): t_1 = fmax(math.fabs(x), math.fabs(y)) t_2 = t_1 / math.fabs(z) t_3 = fmin(math.fabs(x), math.fabs(y)) tmp = 0 if t_2 <= 5e+265: tmp = t_3 * t_2 else: tmp = t_1 / (math.fabs(z) / t_3) return math.copysign(1.0, x) * (math.copysign(1.0, y) * (math.copysign(1.0, z) * tmp))
function code(x, y, z, t) t_1 = fmax(abs(x), abs(y)) t_2 = Float64(t_1 / abs(z)) t_3 = fmin(abs(x), abs(y)) tmp = 0.0 if (t_2 <= 5e+265) tmp = Float64(t_3 * t_2); else tmp = Float64(t_1 / Float64(abs(z) / t_3)); 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) t_1 = max(abs(x), abs(y)); t_2 = t_1 / abs(z); t_3 = min(abs(x), abs(y)); tmp = 0.0; if (t_2 <= 5e+265) tmp = t_3 * t_2; else tmp = t_1 / (abs(z) / t_3); end tmp_2 = (sign(x) * abs(1.0)) * ((sign(y) * abs(1.0)) * ((sign(z) * abs(1.0)) * tmp)); end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Abs[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = 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[t$95$2, 5e+265], N[(t$95$3 * t$95$2), $MachinePrecision], N[(t$95$1 / N[(N[Abs[z], $MachinePrecision] / t$95$3), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\left|x\right|, \left|y\right|\right)\\
t_2 := \frac{t\_1}{\left|z\right|}\\
t_3 := \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}\;t\_2 \leq 5 \cdot 10^{+265}:\\
\;\;\;\;t\_3 \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\frac{\left|z\right|}{t\_3}}\\
\end{array}\right)\right)
\end{array}
if (/.f64 y z) < 5.0000000000000002e265Initial program 81.7%
Applied rewrites92.5%
if 5.0000000000000002e265 < (/.f64 y z) Initial program 81.7%
Applied rewrites91.6%
Applied rewrites91.8%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (fmax (fabs x) (fabs y)))
(t_2 (/ t_1 (fabs z)))
(t_3 (fmin (fabs x) (fabs y))))
(*
(copysign 1.0 x)
(*
(copysign 1.0 y)
(*
(copysign 1.0 z)
(if (<= t_2 5e+265) (* t_3 t_2) (/ (* t_3 t_1) (fabs z))))))))double code(double x, double y, double z, double t) {
double t_1 = fmax(fabs(x), fabs(y));
double t_2 = t_1 / fabs(z);
double t_3 = fmin(fabs(x), fabs(y));
double tmp;
if (t_2 <= 5e+265) {
tmp = t_3 * t_2;
} else {
tmp = (t_3 * t_1) / 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) {
double t_1 = fmax(Math.abs(x), Math.abs(y));
double t_2 = t_1 / Math.abs(z);
double t_3 = fmin(Math.abs(x), Math.abs(y));
double tmp;
if (t_2 <= 5e+265) {
tmp = t_3 * t_2;
} else {
tmp = (t_3 * t_1) / 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): t_1 = fmax(math.fabs(x), math.fabs(y)) t_2 = t_1 / math.fabs(z) t_3 = fmin(math.fabs(x), math.fabs(y)) tmp = 0 if t_2 <= 5e+265: tmp = t_3 * t_2 else: tmp = (t_3 * t_1) / 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) t_1 = fmax(abs(x), abs(y)) t_2 = Float64(t_1 / abs(z)) t_3 = fmin(abs(x), abs(y)) tmp = 0.0 if (t_2 <= 5e+265) tmp = Float64(t_3 * t_2); else tmp = Float64(Float64(t_3 * t_1) / 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) t_1 = max(abs(x), abs(y)); t_2 = t_1 / abs(z); t_3 = min(abs(x), abs(y)); tmp = 0.0; if (t_2 <= 5e+265) tmp = t_3 * t_2; else tmp = (t_3 * t_1) / 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_, t_] := Block[{t$95$1 = N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[Abs[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = 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[t$95$2, 5e+265], N[(t$95$3 * t$95$2), $MachinePrecision], N[(N[(t$95$3 * t$95$1), $MachinePrecision] / N[Abs[z], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\left|x\right|, \left|y\right|\right)\\
t_2 := \frac{t\_1}{\left|z\right|}\\
t_3 := \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}\;t\_2 \leq 5 \cdot 10^{+265}:\\
\;\;\;\;t\_3 \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_3 \cdot t\_1}{\left|z\right|}\\
\end{array}\right)\right)
\end{array}
if (/.f64 y z) < 5.0000000000000002e265Initial program 81.7%
Applied rewrites92.5%
if 5.0000000000000002e265 < (/.f64 y z) Initial program 81.7%
Taylor expanded in x around 0
Applied rewrites92.1%
(FPCore (x y z t) :precision binary64 :pre TRUE (/ (* x y) z))
double code(double x, double y, double z, double t) {
return (x * y) / z;
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * y) / z
end function
public static double code(double x, double y, double z, double t) {
return (x * y) / z;
}
def code(x, y, z, t): return (x * y) / z
function code(x, y, z, t) return Float64(Float64(x * y) / z) end
function tmp = code(x, y, z, t) tmp = (x * y) / z; end
code[x_, y_, z_, t_] := N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (x * y) / z END code
\frac{x \cdot y}{z}
Initial program 81.7%
Taylor expanded in x around 0
Applied rewrites92.1%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
:precision binary64
(* x (/ (* (/ y z) t) t)))