
(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 13 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 (<= (* z 3.0) 5e+89) (+ x (/ (- (/ t y) y) (* z 3.0))) (fma (/ t (* z y)) 0.3333333333333333 (fma y (/ -0.3333333333333333 z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * 3.0) <= 5e+89) {
tmp = x + (((t / y) - y) / (z * 3.0));
} else {
tmp = fma((t / (z * y)), 0.3333333333333333, fma(y, (-0.3333333333333333 / z), x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * 3.0) <= 5e+89) tmp = Float64(x + Float64(Float64(Float64(t / y) - y) / Float64(z * 3.0))); else tmp = fma(Float64(t / Float64(z * y)), 0.3333333333333333, fma(y, Float64(-0.3333333333333333 / z), x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * 3.0), $MachinePrecision], 5e+89], N[(x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333 + N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq 5 \cdot 10^{+89}:\\
\;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{z \cdot y}, 0.3333333333333333, \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\right)\\
\end{array}
\end{array}
if (*.f64 z #s(literal 3 binary64)) < 4.99999999999999983e89Initial program 93.2%
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-/.f6498.9
Applied rewrites98.9%
if 4.99999999999999983e89 < (*.f64 z #s(literal 3 binary64)) Initial program 99.7%
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-eval99.8
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
distribute-neg-frac2N/A
div-invN/A
lower-fma.f64N/A
Applied rewrites99.8%
Final simplification99.1%
(FPCore (x y z t)
:precision binary64
(if (<= y -7e+32)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 1.66e-6)
(fma (/ t z) (/ 0.3333333333333333 y) x)
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -7e+32) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 1.66e-6) {
tmp = fma((t / z), (0.3333333333333333 / y), x);
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -7e+32) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 1.66e-6) tmp = fma(Float64(t / z), Float64(0.3333333333333333 / y), x); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -7e+32], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.66e-6], N[(N[(t / z), $MachinePrecision] * N[(0.3333333333333333 / y), $MachinePrecision] + x), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 1.66 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{z}, \frac{0.3333333333333333}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -7.0000000000000002e32Initial 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 rewrites93.0%
if -7.0000000000000002e32 < y < 1.65999999999999999e-6Initial program 91.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-/.f6495.2
Applied rewrites95.2%
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 rewrites86.7%
Applied rewrites93.4%
if 1.65999999999999999e-6 < y Initial program 99.9%
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.9
Applied rewrites99.9%
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 rewrites90.0%
(FPCore (x y z t)
:precision binary64
(if (<= y -7e+32)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 1.66e-6)
(fma (/ 0.3333333333333333 z) (/ t y) x)
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -7e+32) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 1.66e-6) {
tmp = fma((0.3333333333333333 / z), (t / y), x);
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -7e+32) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 1.66e-6) tmp = fma(Float64(0.3333333333333333 / z), Float64(t / y), x); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -7e+32], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.66e-6], N[(N[(0.3333333333333333 / z), $MachinePrecision] * N[(t / y), $MachinePrecision] + x), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 1.66 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\frac{0.3333333333333333}{z}, \frac{t}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -7.0000000000000002e32Initial 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 rewrites93.0%
if -7.0000000000000002e32 < y < 1.65999999999999999e-6Initial program 91.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-/.f6495.2
Applied rewrites95.2%
Taylor expanded in t around inf
Applied rewrites89.6%
if 1.65999999999999999e-6 < y Initial program 99.9%
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.9
Applied rewrites99.9%
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 rewrites90.0%
(FPCore (x y z t)
:precision binary64
(if (<= y -7e+32)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 6.9e-9)
(fma 0.3333333333333333 (/ t (* z y)) x)
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -7e+32) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 6.9e-9) {
tmp = fma(0.3333333333333333, (t / (z * y)), x);
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -7e+32) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 6.9e-9) tmp = fma(0.3333333333333333, Float64(t / Float64(z * y)), x); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -7e+32], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 6.9e-9], N[(0.3333333333333333 * N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 6.9 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, \frac{t}{z \cdot y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -7.0000000000000002e32Initial 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 rewrites93.0%
if -7.0000000000000002e32 < y < 6.89999999999999975e-9Initial program 91.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-/.f6495.2
Applied rewrites95.2%
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 rewrites86.7%
if 6.89999999999999975e-9 < y Initial program 99.9%
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.9
Applied rewrites99.9%
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 rewrites90.0%
Final simplification88.8%
(FPCore (x y z t)
:precision binary64
(if (<= y -5.5)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 3.15e-30)
(/ t (* (* z 3.0) y))
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 3.15e-30) {
tmp = t / ((z * 3.0) * y);
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 3.15e-30) tmp = Float64(t / Float64(Float64(z * 3.0) * y)); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 3.15e-30], N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 3.15 \cdot 10^{-30}:\\
\;\;\;\;\frac{t}{\left(z \cdot 3\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -5.5Initial program 96.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 rewrites89.1%
if -5.5 < y < 3.14999999999999991e-30Initial program 90.9%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6465.5
Applied rewrites65.5%
Applied rewrites65.6%
if 3.14999999999999991e-30 < y Initial program 99.9%
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.9
Applied rewrites99.9%
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.0%
Final simplification76.9%
(FPCore (x y z t)
:precision binary64
(if (<= y -5.5)
(fma y (/ -0.3333333333333333 z) x)
(if (<= y 3.15e-30)
(* (/ t (* z y)) 0.3333333333333333)
(fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5) {
tmp = fma(y, (-0.3333333333333333 / z), x);
} else if (y <= 3.15e-30) {
tmp = (t / (z * y)) * 0.3333333333333333;
} else {
tmp = fma(-0.3333333333333333, (y / z), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5) tmp = fma(y, Float64(-0.3333333333333333 / z), x); elseif (y <= 3.15e-30) tmp = Float64(Float64(t / Float64(z * y)) * 0.3333333333333333); else tmp = fma(-0.3333333333333333, Float64(y / z), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5], N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 3.15e-30], N[(N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{elif}\;y \leq 3.15 \cdot 10^{-30}:\\
\;\;\;\;\frac{t}{z \cdot y} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if y < -5.5Initial program 96.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 rewrites89.1%
if -5.5 < y < 3.14999999999999991e-30Initial program 90.9%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6465.5
Applied rewrites65.5%
Applied rewrites65.5%
if 3.14999999999999991e-30 < y Initial program 99.9%
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.9
Applied rewrites99.9%
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.0%
Final simplification76.9%
(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.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-/.f6497.2
Applied rewrites97.2%
Final simplification97.2%
(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.5%
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.2
Applied rewrites97.2%
(FPCore (x y z t) :precision binary64 (fma -0.3333333333333333 (/ y z) x))
double code(double x, double y, double z, double t) {
return fma(-0.3333333333333333, (y / z), x);
}
function code(x, y, z, t) return fma(-0.3333333333333333, Float64(y / z), x) end
code[x_, y_, z_, t_] := N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)
\end{array}
Initial program 94.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-/.f6497.2
Applied rewrites97.2%
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 rewrites57.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 94.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 rewrites57.6%
(FPCore (x y z t) :precision binary64 (/ y (* z -3.0)))
double code(double x, double y, double z, double t) {
return 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 = y / (z * (-3.0d0))
end function
public static double code(double x, double y, double z, double t) {
return y / (z * -3.0);
}
def code(x, y, z, t): return y / (z * -3.0)
function code(x, y, z, t) return Float64(y / Float64(z * -3.0)) end
function tmp = code(x, y, z, t) tmp = y / (z * -3.0); end
code[x_, y_, z_, t_] := N[(y / N[(z * -3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{z \cdot -3}
\end{array}
Initial program 94.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-/.f6434.7
Applied rewrites34.7%
Applied rewrites34.7%
(FPCore (x y z t) :precision binary64 (* -0.3333333333333333 (/ y z)))
double code(double x, double y, double z, double t) {
return -0.3333333333333333 * (y / 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 = (-0.3333333333333333d0) * (y / z)
end function
public static double code(double x, double y, double z, double t) {
return -0.3333333333333333 * (y / z);
}
def code(x, y, z, t): return -0.3333333333333333 * (y / z)
function code(x, y, z, t) return Float64(-0.3333333333333333 * Float64(y / z)) end
function tmp = code(x, y, z, t) tmp = -0.3333333333333333 * (y / z); end
code[x_, y_, z_, t_] := N[(-0.3333333333333333 * N[(y / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.3333333333333333 \cdot \frac{y}{z}
\end{array}
Initial program 94.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-/.f6434.7
Applied rewrites34.7%
Applied rewrites34.7%
Final simplification34.7%
(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.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-/.f6434.7
Applied rewrites34.7%
(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 2024221
(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))))