
(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 (<= t -1e+34) (fma (/ t (* y z)) 0.3333333333333333 (fma (/ y z) -0.3333333333333333 x)) (+ x (/ (- (/ t y) y) (* z 3.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1e+34) {
tmp = fma((t / (y * z)), 0.3333333333333333, fma((y / z), -0.3333333333333333, x));
} else {
tmp = x + (((t / y) - y) / (z * 3.0));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -1e+34) tmp = fma(Float64(t / Float64(y * z)), 0.3333333333333333, fma(Float64(y / z), -0.3333333333333333, x)); else tmp = Float64(x + Float64(Float64(Float64(t / y) - y) / Float64(z * 3.0))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -1e+34], N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333 + N[(N[(y / z), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{y \cdot z}, 0.3333333333333333, \mathsf{fma}\left(\frac{y}{z}, -0.3333333333333333, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\
\end{array}
\end{array}
if t < -9.99999999999999946e33Initial program 99.8%
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
lift-*.f64N/A
associate-/r*N/A
div-invN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.8%
if -9.99999999999999946e33 < t 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-/.f6498.9
Applied rewrites98.9%
Final simplification99.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma y (/ -0.3333333333333333 z) x)))
(if (<= y -12200000000.0)
t_1
(if (<= y 5.5e+48) (- x (/ (/ (* t -0.3333333333333333) y) z)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (-0.3333333333333333 / z), x);
double tmp;
if (y <= -12200000000.0) {
tmp = t_1;
} else if (y <= 5.5e+48) {
tmp = x - (((t * -0.3333333333333333) / y) / z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(-0.3333333333333333 / z), x) tmp = 0.0 if (y <= -12200000000.0) tmp = t_1; elseif (y <= 5.5e+48) tmp = Float64(x - Float64(Float64(Float64(t * -0.3333333333333333) / y) / z)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -12200000000.0], t$95$1, If[LessEqual[y, 5.5e+48], N[(x - N[(N[(N[(t * -0.3333333333333333), $MachinePrecision] / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{if}\;y \leq -12200000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+48}:\\
\;\;\;\;x - \frac{\frac{t \cdot -0.3333333333333333}{y}}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.22e10 or 5.5000000000000002e48 < y Initial program 98.0%
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.2%
if -1.22e10 < y < 5.5000000000000002e48Initial program 93.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-/.f6495.1
Applied rewrites95.1%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
div-invN/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
metadata-evalN/A
associate-*l/N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
times-fracN/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6495.2
Applied rewrites95.2%
Taylor expanded in y around 0
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
lower-*.f6490.1
Applied rewrites90.1%
Final simplification93.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma y (/ -0.3333333333333333 z) x)))
(if (<= y -12200000000.0)
t_1
(if (<= y 5.5e+48) (fma 0.3333333333333333 (/ t (* y z)) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (-0.3333333333333333 / z), x);
double tmp;
if (y <= -12200000000.0) {
tmp = t_1;
} else if (y <= 5.5e+48) {
tmp = fma(0.3333333333333333, (t / (y * z)), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(-0.3333333333333333 / z), x) tmp = 0.0 if (y <= -12200000000.0) tmp = t_1; elseif (y <= 5.5e+48) tmp = fma(0.3333333333333333, Float64(t / Float64(y * z)), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -12200000000.0], t$95$1, If[LessEqual[y, 5.5e+48], N[(0.3333333333333333 * N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{if}\;y \leq -12200000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, \frac{t}{y \cdot z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.22e10 or 5.5000000000000002e48 < y Initial program 98.0%
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.2%
if -1.22e10 < y < 5.5000000000000002e48Initial program 93.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-/.f6495.1
Applied rewrites95.1%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
div-invN/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
metadata-evalN/A
associate-*l/N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
times-fracN/A
associate-/r*N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6495.2
Applied rewrites95.2%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
associate-/l*N/A
associate-/l/N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f6487.4
Applied rewrites87.4%
Taylor expanded in y around 0
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
associate-*r/N/A
associate-/l/N/A
associate-*r/N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6488.2
Applied rewrites88.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma y (/ -0.3333333333333333 z) x)))
(if (<= y -12200000000.0)
t_1
(if (<= y 5.5e+48) (fma t (/ 0.3333333333333333 (* y z)) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (-0.3333333333333333 / z), x);
double tmp;
if (y <= -12200000000.0) {
tmp = t_1;
} else if (y <= 5.5e+48) {
tmp = fma(t, (0.3333333333333333 / (y * z)), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(-0.3333333333333333 / z), x) tmp = 0.0 if (y <= -12200000000.0) tmp = t_1; elseif (y <= 5.5e+48) tmp = fma(t, Float64(0.3333333333333333 / Float64(y * z)), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -12200000000.0], t$95$1, If[LessEqual[y, 5.5e+48], N[(t * N[(0.3333333333333333 / N[(y * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{if}\;y \leq -12200000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{0.3333333333333333}{y \cdot z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.22e10 or 5.5000000000000002e48 < y Initial program 98.0%
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.2%
if -1.22e10 < y < 5.5000000000000002e48Initial program 93.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-/.f6495.1
Applied rewrites95.1%
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
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
Applied rewrites87.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma y (/ -0.3333333333333333 z) x))) (if (<= y -5.9e-123) t_1 (if (<= y 3.6e-54) (/ t (* y (* z 3.0))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (-0.3333333333333333 / z), x);
double tmp;
if (y <= -5.9e-123) {
tmp = t_1;
} else if (y <= 3.6e-54) {
tmp = t / (y * (z * 3.0));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(-0.3333333333333333 / z), x) tmp = 0.0 if (y <= -5.9e-123) tmp = t_1; elseif (y <= 3.6e-54) tmp = Float64(t / Float64(y * Float64(z * 3.0))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -5.9e-123], t$95$1, If[LessEqual[y, 3.6e-54], N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{if}\;y \leq -5.9 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-54}:\\
\;\;\;\;\frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.89999999999999988e-123 or 3.59999999999999976e-54 < y Initial program 97.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 rewrites88.4%
if -5.89999999999999988e-123 < y < 3.59999999999999976e-54Initial program 91.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-/.f6493.2
Applied rewrites93.2%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6467.2
Applied rewrites67.2%
Applied rewrites67.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma y (/ -0.3333333333333333 z) x)))
(if (<= y -5.9e-123)
t_1
(if (<= y 3.6e-54) (* (/ t (* y z)) 0.3333333333333333) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (-0.3333333333333333 / z), x);
double tmp;
if (y <= -5.9e-123) {
tmp = t_1;
} else if (y <= 3.6e-54) {
tmp = (t / (y * z)) * 0.3333333333333333;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(-0.3333333333333333 / z), x) tmp = 0.0 if (y <= -5.9e-123) tmp = t_1; elseif (y <= 3.6e-54) tmp = Float64(Float64(t / Float64(y * z)) * 0.3333333333333333); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -5.9e-123], t$95$1, If[LessEqual[y, 3.6e-54], N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{if}\;y \leq -5.9 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-54}:\\
\;\;\;\;\frac{t}{y \cdot z} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.89999999999999988e-123 or 3.59999999999999976e-54 < y Initial program 97.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 rewrites88.4%
if -5.89999999999999988e-123 < y < 3.59999999999999976e-54Initial program 91.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-/.f6493.2
Applied rewrites93.2%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6467.2
Applied rewrites67.2%
Applied rewrites67.3%
Final simplification80.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma y (/ -0.3333333333333333 z) x)))
(if (<= y -5.9e-123)
t_1
(if (<= y 3.6e-54) (/ (* t 0.3333333333333333) (* y z)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, (-0.3333333333333333 / z), x);
double tmp;
if (y <= -5.9e-123) {
tmp = t_1;
} else if (y <= 3.6e-54) {
tmp = (t * 0.3333333333333333) / (y * z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, Float64(-0.3333333333333333 / z), x) tmp = 0.0 if (y <= -5.9e-123) tmp = t_1; elseif (y <= 3.6e-54) tmp = Float64(Float64(t * 0.3333333333333333) / Float64(y * z)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(-0.3333333333333333 / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -5.9e-123], t$95$1, If[LessEqual[y, 3.6e-54], N[(N[(t * 0.3333333333333333), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{-0.3333333333333333}{z}, x\right)\\
\mathbf{if}\;y \leq -5.9 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-54}:\\
\;\;\;\;\frac{t \cdot 0.3333333333333333}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.89999999999999988e-123 or 3.59999999999999976e-54 < y Initial program 97.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 rewrites88.4%
if -5.89999999999999988e-123 < y < 3.59999999999999976e-54Initial program 91.4%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6467.2
Applied rewrites67.2%
Final simplification80.0%
(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 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-/.f6497.2
Applied rewrites97.2%
Final simplification97.2%
(FPCore (x y z t) :precision binary64 (fma (/ (- (/ t y) y) z) 0.3333333333333333 x))
double code(double x, double y, double z, double t) {
return fma((((t / y) - y) / z), 0.3333333333333333, x);
}
function code(x, y, z, t) return fma(Float64(Float64(Float64(t / y) - y) / z), 0.3333333333333333, x) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / z), $MachinePrecision] * 0.3333333333333333 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\frac{t}{y} - y}{z}, 0.3333333333333333, x\right)
\end{array}
Initial 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-/.f6497.2
Applied rewrites97.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
Applied rewrites97.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 95.3%
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.1
Applied rewrites97.1%
(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 95.3%
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 rewrites63.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 95.3%
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-/.f6435.9
Applied rewrites35.9%
Applied rewrites36.0%
(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 95.3%
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-/.f6435.9
Applied rewrites35.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 2024233
(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))))