
(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 12 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 (if (<= t 1e+27) (+ (- x (/ y (* z 3.0))) (/ (/ t z) (* y 3.0))) (+ (- x (/ (* y 0.3333333333333333) z)) (/ t (* y (* z 3.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1e+27) {
tmp = (x - (y / (z * 3.0))) + ((t / z) / (y * 3.0));
} else {
tmp = (x - ((y * 0.3333333333333333) / z)) + (t / (y * (z * 3.0)));
}
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) :: tmp
if (t <= 1d+27) then
tmp = (x - (y / (z * 3.0d0))) + ((t / z) / (y * 3.0d0))
else
tmp = (x - ((y * 0.3333333333333333d0) / z)) + (t / (y * (z * 3.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1e+27) {
tmp = (x - (y / (z * 3.0))) + ((t / z) / (y * 3.0));
} else {
tmp = (x - ((y * 0.3333333333333333) / z)) + (t / (y * (z * 3.0)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= 1e+27: tmp = (x - (y / (z * 3.0))) + ((t / z) / (y * 3.0)) else: tmp = (x - ((y * 0.3333333333333333) / z)) + (t / (y * (z * 3.0))) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= 1e+27) tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(t / z) / Float64(y * 3.0))); else tmp = Float64(Float64(x - Float64(Float64(y * 0.3333333333333333) / z)) + Float64(t / Float64(y * Float64(z * 3.0)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= 1e+27) tmp = (x - (y / (z * 3.0))) + ((t / z) / (y * 3.0)); else tmp = (x - ((y * 0.3333333333333333) / z)) + (t / (y * (z * 3.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, 1e+27], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / z), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[(N[(y * 0.3333333333333333), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 10^{+27}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z}}{y \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\left(x - \frac{y \cdot 0.3333333333333333}{z}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\end{array}
\end{array}
if t < 1e27Initial program 94.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
if 1e27 < t Initial program 96.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval96.7
Applied rewrites96.7%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (<= (* z 3.0) 4e+73) (fma (/ 0.3333333333333333 z) (- (/ t y) y) x) (+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * 3.0) <= 4e+73) {
tmp = fma((0.3333333333333333 / z), ((t / y) - y), x);
} else {
tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * 3.0) <= 4e+73) tmp = fma(Float64(0.3333333333333333 / z), Float64(Float64(t / y) - y), x); else tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(y * Float64(z * 3.0)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * 3.0), $MachinePrecision], 4e+73], N[(N[(0.3333333333333333 / z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] + x), $MachinePrecision], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq 4 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{fma}\left(\frac{0.3333333333333333}{z}, \frac{t}{y} - y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\end{array}
\end{array}
if (*.f64 z #s(literal 3 binary64)) < 3.99999999999999993e73Initial program 94.2%
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.9
Applied rewrites97.9%
if 3.99999999999999993e73 < (*.f64 z #s(literal 3 binary64)) Initial program 97.6%
Final simplification97.9%
(FPCore (x y z t) :precision binary64 (if (<= (* z 3.0) 4e-19) (fma (/ 0.3333333333333333 z) (- (/ t y) y) x) (fma (/ t (* y z)) 0.3333333333333333 (fma (/ y z) -0.3333333333333333 x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * 3.0) <= 4e-19) {
tmp = fma((0.3333333333333333 / z), ((t / y) - y), x);
} else {
tmp = fma((t / (y * z)), 0.3333333333333333, fma((y / z), -0.3333333333333333, x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * 3.0) <= 4e-19) tmp = fma(Float64(0.3333333333333333 / z), Float64(Float64(t / y) - y), x); else tmp = fma(Float64(t / Float64(y * z)), 0.3333333333333333, fma(Float64(y / z), -0.3333333333333333, x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * 3.0), $MachinePrecision], 4e-19], N[(N[(0.3333333333333333 / z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] + x), $MachinePrecision], N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333 + N[(N[(y / z), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq 4 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(\frac{0.3333333333333333}{z}, \frac{t}{y} - y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{y \cdot z}, 0.3333333333333333, \mathsf{fma}\left(\frac{y}{z}, -0.3333333333333333, x\right)\right)\\
\end{array}
\end{array}
if (*.f64 z #s(literal 3 binary64)) < 3.9999999999999999e-19Initial program 93.7%
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.8
Applied rewrites97.8%
if 3.9999999999999999e-19 < (*.f64 z #s(literal 3 binary64)) Initial program 98.1%
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-eval98.1
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites98.1%
(FPCore (x y z t)
:precision binary64
(if (<= y -5e+79)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 1.6e-65)
(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 <= -5e+79) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 1.6e-65) {
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 <= -5e+79) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 1.6e-65) 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, -5e+79], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.6e-65], 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 -5 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-65}:\\
\;\;\;\;\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 < -5e79Initial program 99.7%
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 rewrites97.6%
if -5e79 < y < 1.6e-65Initial program 90.6%
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-/.f6492.3
Applied rewrites92.3%
Taylor expanded in y around 0
div-subN/A
*-commutativeN/A
associate-/l*N/A
remove-double-negN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
associate-/l*N/A
associate-/l/N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
mul-1-negN/A
Applied rewrites85.3%
if 1.6e-65 < y Initial program 98.5%
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
distribute-lft-neg-outN/A
mul-1-negN/A
*-commutativeN/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 rewrites91.7%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.15e-54)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 6.5e-96)
(/ t (* y (* z 3.0)))
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.15e-54) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 6.5e-96) {
tmp = t / (y * (z * 3.0));
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.15e-54) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 6.5e-96) tmp = Float64(t / Float64(y * Float64(z * 3.0))); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.15e-54], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 6.5e-96], N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{-54}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-96}:\\
\;\;\;\;\frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -1.1499999999999999e-54Initial program 95.9%
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 rewrites81.1%
if -1.1499999999999999e-54 < y < 6.50000000000000001e-96Initial program 90.8%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6471.1
Applied rewrites71.1%
Applied rewrites71.5%
if 6.50000000000000001e-96 < y Initial program 97.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
distribute-lft-neg-outN/A
mul-1-negN/A
*-commutativeN/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 rewrites89.6%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.15e-54)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 2.7e-95)
(* 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 <= -1.15e-54) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 2.7e-95) {
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 <= -1.15e-54) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 2.7e-95) 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, -1.15e-54], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.7e-95], 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 -1.15 \cdot 10^{-54}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-95}:\\
\;\;\;\;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 < -1.1499999999999999e-54Initial program 95.9%
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 rewrites81.1%
if -1.1499999999999999e-54 < y < 2.7e-95Initial program 90.8%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6471.1
Applied rewrites71.1%
Applied rewrites71.1%
if 2.7e-95 < y Initial program 97.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
distribute-lft-neg-outN/A
mul-1-negN/A
*-commutativeN/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 rewrites89.6%
Final simplification80.8%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.15e-54)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 2.7e-95)
(* t (/ 0.3333333333333333 (* y z)))
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.15e-54) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 2.7e-95) {
tmp = t * (0.3333333333333333 / (y * z));
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.15e-54) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 2.7e-95) tmp = Float64(t * Float64(0.3333333333333333 / Float64(y * z))); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.15e-54], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.7e-95], N[(t * N[(0.3333333333333333 / 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 -1.15 \cdot 10^{-54}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-95}:\\
\;\;\;\;t \cdot \frac{0.3333333333333333}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -1.1499999999999999e-54Initial program 95.9%
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 rewrites81.1%
if -1.1499999999999999e-54 < y < 2.7e-95Initial program 90.8%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6471.1
Applied rewrites71.1%
Applied rewrites69.8%
if 2.7e-95 < y Initial program 97.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
distribute-lft-neg-outN/A
mul-1-negN/A
*-commutativeN/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 rewrites89.6%
(FPCore (x y z t) :precision binary64 (+ x (/ (- (/ t y) y) (* z 3.0))))
double code(double x, double y, double z, double t) {
return x + (((t / y) - y) / (z * 3.0));
}
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 + (((t / y) - y) / (z * 3.0d0))
end function
public static double code(double x, double y, double z, double t) {
return x + (((t / y) - y) / (z * 3.0));
}
def code(x, y, z, t): return x + (((t / y) - y) / (z * 3.0))
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(t / y) - y) / Float64(z * 3.0))) end
function tmp = code(x, y, z, t) tmp = x + (((t / y) - y) / (z * 3.0)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\frac{t}{y} - y}{z \cdot 3}
\end{array}
Initial program 94.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-/.f6496.1
Applied rewrites96.1%
Final simplification96.1%
(FPCore (x y z t) :precision binary64 (fma (/ 0.3333333333333333 z) (- (/ t y) y) x))
double code(double x, double y, double z, double t) {
return fma((0.3333333333333333 / z), ((t / y) - y), x);
}
function code(x, y, z, t) return fma(Float64(0.3333333333333333 / z), Float64(Float64(t / y) - y), x) end
code[x_, y_, z_, t_] := N[(N[(0.3333333333333333 / z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{0.3333333333333333}{z}, \frac{t}{y} - y, x\right)
\end{array}
Initial program 94.8%
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-/.f6496.0
Applied rewrites96.0%
(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 94.8%
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 rewrites64.8%
(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(Float64(y * -0.3333333333333333) / z) end
function tmp = code(x, y, z, t) tmp = (y * -0.3333333333333333) / z; end
code[x_, y_, z_, t_] := N[(N[(y * -0.3333333333333333), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{y \cdot -0.3333333333333333}{z}
\end{array}
Initial program 94.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-/.f6496.1
Applied rewrites96.1%
Taylor expanded in y around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f6440.9
Applied rewrites40.9%
Final simplification40.9%
(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 94.8%
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-/.f6440.9
Applied rewrites40.9%
(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 2024257
(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))))