
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Initial program 100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -35000000.0)
t_1
(if (<= y 2.4e-238)
(fma z (- t) x)
(if (<= y 6.4e+80) (fma x z x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -35000000.0) {
tmp = t_1;
} else if (y <= 2.4e-238) {
tmp = fma(z, -t, x);
} else if (y <= 6.4e+80) {
tmp = fma(x, z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -35000000.0) tmp = t_1; elseif (y <= 2.4e-238) tmp = fma(z, Float64(-t), x); elseif (y <= 6.4e+80) tmp = fma(x, z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -35000000.0], t$95$1, If[LessEqual[y, 2.4e-238], N[(z * (-t) + x), $MachinePrecision], If[LessEqual[y, 6.4e+80], N[(x * z + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -35000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-238}:\\
\;\;\;\;\mathsf{fma}\left(z, -t, x\right)\\
\mathbf{elif}\;y \leq 6.4 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.5e7 or 6.39999999999999979e80 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6481.6
Applied rewrites81.6%
if -3.5e7 < y < 2.3999999999999998e-238Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6496.0
Applied rewrites96.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f6492.4
Applied rewrites92.4%
Taylor expanded in x around 0
Applied rewrites74.4%
if 2.3999999999999998e-238 < y < 6.39999999999999979e80Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f6484.4
Applied rewrites84.4%
Taylor expanded in x around inf
Applied rewrites66.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))))
(if (<= z -3.3e+68)
t_1
(if (<= z -1.6e-209)
(* y (- t x))
(if (<= z 0.059) (fma y (- x) x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -3.3e+68) {
tmp = t_1;
} else if (z <= -1.6e-209) {
tmp = y * (t - x);
} else if (z <= 0.059) {
tmp = fma(y, -x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -3.3e+68) tmp = t_1; elseif (z <= -1.6e-209) tmp = Float64(y * Float64(t - x)); elseif (z <= 0.059) tmp = fma(y, Float64(-x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.3e+68], t$95$1, If[LessEqual[z, -1.6e-209], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.059], N[(y * (-x) + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{-209}:\\
\;\;\;\;y \cdot \left(t - x\right)\\
\mathbf{elif}\;z \leq 0.059:\\
\;\;\;\;\mathsf{fma}\left(y, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.3e68 or 0.058999999999999997 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6480.7
Applied rewrites80.7%
if -3.3e68 < z < -1.6000000000000001e-209Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6461.9
Applied rewrites61.9%
if -1.6000000000000001e-209 < z < 0.058999999999999997Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6493.8
Applied rewrites93.8%
Taylor expanded in t around 0
Applied rewrites71.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -4.1e+46)
t_1
(if (<= y -3.05e-34) (* (- y z) t) (if (<= y 6.4e+80) (fma x z x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -4.1e+46) {
tmp = t_1;
} else if (y <= -3.05e-34) {
tmp = (y - z) * t;
} else if (y <= 6.4e+80) {
tmp = fma(x, z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -4.1e+46) tmp = t_1; elseif (y <= -3.05e-34) tmp = Float64(Float64(y - z) * t); elseif (y <= 6.4e+80) tmp = fma(x, z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.1e+46], t$95$1, If[LessEqual[y, -3.05e-34], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[y, 6.4e+80], N[(x * z + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -4.1 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -3.05 \cdot 10^{-34}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{elif}\;y \leq 6.4 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.1e46 or 6.39999999999999979e80 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6484.0
Applied rewrites84.0%
if -4.1e46 < y < -3.0499999999999999e-34Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6475.8
Applied rewrites75.8%
if -3.0499999999999999e-34 < y < 6.39999999999999979e80Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6497.7
Applied rewrites97.7%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f6488.8
Applied rewrites88.8%
Taylor expanded in x around inf
Applied rewrites63.0%
Final simplification72.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- x))))
(if (<= y -1.6e+118)
t_1
(if (<= y -4.7e+25) (* y t) (if (<= y 8.2e+82) (fma x z x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = y * -x;
double tmp;
if (y <= -1.6e+118) {
tmp = t_1;
} else if (y <= -4.7e+25) {
tmp = y * t;
} else if (y <= 8.2e+82) {
tmp = fma(x, z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(-x)) tmp = 0.0 if (y <= -1.6e+118) tmp = t_1; elseif (y <= -4.7e+25) tmp = Float64(y * t); elseif (y <= 8.2e+82) tmp = fma(x, z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * (-x)), $MachinePrecision]}, If[LessEqual[y, -1.6e+118], t$95$1, If[LessEqual[y, -4.7e+25], N[(y * t), $MachinePrecision], If[LessEqual[y, 8.2e+82], N[(x * z + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -1.6 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -4.7 \cdot 10^{+25}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.60000000000000008e118 or 8.1999999999999999e82 < y Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
mul-1-negN/A
sub-negN/A
lower-*.f64N/A
lower--.f6488.3
Applied rewrites88.3%
Taylor expanded in t around 0
Applied rewrites56.2%
if -1.60000000000000008e118 < y < -4.6999999999999998e25Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6466.2
Applied rewrites66.2%
Taylor expanded in t around inf
Applied rewrites45.6%
if -4.6999999999999998e25 < y < 8.1999999999999999e82Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f6487.7
Applied rewrites87.7%
Taylor expanded in x around inf
Applied rewrites59.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- t))))
(if (<= t -1.8e+106)
t_1
(if (<= t 960000000.0) (fma x z x) (if (<= t 1e+215) t_1 (* y t))))))
double code(double x, double y, double z, double t) {
double t_1 = z * -t;
double tmp;
if (t <= -1.8e+106) {
tmp = t_1;
} else if (t <= 960000000.0) {
tmp = fma(x, z, x);
} else if (t <= 1e+215) {
tmp = t_1;
} else {
tmp = y * t;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(-t)) tmp = 0.0 if (t <= -1.8e+106) tmp = t_1; elseif (t <= 960000000.0) tmp = fma(x, z, x); elseif (t <= 1e+215) tmp = t_1; else tmp = Float64(y * t); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * (-t)), $MachinePrecision]}, If[LessEqual[t, -1.8e+106], t$95$1, If[LessEqual[t, 960000000.0], N[(x * z + x), $MachinePrecision], If[LessEqual[t, 1e+215], t$95$1, N[(y * t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(-t\right)\\
\mathbf{if}\;t \leq -1.8 \cdot 10^{+106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 960000000:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;t \leq 10^{+215}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if t < -1.8e106 or 9.6e8 < t < 9.99999999999999907e214Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6454.9
Applied rewrites54.9%
Taylor expanded in x around 0
Applied rewrites51.8%
if -1.8e106 < t < 9.6e8Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f6462.7
Applied rewrites62.7%
Taylor expanded in x around inf
Applied rewrites56.2%
if 9.99999999999999907e214 < t Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6483.7
Applied rewrites83.7%
Taylor expanded in t around inf
Applied rewrites77.8%
(FPCore (x y z t) :precision binary64 (if (<= z -3.3e+68) (* z (- x t)) (if (<= z 0.0265) (fma y (- t x) x) (fma z (- x t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.3e+68) {
tmp = z * (x - t);
} else if (z <= 0.0265) {
tmp = fma(y, (t - x), x);
} else {
tmp = fma(z, (x - t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -3.3e+68) tmp = Float64(z * Float64(x - t)); elseif (z <= 0.0265) tmp = fma(y, Float64(t - x), x); else tmp = fma(z, Float64(x - t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.3e+68], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.0265], N[(y * N[(t - x), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{+68}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{elif}\;z \leq 0.0265:\\
\;\;\;\;\mathsf{fma}\left(y, t - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\end{array}
\end{array}
if z < -3.3e68Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6482.0
Applied rewrites82.0%
if -3.3e68 < z < 0.0264999999999999993Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6488.8
Applied rewrites88.8%
if 0.0264999999999999993 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6482.0
Applied rewrites82.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (- x t)))) (if (<= z -3.3e+68) t_1 (if (<= z 5.8e+50) (fma y (- t x) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -3.3e+68) {
tmp = t_1;
} else if (z <= 5.8e+50) {
tmp = fma(y, (t - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -3.3e+68) tmp = t_1; elseif (z <= 5.8e+50) tmp = fma(y, Float64(t - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.3e+68], t$95$1, If[LessEqual[z, 5.8e+50], N[(y * N[(t - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(y, t - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.3e68 or 5.8e50 < z Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6484.8
Applied rewrites84.8%
if -3.3e68 < z < 5.8e50Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6485.1
Applied rewrites85.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- y z) t))) (if (<= t -3.6e+82) t_1 (if (<= t 7e-41) (fma x (- z y) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (y - z) * t;
double tmp;
if (t <= -3.6e+82) {
tmp = t_1;
} else if (t <= 7e-41) {
tmp = fma(x, (z - y), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(y - z) * t) tmp = 0.0 if (t <= -3.6e+82) tmp = t_1; elseif (t <= 7e-41) tmp = fma(x, Float64(z - y), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t, -3.6e+82], t$95$1, If[LessEqual[t, 7e-41], N[(x * N[(z - y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y - z\right) \cdot t\\
\mathbf{if}\;t \leq -3.6 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 7 \cdot 10^{-41}:\\
\;\;\;\;\mathsf{fma}\left(x, z - y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.60000000000000014e82 or 6.9999999999999999e-41 < t Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6478.5
Applied rewrites78.5%
if -3.60000000000000014e82 < t < 6.9999999999999999e-41Initial program 100.0%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6483.1
Applied rewrites83.1%
Final simplification81.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- y z) t))) (if (<= t -2.65e+79) t_1 (if (<= t 2.25e-56) (fma x z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (y - z) * t;
double tmp;
if (t <= -2.65e+79) {
tmp = t_1;
} else if (t <= 2.25e-56) {
tmp = fma(x, z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(y - z) * t) tmp = 0.0 if (t <= -2.65e+79) tmp = t_1; elseif (t <= 2.25e-56) tmp = fma(x, z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t, -2.65e+79], t$95$1, If[LessEqual[t, 2.25e-56], N[(x * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y - z\right) \cdot t\\
\mathbf{if}\;t \leq -2.65 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.25 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.64999999999999989e79 or 2.25e-56 < t Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6476.3
Applied rewrites76.3%
if -2.64999999999999989e79 < t < 2.25e-56Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f6466.1
Applied rewrites66.1%
Taylor expanded in x around inf
Applied rewrites60.1%
Final simplification67.7%
(FPCore (x y z t) :precision binary64 (if (<= y -4.7e+25) (* y t) (if (<= y 9.2e+80) (fma x z x) (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.7e+25) {
tmp = y * t;
} else if (y <= 9.2e+80) {
tmp = fma(x, z, x);
} else {
tmp = y * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -4.7e+25) tmp = Float64(y * t); elseif (y <= 9.2e+80) tmp = fma(x, z, x); else tmp = Float64(y * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.7e+25], N[(y * t), $MachinePrecision], If[LessEqual[y, 9.2e+80], N[(x * z + x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+25}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -4.6999999999999998e25 or 9.20000000000000016e80 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6482.7
Applied rewrites82.7%
Taylor expanded in t around inf
Applied rewrites43.2%
if -4.6999999999999998e25 < y < 9.20000000000000016e80Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f6487.7
Applied rewrites87.7%
Taylor expanded in x around inf
Applied rewrites59.8%
(FPCore (x y z t) :precision binary64 (if (<= z -7.4e+19) (* x z) (if (<= z 2.7e+55) (* y t) (* x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.4e+19) {
tmp = x * z;
} else if (z <= 2.7e+55) {
tmp = y * t;
} else {
tmp = x * z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-7.4d+19)) then
tmp = x * z
else if (z <= 2.7d+55) then
tmp = y * t
else
tmp = x * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.4e+19) {
tmp = x * z;
} else if (z <= 2.7e+55) {
tmp = y * t;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.4e+19: tmp = x * z elif z <= 2.7e+55: tmp = y * t else: tmp = x * z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.4e+19) tmp = Float64(x * z); elseif (z <= 2.7e+55) tmp = Float64(y * t); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.4e+19) tmp = x * z; elseif (z <= 2.7e+55) tmp = y * t; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.4e+19], N[(x * z), $MachinePrecision], If[LessEqual[z, 2.7e+55], N[(y * t), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.4 \cdot 10^{+19}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{+55}:\\
\;\;\;\;y \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if z < -7.4e19 or 2.69999999999999977e55 < z Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6481.6
Applied rewrites81.6%
Taylor expanded in x around inf
Applied rewrites49.9%
if -7.4e19 < z < 2.69999999999999977e55Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f6486.6
Applied rewrites86.6%
Taylor expanded in t around inf
Applied rewrites33.4%
(FPCore (x y z t) :precision binary64 (* x z))
double code(double x, double y, double z, double t) {
return x * 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 * z
end function
public static double code(double x, double y, double z, double t) {
return x * z;
}
def code(x, y, z, t): return x * z
function code(x, y, z, t) return Float64(x * z) end
function tmp = code(x, y, z, t) tmp = x * z; end
code[x_, y_, z_, t_] := N[(x * z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot z
\end{array}
Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6443.1
Applied rewrites43.1%
Taylor expanded in x around inf
Applied rewrites23.6%
(FPCore (x y z t) :precision binary64 (+ x (+ (* t (- y z)) (* (- x) (- y z)))))
double code(double x, double y, double z, double t) {
return x + ((t * (y - z)) + (-x * (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 = x + ((t * (y - z)) + (-x * (y - z)))
end function
public static double code(double x, double y, double z, double t) {
return x + ((t * (y - z)) + (-x * (y - z)));
}
def code(x, y, z, t): return x + ((t * (y - z)) + (-x * (y - z)))
function code(x, y, z, t) return Float64(x + Float64(Float64(t * Float64(y - z)) + Float64(Float64(-x) * Float64(y - z)))) end
function tmp = code(x, y, z, t) tmp = x + ((t * (y - z)) + (-x * (y - z))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision] + N[((-x) * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(t \cdot \left(y - z\right) + \left(-x\right) \cdot \left(y - z\right)\right)
\end{array}
herbie shell --seed 2024233
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (+ (* t (- y z)) (* (- x) (- y z)))))
(+ x (* (- y z) (- t x))))