
(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 16 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 1.5e-91) (+ (/ (/ t z) (* 3.0 y)) (- x (/ y (* 3.0 z)))) (fma (/ (/ 0.3333333333333333 z) y) t (fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 1.5e-91) {
tmp = ((t / z) / (3.0 * y)) + (x - (y / (3.0 * z)));
} else {
tmp = fma(((0.3333333333333333 / z) / y), t, fma(-0.3333333333333333, (y / z), x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= 1.5e-91) tmp = Float64(Float64(Float64(t / z) / Float64(3.0 * y)) + Float64(x - Float64(y / Float64(3.0 * z)))); else tmp = fma(Float64(Float64(0.3333333333333333 / z) / y), t, fma(-0.3333333333333333, Float64(y / z), x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, 1.5e-91], N[(N[(N[(t / z), $MachinePrecision] / N[(3.0 * y), $MachinePrecision]), $MachinePrecision] + N[(x - N[(y / N[(3.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.3333333333333333 / z), $MachinePrecision] / y), $MachinePrecision] * t + N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.5 \cdot 10^{-91}:\\
\;\;\;\;\frac{\frac{t}{z}}{3 \cdot y} + \left(x - \frac{y}{3 \cdot z}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{0.3333333333333333}{z}}{y}, t, \mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\right)\\
\end{array}
\end{array}
if t < 1.5000000000000001e-91Initial program 95.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6498.8
Applied rewrites98.8%
if 1.5000000000000001e-91 < t Initial program 96.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval99.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
distribute-neg-fracN/A
neg-mul-1N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites99.9%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (if (<= t 2e-92) (- x (/ (- y (/ t y)) (* 3.0 z))) (fma (/ (/ 0.3333333333333333 z) y) t (fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 2e-92) {
tmp = x - ((y - (t / y)) / (3.0 * z));
} else {
tmp = fma(((0.3333333333333333 / z) / y), t, fma(-0.3333333333333333, (y / z), x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= 2e-92) tmp = Float64(x - Float64(Float64(y - Float64(t / y)) / Float64(3.0 * z))); else tmp = fma(Float64(Float64(0.3333333333333333 / z) / y), t, fma(-0.3333333333333333, Float64(y / z), x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, 2e-92], N[(x - N[(N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] / N[(3.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.3333333333333333 / z), $MachinePrecision] / y), $MachinePrecision] * t + N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 2 \cdot 10^{-92}:\\
\;\;\;\;x - \frac{y - \frac{t}{y}}{3 \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{0.3333333333333333}{z}}{y}, t, \mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\right)\\
\end{array}
\end{array}
if t < 1.99999999999999998e-92Initial program 95.3%
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.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.1
Applied rewrites98.1%
if 1.99999999999999998e-92 < t Initial program 96.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval99.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
distribute-neg-fracN/A
neg-mul-1N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites99.9%
(FPCore (x y z t) :precision binary64 (if (<= t 5e-29) (- x (/ (- y (/ t y)) (* 3.0 z))) (fma (/ 0.3333333333333333 (* z y)) t (fma -0.3333333333333333 (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= 5e-29) {
tmp = x - ((y - (t / y)) / (3.0 * z));
} else {
tmp = fma((0.3333333333333333 / (z * y)), t, fma(-0.3333333333333333, (y / z), x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= 5e-29) tmp = Float64(x - Float64(Float64(y - Float64(t / y)) / Float64(3.0 * z))); else tmp = fma(Float64(0.3333333333333333 / Float64(z * y)), t, fma(-0.3333333333333333, Float64(y / z), x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, 5e-29], N[(x - N[(N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] / N[(3.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.3333333333333333 / N[(z * y), $MachinePrecision]), $MachinePrecision] * t + N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 5 \cdot 10^{-29}:\\
\;\;\;\;x - \frac{y - \frac{t}{y}}{3 \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{0.3333333333333333}{z \cdot y}, t, \mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\right)\\
\end{array}
\end{array}
if t < 4.99999999999999986e-29Initial program 95.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-/.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
if 4.99999999999999986e-29 < t Initial program 95.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval99.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
distribute-neg-fracN/A
neg-mul-1N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Final simplification98.7%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.14e-32)
(fma -0.3333333333333333 (/ y z) x)
(if (<= y 2.2e+20)
(- x (* (/ (/ t z) y) -0.3333333333333333))
(fma (/ -0.3333333333333333 z) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.14e-32) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else if (y <= 2.2e+20) {
tmp = x - (((t / z) / y) * -0.3333333333333333);
} else {
tmp = fma((-0.3333333333333333 / z), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.14e-32) tmp = fma(-0.3333333333333333, Float64(y / z), x); elseif (y <= 2.2e+20) tmp = Float64(x - Float64(Float64(Float64(t / z) / y) * -0.3333333333333333)); else tmp = fma(Float64(-0.3333333333333333 / z), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.14e-32], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.2e+20], N[(x - N[(N[(N[(t / z), $MachinePrecision] / y), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision], N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.14 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+20}:\\
\;\;\;\;x - \frac{\frac{t}{z}}{y} \cdot -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)\\
\end{array}
\end{array}
if y < -1.14000000000000005e-32Initial program 98.3%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
if -1.14000000000000005e-32 < y < 2.2e20Initial 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-/.f6491.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.8
Applied rewrites91.8%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.7
Applied rewrites91.7%
Applied rewrites96.7%
if 2.2e20 < y Initial program 97.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-/.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.4
Applied rewrites94.4%
Applied rewrites94.5%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.14e-32)
(fma -0.3333333333333333 (/ y z) x)
(if (<= y 2.55e+45)
(- x (/ t (* (* -3.0 z) y)))
(fma (/ -0.3333333333333333 z) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.14e-32) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else if (y <= 2.55e+45) {
tmp = x - (t / ((-3.0 * z) * y));
} else {
tmp = fma((-0.3333333333333333 / z), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.14e-32) tmp = fma(-0.3333333333333333, Float64(y / z), x); elseif (y <= 2.55e+45) tmp = Float64(x - Float64(t / Float64(Float64(-3.0 * z) * y))); else tmp = fma(Float64(-0.3333333333333333 / z), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.14e-32], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.55e+45], N[(x - N[(t / N[(N[(-3.0 * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.14 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{elif}\;y \leq 2.55 \cdot 10^{+45}:\\
\;\;\;\;x - \frac{t}{\left(-3 \cdot z\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)\\
\end{array}
\end{array}
if y < -1.14000000000000005e-32Initial program 98.3%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
if -1.14000000000000005e-32 < y < 2.5499999999999999e45Initial program 93.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.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.2
Applied rewrites92.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
Applied rewrites91.7%
if 2.5499999999999999e45 < y Initial program 96.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.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Applied rewrites96.9%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.14e-32)
(fma -0.3333333333333333 (/ y z) x)
(if (<= y 2.55e+45)
(- x (* (/ -0.3333333333333333 (* z y)) t))
(fma (/ -0.3333333333333333 z) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.14e-32) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else if (y <= 2.55e+45) {
tmp = x - ((-0.3333333333333333 / (z * y)) * t);
} else {
tmp = fma((-0.3333333333333333 / z), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.14e-32) tmp = fma(-0.3333333333333333, Float64(y / z), x); elseif (y <= 2.55e+45) tmp = Float64(x - Float64(Float64(-0.3333333333333333 / Float64(z * y)) * t)); else tmp = fma(Float64(-0.3333333333333333 / z), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.14e-32], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.55e+45], N[(x - N[(N[(-0.3333333333333333 / N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.14 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{elif}\;y \leq 2.55 \cdot 10^{+45}:\\
\;\;\;\;x - \frac{-0.3333333333333333}{z \cdot y} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)\\
\end{array}
\end{array}
if y < -1.14000000000000005e-32Initial program 98.3%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
if -1.14000000000000005e-32 < y < 2.5499999999999999e45Initial program 93.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.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.2
Applied rewrites92.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
Applied rewrites91.0%
if 2.5499999999999999e45 < y Initial program 96.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.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Applied rewrites96.9%
Final simplification94.1%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.14e-32)
(fma -0.3333333333333333 (/ y z) x)
(if (<= y 2.55e+45)
(fma (/ t (* z y)) 0.3333333333333333 x)
(fma (/ -0.3333333333333333 z) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.14e-32) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else if (y <= 2.55e+45) {
tmp = fma((t / (z * y)), 0.3333333333333333, x);
} else {
tmp = fma((-0.3333333333333333 / z), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.14e-32) tmp = fma(-0.3333333333333333, Float64(y / z), x); elseif (y <= 2.55e+45) tmp = fma(Float64(t / Float64(z * y)), 0.3333333333333333, x); else tmp = fma(Float64(-0.3333333333333333 / z), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.14e-32], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.55e+45], N[(N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333 + x), $MachinePrecision], N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.14 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{elif}\;y \leq 2.55 \cdot 10^{+45}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{z \cdot y}, 0.3333333333333333, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)\\
\end{array}
\end{array}
if y < -1.14000000000000005e-32Initial program 98.3%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
if -1.14000000000000005e-32 < y < 2.5499999999999999e45Initial program 93.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.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.2
Applied rewrites92.2%
Taylor expanded in y around 0
div-subN/A
associate-*l/N/A
remove-double-negN/A
distribute-lft-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
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
Applied rewrites91.0%
if 2.5499999999999999e45 < y Initial program 96.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.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Applied rewrites96.9%
(FPCore (x y z t)
:precision binary64
(if (<= y -9.8e-71)
(fma -0.3333333333333333 (/ y z) x)
(if (<= y 8e-27)
(/ t (* (* 3.0 z) y))
(fma (/ -0.3333333333333333 z) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.8e-71) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else if (y <= 8e-27) {
tmp = t / ((3.0 * z) * y);
} else {
tmp = fma((-0.3333333333333333 / z), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -9.8e-71) tmp = fma(-0.3333333333333333, Float64(y / z), x); elseif (y <= 8e-27) tmp = Float64(t / Float64(Float64(3.0 * z) * y)); else tmp = fma(Float64(-0.3333333333333333 / z), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.8e-71], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 8e-27], N[(t / N[(N[(3.0 * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{-71}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-27}:\\
\;\;\;\;\frac{t}{\left(3 \cdot z\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)\\
\end{array}
\end{array}
if y < -9.7999999999999994e-71Initial program 98.4%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
if -9.7999999999999994e-71 < y < 8.0000000000000003e-27Initial program 92.4%
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-/.f6490.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.8
Applied rewrites90.8%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
Applied rewrites64.5%
if 8.0000000000000003e-27 < y Initial program 97.3%
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
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.3
Applied rewrites91.3%
Applied rewrites91.4%
(FPCore (x y z t)
:precision binary64
(if (<= y -9.8e-71)
(fma -0.3333333333333333 (/ y z) x)
(if (<= y 8e-27)
(* (/ 0.3333333333333333 (* z y)) t)
(fma (/ -0.3333333333333333 z) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.8e-71) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else if (y <= 8e-27) {
tmp = (0.3333333333333333 / (z * y)) * t;
} else {
tmp = fma((-0.3333333333333333 / z), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -9.8e-71) tmp = fma(-0.3333333333333333, Float64(y / z), x); elseif (y <= 8e-27) tmp = Float64(Float64(0.3333333333333333 / Float64(z * y)) * t); else tmp = fma(Float64(-0.3333333333333333 / z), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.8e-71], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 8e-27], N[(N[(0.3333333333333333 / N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{-71}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-27}:\\
\;\;\;\;\frac{0.3333333333333333}{z \cdot y} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)\\
\end{array}
\end{array}
if y < -9.7999999999999994e-71Initial program 98.4%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
if -9.7999999999999994e-71 < y < 8.0000000000000003e-27Initial program 92.4%
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-/.f6490.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.8
Applied rewrites90.8%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
Applied rewrites63.7%
if 8.0000000000000003e-27 < y Initial program 97.3%
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
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.3
Applied rewrites91.3%
Applied rewrites91.4%
Final simplification81.3%
(FPCore (x y z t)
:precision binary64
(if (<= y -9.8e-71)
(fma -0.3333333333333333 (/ y z) x)
(if (<= y 8e-27)
(* (/ t (* z y)) 0.3333333333333333)
(fma (/ -0.3333333333333333 z) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.8e-71) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else if (y <= 8e-27) {
tmp = (t / (z * y)) * 0.3333333333333333;
} else {
tmp = fma((-0.3333333333333333 / z), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -9.8e-71) tmp = fma(-0.3333333333333333, Float64(y / z), x); elseif (y <= 8e-27) tmp = Float64(Float64(t / Float64(z * y)) * 0.3333333333333333); else tmp = fma(Float64(-0.3333333333333333 / z), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.8e-71], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 8e-27], N[(N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{-71}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-27}:\\
\;\;\;\;\frac{t}{z \cdot y} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)\\
\end{array}
\end{array}
if y < -9.7999999999999994e-71Initial program 98.4%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
if -9.7999999999999994e-71 < y < 8.0000000000000003e-27Initial program 92.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
if 8.0000000000000003e-27 < y Initial program 97.3%
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
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.3
Applied rewrites91.3%
Applied rewrites91.4%
(FPCore (x y z t) :precision binary64 (- x (/ (- y (/ t y)) (* 3.0 z))))
double code(double x, double y, double z, double t) {
return x - ((y - (t / y)) / (3.0 * 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 = x - ((y - (t / y)) / (3.0d0 * z))
end function
public static double code(double x, double y, double z, double t) {
return x - ((y - (t / y)) / (3.0 * z));
}
def code(x, y, z, t): return x - ((y - (t / y)) / (3.0 * z))
function code(x, y, z, t) return Float64(x - Float64(Float64(y - Float64(t / y)) / Float64(3.0 * z))) end
function tmp = code(x, y, z, t) tmp = x - ((y - (t / y)) / (3.0 * z)); end
code[x_, y_, z_, t_] := N[(x - N[(N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] / N[(3.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - \frac{t}{y}}{3 \cdot z}
\end{array}
Initial program 95.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-/.f6496.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.1
Applied rewrites96.1%
(FPCore (x y z t) :precision binary64 (fma (/ (- y (/ t y)) z) -0.3333333333333333 x))
double code(double x, double y, double z, double t) {
return fma(((y - (t / y)) / z), -0.3333333333333333, x);
}
function code(x, y, z, t) return fma(Float64(Float64(y - Float64(t / y)) / z), -0.3333333333333333, x) end
code[x_, y_, z_, t_] := N[(N[(N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y - \frac{t}{y}}{z}, -0.3333333333333333, x\right)
\end{array}
Initial program 95.6%
Taylor expanded in t around 0
associate--l+N/A
+-commutativeN/A
distribute-lft-out--N/A
associate-/r*N/A
div-subN/A
associate-/l*N/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-out--N/A
associate-*r/N/A
Applied rewrites95.8%
(FPCore (x y z t) :precision binary64 (fma (/ -0.3333333333333333 z) y x))
double code(double x, double y, double z, double t) {
return fma((-0.3333333333333333 / z), y, x);
}
function code(x, y, z, t) return fma(Float64(-0.3333333333333333 / z), y, x) end
code[x_, y_, z_, t_] := N[(N[(-0.3333333333333333 / z), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y, x\right)
\end{array}
Initial program 95.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-/.f6496.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6496.1
Applied rewrites96.1%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
Applied rewrites69.8%
(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 95.6%
Taylor expanded in t around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
(FPCore (x y z t) :precision binary64 (/ y (* -3.0 z)))
double code(double x, double y, double z, double t) {
return y / (-3.0 * 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 / ((-3.0d0) * z)
end function
public static double code(double x, double y, double z, double t) {
return y / (-3.0 * z);
}
def code(x, y, z, t): return y / (-3.0 * z)
function code(x, y, z, t) return Float64(y / Float64(-3.0 * z)) end
function tmp = code(x, y, z, t) tmp = y / (-3.0 * z); end
code[x_, y_, z_, t_] := N[(y / N[(-3.0 * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{-3 \cdot z}
\end{array}
Initial program 95.6%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6438.4
Applied rewrites38.4%
Applied rewrites38.4%
(FPCore (x y z t) :precision binary64 (* (/ y z) -0.3333333333333333))
double code(double x, double y, double z, double t) {
return (y / z) * -0.3333333333333333;
}
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) * (-0.3333333333333333d0)
end function
public static double code(double x, double y, double z, double t) {
return (y / z) * -0.3333333333333333;
}
def code(x, y, z, t): return (y / z) * -0.3333333333333333
function code(x, y, z, t) return Float64(Float64(y / z) * -0.3333333333333333) end
function tmp = code(x, y, z, t) tmp = (y / z) * -0.3333333333333333; end
code[x_, y_, z_, t_] := N[(N[(y / z), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{z} \cdot -0.3333333333333333
\end{array}
Initial program 95.6%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6438.4
Applied rewrites38.4%
Final simplification38.4%
(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 2024277
(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))))