
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= (+ t_1 (/ t (* y (* z 3.0)))) 1e+305)
(+ t_1 (/ t (* z (* y 3.0))))
(* 0.3333333333333333 (/ (- (/ t y) y) z)))))
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if ((t_1 + (t / (y * (z * 3.0)))) <= 1e+305) {
tmp = t_1 + (t / (z * (y * 3.0)));
} else {
tmp = 0.3333333333333333 * (((t / y) - y) / z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x - (y / (z * 3.0d0))
if ((t_1 + (t / (y * (z * 3.0d0)))) <= 1d+305) then
tmp = t_1 + (t / (z * (y * 3.0d0)))
else
tmp = 0.3333333333333333d0 * (((t / y) - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if ((t_1 + (t / (y * (z * 3.0)))) <= 1e+305) {
tmp = t_1 + (t / (z * (y * 3.0)));
} else {
tmp = 0.3333333333333333 * (((t / y) - y) / z);
}
return tmp;
}
def code(x, y, z, t): t_1 = x - (y / (z * 3.0)) tmp = 0 if (t_1 + (t / (y * (z * 3.0)))) <= 1e+305: tmp = t_1 + (t / (z * (y * 3.0))) else: tmp = 0.3333333333333333 * (((t / y) - y) / z) return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (Float64(t_1 + Float64(t / Float64(y * Float64(z * 3.0)))) <= 1e+305) tmp = Float64(t_1 + Float64(t / Float64(z * Float64(y * 3.0)))); else tmp = Float64(0.3333333333333333 * Float64(Float64(Float64(t / y) - y) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - (y / (z * 3.0)); tmp = 0.0; if ((t_1 + (t / (y * (z * 3.0)))) <= 1e+305) tmp = t_1 + (t / (z * (y * 3.0))); else tmp = 0.3333333333333333 * (((t / y) - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+305], N[(t$95$1 + N[(t / N[(z * N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;t\_1 + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq 10^{+305}:\\
\;\;\;\;t\_1 + \frac{t}{z \cdot \left(y \cdot 3\right)}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z}\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (/.f64 y (*.f64 z #s(literal 3 binary64)))) (/.f64 t (*.f64 (*.f64 z #s(literal 3 binary64)) y))) < 9.9999999999999994e304Initial program 97.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6497.9
Applied rewrites97.9%
if 9.9999999999999994e304 < (+.f64 (-.f64 x (/.f64 y (*.f64 z #s(literal 3 binary64)))) (/.f64 t (*.f64 (*.f64 z #s(literal 3 binary64)) y))) Initial program 89.5%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6432.1
Applied rewrites32.1%
Taylor expanded in x around 0
distribute-lft-out--N/A
associate-/r*N/A
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Final simplification98.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ t (* y (* z 3.0)))))
(if (<= (+ (- x (/ y (* z 3.0))) t_1) 5e+303)
(fma (/ y z) -0.3333333333333333 (+ x t_1))
(* (- (/ t y) y) (/ 0.3333333333333333 z)))))
double code(double x, double y, double z, double t) {
double t_1 = t / (y * (z * 3.0));
double tmp;
if (((x - (y / (z * 3.0))) + t_1) <= 5e+303) {
tmp = fma((y / z), -0.3333333333333333, (x + t_1));
} else {
tmp = ((t / y) - y) * (0.3333333333333333 / z);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(t / Float64(y * Float64(z * 3.0))) tmp = 0.0 if (Float64(Float64(x - Float64(y / Float64(z * 3.0))) + t_1) <= 5e+303) tmp = fma(Float64(y / z), -0.3333333333333333, Float64(x + t_1)); else tmp = Float64(Float64(Float64(t / y) - y) * Float64(0.3333333333333333 / z)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], 5e+303], N[(N[(y / z), $MachinePrecision] * -0.3333333333333333 + N[(x + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * N[(0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{if}\;\left(x - \frac{y}{z \cdot 3}\right) + t\_1 \leq 5 \cdot 10^{+303}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, -0.3333333333333333, x + t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{t}{y} - y\right) \cdot \frac{0.3333333333333333}{z}\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (/.f64 y (*.f64 z #s(literal 3 binary64)))) (/.f64 t (*.f64 (*.f64 z #s(literal 3 binary64)) y))) < 4.9999999999999997e303Initial program 97.9%
lift-+.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-+.f6497.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.9
Applied rewrites97.9%
if 4.9999999999999997e303 < (+.f64 (-.f64 x (/.f64 y (*.f64 z #s(literal 3 binary64)))) (/.f64 t (*.f64 (*.f64 z #s(literal 3 binary64)) y))) Initial program 89.7%
Taylor expanded in x around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
associate-*r/N/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
distribute-lft-out--N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (<= (+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0)))) 1e+302) (fma (/ t (* y z)) 0.3333333333333333 (fma y (/ -0.3333333333333333 z) x)) (/ (- (/ t y) y) (* z 3.0))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x - (y / (z * 3.0))) + (t / (y * (z * 3.0)))) <= 1e+302) {
tmp = fma((t / (y * z)), 0.3333333333333333, fma(y, (-0.3333333333333333 / z), x));
} else {
tmp = ((t / y) - y) / (z * 3.0);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(y * Float64(z * 3.0)))) <= 1e+302) tmp = fma(Float64(t / Float64(y * z)), 0.3333333333333333, fma(y, Float64(-0.3333333333333333 / z), x)); else tmp = Float64(Float64(Float64(t / y) - y) / Float64(z * 3.0)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+302], N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333 + N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq 10^{+302}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{y \cdot z}, 0.3333333333333333, \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t}{y} - y}{z \cdot 3}\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (/.f64 y (*.f64 z #s(literal 3 binary64)))) (/.f64 t (*.f64 (*.f64 z #s(literal 3 binary64)) y))) < 1.0000000000000001e302Initial program 97.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
metadata-eval97.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
distribute-neg-frac2N/A
div-invN/A
lower-fma.f64N/A
Applied rewrites97.9%
if 1.0000000000000001e302 < (+.f64 (-.f64 x (/.f64 y (*.f64 z #s(literal 3 binary64)))) (/.f64 t (*.f64 (*.f64 z #s(literal 3 binary64)) y))) Initial program 90.1%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6436.2
Applied rewrites36.2%
Taylor expanded in x around 0
distribute-lft-out--N/A
associate-/r*N/A
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (<= (* z 3.0) -5e+119) (fma 0.3333333333333333 (/ t (* y z)) x) (+ x (/ (/ (- (/ t y) y) 3.0) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * 3.0) <= -5e+119) {
tmp = fma(0.3333333333333333, (t / (y * z)), x);
} else {
tmp = x + ((((t / y) - y) / 3.0) / z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * 3.0) <= -5e+119) tmp = fma(0.3333333333333333, Float64(t / Float64(y * z)), x); else tmp = Float64(x + Float64(Float64(Float64(Float64(t / y) - y) / 3.0) / z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * 3.0), $MachinePrecision], -5e+119], N[(0.3333333333333333 * N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / 3.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -5 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, \frac{t}{y \cdot z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\frac{\frac{t}{y} - y}{3}}{z}\\
\end{array}
\end{array}
if (*.f64 z #s(literal 3 binary64)) < -4.9999999999999999e119Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Applied rewrites77.3%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6494.3
Applied rewrites94.3%
if -4.9999999999999999e119 < (*.f64 z #s(literal 3 binary64)) Initial program 96.0%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
Final simplification97.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z 3.0) -5e+119) (fma 0.3333333333333333 (/ t (* y z)) x) (- x (/ (fma y 0.3333333333333333 (/ t (* y (- 3.0)))) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * 3.0) <= -5e+119) {
tmp = fma(0.3333333333333333, (t / (y * z)), x);
} else {
tmp = x - (fma(y, 0.3333333333333333, (t / (y * -3.0))) / z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * 3.0) <= -5e+119) tmp = fma(0.3333333333333333, Float64(t / Float64(y * z)), x); else tmp = Float64(x - Float64(fma(y, 0.3333333333333333, Float64(t / Float64(y * Float64(-3.0)))) / z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * 3.0), $MachinePrecision], -5e+119], N[(0.3333333333333333 * N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x - N[(N[(y * 0.3333333333333333 + N[(t / N[(y * (-3.0)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -5 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, \frac{t}{y \cdot z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{fma}\left(y, 0.3333333333333333, \frac{t}{y \cdot \left(-3\right)}\right)}{z}\\
\end{array}
\end{array}
if (*.f64 z #s(literal 3 binary64)) < -4.9999999999999999e119Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Applied rewrites77.3%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6494.3
Applied rewrites94.3%
if -4.9999999999999999e119 < (*.f64 z #s(literal 3 binary64)) Initial program 96.0%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
div-invN/A
metadata-evalN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Final simplification97.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z 3.0) -5e+119) (fma 0.3333333333333333 (/ t (* y z)) x) (fma (/ 0.3333333333333333 z) (- (/ t y) y) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * 3.0) <= -5e+119) {
tmp = fma(0.3333333333333333, (t / (y * z)), x);
} else {
tmp = fma((0.3333333333333333 / z), ((t / y) - y), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * 3.0) <= -5e+119) tmp = fma(0.3333333333333333, Float64(t / Float64(y * z)), x); else tmp = fma(Float64(0.3333333333333333 / z), Float64(Float64(t / y) - y), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * 3.0), $MachinePrecision], -5e+119], N[(0.3333333333333333 * N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(0.3333333333333333 / z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -5 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, \frac{t}{y \cdot z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{0.3333333333333333}{z}, \frac{t}{y} - y, x\right)\\
\end{array}
\end{array}
if (*.f64 z #s(literal 3 binary64)) < -4.9999999999999999e119Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Applied rewrites77.3%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6494.3
Applied rewrites94.3%
if -4.9999999999999999e119 < (*.f64 z #s(literal 3 binary64)) Initial program 96.0%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
associate-*r/N/A
associate-*r/N/A
associate-*l/N/A
metadata-evalN/A
associate-*r/N/A
distribute-lft-out--N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6497.7
Applied rewrites97.7%
(FPCore (x y z t)
:precision binary64
(if (<= y -3.9e+40)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 1.85e+46)
(fma 0.3333333333333333 (/ t (* y z)) x)
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.9e+40) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 1.85e+46) {
tmp = fma(0.3333333333333333, (t / (y * z)), x);
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -3.9e+40) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 1.85e+46) tmp = fma(0.3333333333333333, Float64(t / Float64(y * z)), x); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.9e+40], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.85e+46], N[(0.3333333333333333 * N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+40}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, \frac{t}{y \cdot z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -3.9000000000000001e40Initial program 96.5%
Taylor expanded in y around inf
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*l/N/A
associate-*r/N/A
cancel-sign-subN/A
mul-1-negN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
mul-1-negN/A
*-inversesN/A
cancel-sign-subN/A
*-rgt-identityN/A
Applied rewrites90.7%
if -3.9000000000000001e40 < y < 1.84999999999999995e46Initial program 95.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6495.2
Applied rewrites95.2%
Applied rewrites92.5%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6492.2
Applied rewrites92.2%
if 1.84999999999999995e46 < y Initial program 99.8%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
sub-negN/A
distribute-rgt-inN/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
associate-*l*N/A
associate-*l/N/A
*-lft-identityN/A
unsub-negN/A
neg-sub0N/A
associate--r+N/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
distribute-lft-neg-inN/A
metadata-evalN/A
Applied rewrites96.1%
(FPCore (x y z t)
:precision binary64
(if (<= y -3.5e-50)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 4.6e-40)
(* 0.3333333333333333 (/ t (* y z)))
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.5e-50) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 4.6e-40) {
tmp = 0.3333333333333333 * (t / (y * z));
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -3.5e-50) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 4.6e-40) tmp = Float64(0.3333333333333333 * Float64(t / Float64(y * z))); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.5e-50], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 4.6e-40], N[(0.3333333333333333 * N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-40}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{t}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -3.49999999999999997e-50Initial program 97.1%
Taylor expanded in y around inf
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*l/N/A
associate-*r/N/A
cancel-sign-subN/A
mul-1-negN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
mul-1-negN/A
*-inversesN/A
cancel-sign-subN/A
*-rgt-identityN/A
Applied rewrites85.0%
if -3.49999999999999997e-50 < y < 4.6e-40Initial program 93.5%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f642.5
Applied rewrites2.5%
Taylor expanded in x around 0
distribute-lft-out--N/A
associate-/r*N/A
div-subN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6473.0
Applied rewrites73.0%
Taylor expanded in t around inf
Applied rewrites75.6%
if 4.6e-40 < y Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
Taylor expanded in y around inf
sub-negN/A
distribute-rgt-inN/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
associate-*l*N/A
associate-*l/N/A
*-lft-identityN/A
unsub-negN/A
neg-sub0N/A
associate--r+N/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
distribute-lft-neg-inN/A
metadata-evalN/A
Applied rewrites86.6%
(FPCore (x y z t) :precision binary64 (fma y (/ -0.3333333333333333 z) x))
double code(double x, double y, double z, double t) {
return fma(y, (-0.3333333333333333 / z), x);
}
function code(x, y, z, t) return fma(y, Float64(-0.3333333333333333 / z), x) end
code[x_, y_, z_, t_] := N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)
\end{array}
Initial program 96.4%
Taylor expanded in y around inf
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*l/N/A
associate-*r/N/A
cancel-sign-subN/A
mul-1-negN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
mul-1-negN/A
*-inversesN/A
cancel-sign-subN/A
*-rgt-identityN/A
Applied rewrites58.6%
(FPCore (x y z t) :precision binary64 (* y (/ -0.3333333333333333 z)))
double code(double x, double y, double z, double t) {
return y * (-0.3333333333333333 / z);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = y * ((-0.3333333333333333d0) / z)
end function
public static double code(double x, double y, double z, double t) {
return y * (-0.3333333333333333 / z);
}
def code(x, y, z, t): return y * (-0.3333333333333333 / z)
function code(x, y, z, t) return Float64(y * Float64(-0.3333333333333333 / z)) end
function tmp = code(x, y, z, t) tmp = y * (-0.3333333333333333 / z); end
code[x_, y_, z_, t_] := N[(y * N[(-0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{-0.3333333333333333}{z}
\end{array}
Initial program 96.4%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6432.8
Applied rewrites32.8%
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y)))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + ((t / (z * 3.0d0)) / y)
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y);
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y)
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(t / Float64(z * 3.0)) / y)) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / N[(z * 3.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}
\end{array}
herbie shell --seed 2024220
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:alt
(! :herbie-platform default (+ (- x (/ y (* z 3))) (/ (/ t (* z 3)) y)))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))