
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= (+ x (/ (* y (- z t)) (- z a))) -5e-17) (+ x (/ (- z t) (/ (- z a) y))) (fma (/ (- z t) (- z a)) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x + ((y * (z - t)) / (z - a))) <= -5e-17) {
tmp = x + ((z - t) / ((z - a) / y));
} else {
tmp = fma(((z - t) / (z - a)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) <= -5e-17) tmp = Float64(x + Float64(Float64(z - t) / Float64(Float64(z - a) / y))); else tmp = fma(Float64(Float64(z - t) / Float64(z - a)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-17], N[(x + N[(N[(z - t), $MachinePrecision] / N[(N[(z - a), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{y \cdot \left(z - t\right)}{z - a} \leq -5 \cdot 10^{-17}:\\
\;\;\;\;x + \frac{z - t}{\frac{z - a}{y}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < -4.9999999999999999e-17Initial program 84.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6495.6
Applied rewrites95.6%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -4.9999999999999999e-17 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) Initial program 90.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.4
Applied rewrites98.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ y (- z a)) (- z t))) (t_2 (/ (* y (- z t)) (- z a))))
(if (<= t_2 -2e+96)
t_1
(if (<= t_2 1e-116)
(fma (/ z (- z a)) y x)
(if (<= t_2 5e+62) (+ x (/ (* t y) a)) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y / (z - a)) * (z - t);
double t_2 = (y * (z - t)) / (z - a);
double tmp;
if (t_2 <= -2e+96) {
tmp = t_1;
} else if (t_2 <= 1e-116) {
tmp = fma((z / (z - a)), y, x);
} else if (t_2 <= 5e+62) {
tmp = x + ((t * y) / a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y / Float64(z - a)) * Float64(z - t)) t_2 = Float64(Float64(y * Float64(z - t)) / Float64(z - a)) tmp = 0.0 if (t_2 <= -2e+96) tmp = t_1; elseif (t_2 <= 1e-116) tmp = fma(Float64(z / Float64(z - a)), y, x); elseif (t_2 <= 5e+62) tmp = Float64(x + Float64(Float64(t * y) / a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+96], t$95$1, If[LessEqual[t$95$2, 1e-116], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$2, 5e+62], N[(x + N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{z - a} \cdot \left(z - t\right)\\
t_2 := \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+96}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{-116}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+62}:\\
\;\;\;\;x + \frac{t \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < -2.0000000000000001e96 or 5.00000000000000029e62 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) Initial program 69.7%
Taylor expanded in x around 0
associate-/l*N/A
div-subN/A
distribute-lft-out--N/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6490.6
Applied rewrites90.6%
if -2.0000000000000001e96 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < 9.9999999999999999e-117Initial program 99.9%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6489.4
Applied rewrites89.4%
if 9.9999999999999999e-117 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < 5.00000000000000029e62Initial program 99.9%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
(FPCore (x y z t a)
:precision binary64
(if (<= z -2.4e+143)
(+ y x)
(if (<= z 5.5e-27)
(fma (/ t a) y x)
(if (<= z 3.2e+163) (fma (/ (- t) z) y x) (+ y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.4e+143) {
tmp = y + x;
} else if (z <= 5.5e-27) {
tmp = fma((t / a), y, x);
} else if (z <= 3.2e+163) {
tmp = fma((-t / z), y, x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.4e+143) tmp = Float64(y + x); elseif (z <= 5.5e-27) tmp = fma(Float64(t / a), y, x); elseif (z <= 3.2e+163) tmp = fma(Float64(Float64(-t) / z), y, x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.4e+143], N[(y + x), $MachinePrecision], If[LessEqual[z, 5.5e-27], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 3.2e+163], N[(N[((-t) / z), $MachinePrecision] * y + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+143}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+163}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -2.3999999999999998e143 or 3.1999999999999998e163 < z Initial program 70.3%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6490.3
Applied rewrites90.3%
if -2.3999999999999998e143 < z < 5.5000000000000002e-27Initial program 95.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.5
Applied rewrites95.5%
Taylor expanded in z around 0
lower-/.f6481.7
Applied rewrites81.7%
if 5.5000000000000002e-27 < z < 3.1999999999999998e163Initial program 89.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6478.2
Applied rewrites78.2%
Taylor expanded in z around 0
Applied rewrites76.6%
(FPCore (x y z t a)
:precision binary64
(if (<= z -2.4e+143)
(+ y x)
(if (<= z 9.6e-27)
(fma (/ t a) y x)
(if (<= z 4.5e+71) (- x (/ (* y z) a)) (+ y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.4e+143) {
tmp = y + x;
} else if (z <= 9.6e-27) {
tmp = fma((t / a), y, x);
} else if (z <= 4.5e+71) {
tmp = x - ((y * z) / a);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.4e+143) tmp = Float64(y + x); elseif (z <= 9.6e-27) tmp = fma(Float64(t / a), y, x); elseif (z <= 4.5e+71) tmp = Float64(x - Float64(Float64(y * z) / a)); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.4e+143], N[(y + x), $MachinePrecision], If[LessEqual[z, 9.6e-27], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 4.5e+71], N[(x - N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+143}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+71}:\\
\;\;\;\;x - \frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -2.3999999999999998e143 or 4.50000000000000043e71 < z Initial program 73.0%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6486.9
Applied rewrites86.9%
if -2.3999999999999998e143 < z < 9.60000000000000008e-27Initial program 95.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.5
Applied rewrites95.5%
Taylor expanded in z around 0
lower-/.f6481.7
Applied rewrites81.7%
if 9.60000000000000008e-27 < z < 4.50000000000000043e71Initial program 94.3%
Taylor expanded in a around inf
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6451.2
Applied rewrites51.2%
Taylor expanded in z around inf
Applied rewrites74.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.6e+39) (not (<= z 5.4e-27))) (fma (/ (- z t) z) y x) (fma (/ t a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.6e+39) || !(z <= 5.4e-27)) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = fma((t / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.6e+39) || !(z <= 5.4e-27)) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = fma(Float64(t / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.6e+39], N[Not[LessEqual[z, 5.4e-27]], $MachinePrecision]], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+39} \lor \neg \left(z \leq 5.4 \cdot 10^{-27}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -4.60000000000000024e39 or 5.39999999999999978e-27 < z Initial program 79.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6485.5
Applied rewrites85.5%
if -4.60000000000000024e39 < z < 5.39999999999999978e-27Initial program 96.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.7
Applied rewrites94.7%
Taylor expanded in z around 0
lower-/.f6485.7
Applied rewrites85.7%
Final simplification85.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.05e+96) (not (<= z 1.4e-27))) (fma (/ z (- z a)) y x) (fma (/ t a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.05e+96) || !(z <= 1.4e-27)) {
tmp = fma((z / (z - a)), y, x);
} else {
tmp = fma((t / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.05e+96) || !(z <= 1.4e-27)) tmp = fma(Float64(z / Float64(z - a)), y, x); else tmp = fma(Float64(t / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.05e+96], N[Not[LessEqual[z, 1.4e-27]], $MachinePrecision]], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+96} \lor \neg \left(z \leq 1.4 \cdot 10^{-27}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -2.04999999999999999e96 or 1.4e-27 < z Initial program 79.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6485.4
Applied rewrites85.4%
if -2.04999999999999999e96 < z < 1.4e-27Initial program 94.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.2
Applied rewrites95.2%
Taylor expanded in z around 0
lower-/.f6484.2
Applied rewrites84.2%
Final simplification84.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.05e+96) (not (<= z 1.4e-27))) (fma z (/ y (- z a)) x) (fma (/ t a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.05e+96) || !(z <= 1.4e-27)) {
tmp = fma(z, (y / (z - a)), x);
} else {
tmp = fma((t / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.05e+96) || !(z <= 1.4e-27)) tmp = fma(z, Float64(y / Float64(z - a)), x); else tmp = fma(Float64(t / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.05e+96], N[Not[LessEqual[z, 1.4e-27]], $MachinePrecision]], N[(z * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+96} \lor \neg \left(z \leq 1.4 \cdot 10^{-27}\right):\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{z - a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -2.04999999999999999e96 or 1.4e-27 < z Initial program 79.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6485.4
Applied rewrites85.4%
Applied rewrites82.3%
if -2.04999999999999999e96 < z < 1.4e-27Initial program 94.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.2
Applied rewrites95.2%
Taylor expanded in z around 0
lower-/.f6484.2
Applied rewrites84.2%
Final simplification83.4%
(FPCore (x y z t a) :precision binary64 (+ x (/ y (/ (- z a) (- z t)))))
double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (y / ((z - a) / (z - t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
def code(x, y, z, t, a): return x + (y / ((z - a) / (z - t)))
function code(x, y, z, t, a) return Float64(x + Float64(y / Float64(Float64(z - a) / Float64(z - t)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y / ((z - a) / (z - t))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{z - a}{z - t}}
\end{array}
Initial program 88.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6497.2
Applied rewrites97.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.4e+143) (not (<= z 8.2e-27))) (+ y x) (fma (/ t a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.4e+143) || !(z <= 8.2e-27)) {
tmp = y + x;
} else {
tmp = fma((t / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.4e+143) || !(z <= 8.2e-27)) tmp = Float64(y + x); else tmp = fma(Float64(t / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.4e+143], N[Not[LessEqual[z, 8.2e-27]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+143} \lor \neg \left(z \leq 8.2 \cdot 10^{-27}\right):\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -2.3999999999999998e143 or 8.1999999999999997e-27 < z Initial program 77.0%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6480.2
Applied rewrites80.2%
if -2.3999999999999998e143 < z < 8.1999999999999997e-27Initial program 95.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.5
Applied rewrites95.5%
Taylor expanded in z around 0
lower-/.f6481.7
Applied rewrites81.7%
Final simplification81.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.4e+143) (not (<= z 8.2e-27))) (+ y x) (fma (/ y a) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.4e+143) || !(z <= 8.2e-27)) {
tmp = y + x;
} else {
tmp = fma((y / a), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.4e+143) || !(z <= 8.2e-27)) tmp = Float64(y + x); else tmp = fma(Float64(y / a), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.4e+143], N[Not[LessEqual[z, 8.2e-27]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+143} \lor \neg \left(z \leq 8.2 \cdot 10^{-27}\right):\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\end{array}
\end{array}
if z < -2.3999999999999998e143 or 8.1999999999999997e-27 < z Initial program 77.0%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6480.2
Applied rewrites80.2%
if -2.3999999999999998e143 < z < 8.1999999999999997e-27Initial program 95.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6479.1
Applied rewrites79.1%
Final simplification79.5%
(FPCore (x y z t a) :precision binary64 (fma (/ (- z t) (- z a)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - t) / (z - a)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - t) / Float64(z - a)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)
\end{array}
Initial program 88.6%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
(FPCore (x y z t a) :precision binary64 (fma z (/ y z) x))
double code(double x, double y, double z, double t, double a) {
return fma(z, (y / z), x);
}
function code(x, y, z, t, a) return fma(z, Float64(y / z), x) end
code[x_, y_, z_, t_, a_] := N[(z * N[(y / z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \frac{y}{z}, x\right)
\end{array}
Initial program 88.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6464.7
Applied rewrites64.7%
Applied rewrites63.7%
Taylor expanded in z around inf
Applied rewrites54.7%
(FPCore (x y z t a) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a) {
return y + x;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = y + x
end function
public static double code(double x, double y, double z, double t, double a) {
return y + x;
}
def code(x, y, z, t, a): return y + x
function code(x, y, z, t, a) return Float64(y + x) end
function tmp = code(x, y, z, t, a) tmp = y + x; end
code[x_, y_, z_, t_, a_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 88.6%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6454.5
Applied rewrites54.5%
(FPCore (x y z t a) :precision binary64 (+ x (/ y (/ (- z a) (- z t)))))
double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (y / ((z - a) / (z - t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
def code(x, y, z, t, a): return x + (y / ((z - a) / (z - t)))
function code(x, y, z, t, a) return Float64(x + Float64(y / Float64(Float64(z - a) / Float64(z - t)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y / ((z - a) / (z - t))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{z - a}{z - t}}
\end{array}
herbie shell --seed 2024318
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
:precision binary64
:alt
(! :herbie-platform default (+ x (/ y (/ (- z a) (- z t)))))
(+ x (/ (* y (- z t)) (- z a))))