
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
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 - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
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 - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (fma (/ y t) (- z x) x))
double code(double x, double y, double z, double t) {
return fma((y / t), (z - x), x);
}
function code(x, y, z, t) return fma(Float64(y / t), Float64(z - x), x) end
code[x_, y_, z_, t_] := N[(N[(y / t), $MachinePrecision] * N[(z - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)
\end{array}
Initial program 93.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (/ (* (- z x) y) t) x)) (t_2 (* (/ (- z x) t) y))) (if (<= t_1 -1e+281) t_2 (if (<= t_1 2e+305) (+ (/ (* z y) t) x) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (((z - x) * y) / t) + x;
double t_2 = ((z - x) / t) * y;
double tmp;
if (t_1 <= -1e+281) {
tmp = t_2;
} else if (t_1 <= 2e+305) {
tmp = ((z * y) / t) + x;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (((z - x) * y) / t) + x
t_2 = ((z - x) / t) * y
if (t_1 <= (-1d+281)) then
tmp = t_2
else if (t_1 <= 2d+305) then
tmp = ((z * y) / t) + x
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (((z - x) * y) / t) + x;
double t_2 = ((z - x) / t) * y;
double tmp;
if (t_1 <= -1e+281) {
tmp = t_2;
} else if (t_1 <= 2e+305) {
tmp = ((z * y) / t) + x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (((z - x) * y) / t) + x t_2 = ((z - x) / t) * y tmp = 0 if t_1 <= -1e+281: tmp = t_2 elif t_1 <= 2e+305: tmp = ((z * y) / t) + x else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(Float64(z - x) * y) / t) + x) t_2 = Float64(Float64(Float64(z - x) / t) * y) tmp = 0.0 if (t_1 <= -1e+281) tmp = t_2; elseif (t_1 <= 2e+305) tmp = Float64(Float64(Float64(z * y) / t) + x); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (((z - x) * y) / t) + x; t_2 = ((z - x) / t) * y; tmp = 0.0; if (t_1 <= -1e+281) tmp = t_2; elseif (t_1 <= 2e+305) tmp = ((z * y) / t) + x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+281], t$95$2, If[LessEqual[t$95$1, 2e+305], N[(N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z - x\right) \cdot y}{t} + x\\
t_2 := \frac{z - x}{t} \cdot y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;\frac{z \cdot y}{t} + x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -1e281 or 1.9999999999999999e305 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) Initial program 83.4%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6482.4
Applied rewrites82.4%
Applied rewrites95.6%
if -1e281 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 1.9999999999999999e305Initial program 98.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6484.1
Applied rewrites84.1%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (/ (* (- z x) y) t) x)) (t_2 (* (/ (- z x) t) y))) (if (<= t_1 -1e+281) t_2 (if (<= t_1 2e+305) (fma (/ z t) y x) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (((z - x) * y) / t) + x;
double t_2 = ((z - x) / t) * y;
double tmp;
if (t_1 <= -1e+281) {
tmp = t_2;
} else if (t_1 <= 2e+305) {
tmp = fma((z / t), y, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(Float64(z - x) * y) / t) + x) t_2 = Float64(Float64(Float64(z - x) / t) * y) tmp = 0.0 if (t_1 <= -1e+281) tmp = t_2; elseif (t_1 <= 2e+305) tmp = fma(Float64(z / t), y, x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+281], t$95$2, If[LessEqual[t$95$1, 2e+305], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(z - x\right) \cdot y}{t} + x\\
t_2 := \frac{z - x}{t} \cdot y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -1e281 or 1.9999999999999999e305 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) Initial program 83.4%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6482.4
Applied rewrites82.4%
Applied rewrites95.6%
if -1e281 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 1.9999999999999999e305Initial program 98.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.6
Applied rewrites84.6%
Taylor expanded in z around inf
lower-/.f6474.5
Applied rewrites74.5%
Final simplification81.5%
(FPCore (x y z t) :precision binary64 (if (<= (+ (/ (* (- z x) y) t) x) 2e+282) (/ (* z y) t) (* (/ z t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (((((z - x) * y) / t) + x) <= 2e+282) {
tmp = (z * y) / t;
} else {
tmp = (z / t) * y;
}
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 - x) * y) / t) + x) <= 2d+282) then
tmp = (z * y) / t
else
tmp = (z / t) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((((z - x) * y) / t) + x) <= 2e+282) {
tmp = (z * y) / t;
} else {
tmp = (z / t) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((((z - x) * y) / t) + x) <= 2e+282: tmp = (z * y) / t else: tmp = (z / t) * y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(Float64(Float64(z - x) * y) / t) + x) <= 2e+282) tmp = Float64(Float64(z * y) / t); else tmp = Float64(Float64(z / t) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((((z - x) * y) / t) + x) <= 2e+282) tmp = (z * y) / t; else tmp = (z / t) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision], 2e+282], N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\left(z - x\right) \cdot y}{t} + x \leq 2 \cdot 10^{+282}:\\
\;\;\;\;\frac{z \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{t} \cdot y\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 2.00000000000000007e282Initial program 96.4%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.5
Applied rewrites37.5%
if 2.00000000000000007e282 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) Initial program 80.3%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.4
Applied rewrites41.4%
Applied rewrites53.4%
Final simplification40.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (* z (/ y t)) x))) (if (<= z -2.7e-22) t_1 (if (<= z 2.1e-48) (- x (/ (* x y) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (z * (y / t)) + x;
double tmp;
if (z <= -2.7e-22) {
tmp = t_1;
} else if (z <= 2.1e-48) {
tmp = x - ((x * y) / t);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = (z * (y / t)) + x
if (z <= (-2.7d-22)) then
tmp = t_1
else if (z <= 2.1d-48) then
tmp = x - ((x * y) / t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * (y / t)) + x;
double tmp;
if (z <= -2.7e-22) {
tmp = t_1;
} else if (z <= 2.1e-48) {
tmp = x - ((x * y) / t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * (y / t)) + x tmp = 0 if z <= -2.7e-22: tmp = t_1 elif z <= 2.1e-48: tmp = x - ((x * y) / t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * Float64(y / t)) + x) tmp = 0.0 if (z <= -2.7e-22) tmp = t_1; elseif (z <= 2.1e-48) tmp = Float64(x - Float64(Float64(x * y) / t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * (y / t)) + x; tmp = 0.0; if (z <= -2.7e-22) tmp = t_1; elseif (z <= 2.1e-48) tmp = x - ((x * y) / t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -2.7e-22], t$95$1, If[LessEqual[z, 2.1e-48], N[(x - N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \frac{y}{t} + x\\
\mathbf{if}\;z \leq -2.7 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-48}:\\
\;\;\;\;x - \frac{x \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.7000000000000002e-22 or 2.09999999999999989e-48 < z Initial program 89.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
Taylor expanded in z around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6487.3
Applied rewrites87.3%
if -2.7000000000000002e-22 < z < 2.09999999999999989e-48Initial program 97.7%
Taylor expanded in z around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6487.7
Applied rewrites87.7%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ z t) y x))) (if (<= t -6e-55) t_1 (if (<= t 3.5e-40) (/ (* (- z x) y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z / t), y, x);
double tmp;
if (t <= -6e-55) {
tmp = t_1;
} else if (t <= 3.5e-40) {
tmp = ((z - x) * y) / t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(z / t), y, x) tmp = 0.0 if (t <= -6e-55) tmp = t_1; elseif (t <= 3.5e-40) tmp = Float64(Float64(Float64(z - x) * y) / t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -6e-55], t$95$1, If[LessEqual[t, 3.5e-40], N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -6 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.5 \cdot 10^{-40}:\\
\;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -6.00000000000000033e-55 or 3.5000000000000002e-40 < t Initial program 90.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
Taylor expanded in z around inf
lower-/.f6484.9
Applied rewrites84.9%
if -6.00000000000000033e-55 < t < 3.5000000000000002e-40Initial program 97.5%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6486.0
Applied rewrites86.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ z t) y x))) (if (<= z -2.7e-22) t_1 (if (<= z 2.1e-48) (- x (/ (* x y) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z / t), y, x);
double tmp;
if (z <= -2.7e-22) {
tmp = t_1;
} else if (z <= 2.1e-48) {
tmp = x - ((x * y) / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(z / t), y, x) tmp = 0.0 if (z <= -2.7e-22) tmp = t_1; elseif (z <= 2.1e-48) tmp = Float64(x - Float64(Float64(x * y) / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -2.7e-22], t$95$1, If[LessEqual[z, 2.1e-48], N[(x - N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{if}\;z \leq -2.7 \cdot 10^{-22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-48}:\\
\;\;\;\;x - \frac{x \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.7000000000000002e-22 or 2.09999999999999989e-48 < z Initial program 89.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
Taylor expanded in z around inf
lower-/.f6478.2
Applied rewrites78.2%
if -2.7000000000000002e-22 < z < 2.09999999999999989e-48Initial program 97.7%
Taylor expanded in z around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6487.7
Applied rewrites87.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ z t) y x))) (if (<= t -2.7e-55) t_1 (if (<= t 3.5e-290) (/ (* (- x) y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z / t), y, x);
double tmp;
if (t <= -2.7e-55) {
tmp = t_1;
} else if (t <= 3.5e-290) {
tmp = (-x * y) / t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(z / t), y, x) tmp = 0.0 if (t <= -2.7e-55) tmp = t_1; elseif (t <= 3.5e-290) tmp = Float64(Float64(Float64(-x) * y) / t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -2.7e-55], t$95$1, If[LessEqual[t, 3.5e-290], N[(N[((-x) * y), $MachinePrecision] / t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -2.7 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.5 \cdot 10^{-290}:\\
\;\;\;\;\frac{\left(-x\right) \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.70000000000000004e-55 or 3.49999999999999981e-290 < t Initial program 92.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6493.0
Applied rewrites93.0%
Taylor expanded in z around inf
lower-/.f6478.7
Applied rewrites78.7%
if -2.70000000000000004e-55 < t < 3.49999999999999981e-290Initial program 97.1%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.2
Applied rewrites88.2%
Taylor expanded in z around 0
Applied rewrites63.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ z t) y x))) (if (<= t -2.7e-55) t_1 (if (<= t 3.5e-290) (* (- x) (/ y t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z / t), y, x);
double tmp;
if (t <= -2.7e-55) {
tmp = t_1;
} else if (t <= 3.5e-290) {
tmp = -x * (y / t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(z / t), y, x) tmp = 0.0 if (t <= -2.7e-55) tmp = t_1; elseif (t <= 3.5e-290) tmp = Float64(Float64(-x) * Float64(y / t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -2.7e-55], t$95$1, If[LessEqual[t, 3.5e-290], N[((-x) * N[(y / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -2.7 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.5 \cdot 10^{-290}:\\
\;\;\;\;\left(-x\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.70000000000000004e-55 or 3.49999999999999981e-290 < t Initial program 92.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6493.0
Applied rewrites93.0%
Taylor expanded in z around inf
lower-/.f6478.7
Applied rewrites78.7%
if -2.70000000000000004e-55 < t < 3.49999999999999981e-290Initial program 97.1%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.2
Applied rewrites88.2%
Taylor expanded in z around 0
Applied rewrites63.1%
Applied rewrites61.8%
Final simplification75.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (/ z t) y x))) (if (<= t -2.7e-55) t_1 (if (<= t 3.5e-290) (* (/ (- x) t) y) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z / t), y, x);
double tmp;
if (t <= -2.7e-55) {
tmp = t_1;
} else if (t <= 3.5e-290) {
tmp = (-x / t) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(z / t), y, x) tmp = 0.0 if (t <= -2.7e-55) tmp = t_1; elseif (t <= 3.5e-290) tmp = Float64(Float64(Float64(-x) / t) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -2.7e-55], t$95$1, If[LessEqual[t, 3.5e-290], N[(N[((-x) / t), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -2.7 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.5 \cdot 10^{-290}:\\
\;\;\;\;\frac{-x}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.70000000000000004e-55 or 3.49999999999999981e-290 < t Initial program 92.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6493.0
Applied rewrites93.0%
Taylor expanded in z around inf
lower-/.f6478.7
Applied rewrites78.7%
if -2.70000000000000004e-55 < t < 3.49999999999999981e-290Initial program 97.1%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.2
Applied rewrites88.2%
Taylor expanded in z around 0
Applied rewrites56.9%
(FPCore (x y z t) :precision binary64 (fma (/ z t) y x))
double code(double x, double y, double z, double t) {
return fma((z / t), y, x);
}
function code(x, y, z, t) return fma(Float64(z / t), y, x) end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z}{t}, y, x\right)
\end{array}
Initial program 93.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.3
Applied rewrites89.3%
Taylor expanded in z around inf
lower-/.f6468.6
Applied rewrites68.6%
(FPCore (x y z t) :precision binary64 (* z (/ y t)))
double code(double x, double y, double z, double t) {
return z * (y / t);
}
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 = z * (y / t)
end function
public static double code(double x, double y, double z, double t) {
return z * (y / t);
}
def code(x, y, z, t): return z * (y / t)
function code(x, y, z, t) return Float64(z * Float64(y / t)) end
function tmp = code(x, y, z, t) tmp = z * (y / t); end
code[x_, y_, z_, t_] := N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \frac{y}{t}
\end{array}
Initial program 93.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.3
Applied rewrites89.3%
Taylor expanded in z around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6440.8
Applied rewrites40.8%
Final simplification40.8%
(FPCore (x y z t) :precision binary64 (* (/ z t) y))
double code(double x, double y, double z, double t) {
return (z / t) * 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 = (z / t) * y
end function
public static double code(double x, double y, double z, double t) {
return (z / t) * y;
}
def code(x, y, z, t): return (z / t) * y
function code(x, y, z, t) return Float64(Float64(z / t) * y) end
function tmp = code(x, y, z, t) tmp = (z / t) * y; end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{t} \cdot y
\end{array}
Initial program 93.4%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.2
Applied rewrites38.2%
Applied rewrites34.7%
(FPCore (x y z t) :precision binary64 (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
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 - ((x * (y / t)) + (-z * (y / t)))
end function
public static double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
def code(x, y, z, t): return x - ((x * (y / t)) + (-z * (y / t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(x * Float64(y / t)) + Float64(Float64(-z) * Float64(y / t)))) end
function tmp = code(x, y, z, t) tmp = x - ((x * (y / t)) + (-z * (y / t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[((-z) * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)
\end{array}
herbie shell --seed 2024255
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:alt
(! :herbie-platform default (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
(+ x (/ (* y (- z x)) t)))