
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / 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 - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / 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 - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (/ (* z (- y x)) t))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+302)))
(* (- y x) (/ z t))
t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + ((z * (y - x)) / t);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+302)) {
tmp = (y - x) * (z / t);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((z * (y - x)) / t);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+302)) {
tmp = (y - x) * (z / t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((z * (y - x)) / t) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 2e+302): tmp = (y - x) * (z / t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(z * Float64(y - x)) / t)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+302)) tmp = Float64(Float64(y - x) * Float64(z / t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((z * (y - x)) / t); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 2e+302))) tmp = (y - x) * (z / t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+302]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{z \cdot \left(y - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+302}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -inf.0 or 2.0000000000000002e302 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) Initial program 80.2%
Taylor expanded in t around 0 80.2%
*-commutative80.2%
associate-*l/99.9%
Applied egg-rr99.9%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 2.0000000000000002e302Initial program 99.2%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (if (<= z -5e+16) (fma (/ (- y x) t) z x) (fma (/ z t) (- y x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5e+16) {
tmp = fma(((y - x) / t), z, x);
} else {
tmp = fma((z / t), (y - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -5e+16) tmp = fma(Float64(Float64(y - x) / t), z, x); else tmp = fma(Float64(z / t), Float64(y - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -5e+16], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\
\end{array}
\end{array}
if z < -5e16Initial program 92.3%
+-commutative92.3%
associate-*l/99.8%
fma-def99.8%
Simplified99.8%
if -5e16 < z Initial program 94.0%
+-commutative94.0%
*-commutative94.0%
associate-*l/98.5%
fma-def98.5%
Simplified98.5%
Final simplification98.8%
(FPCore (x y z t) :precision binary64 (if (<= z -1e+137) (+ x (/ z (* t (/ 1.0 (- y x))))) (fma (/ z t) (- y x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e+137) {
tmp = x + (z / (t * (1.0 / (y - x))));
} else {
tmp = fma((z / t), (y - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -1e+137) tmp = Float64(x + Float64(z / Float64(t * Float64(1.0 / Float64(y - x))))); else tmp = fma(Float64(z / t), Float64(y - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1e+137], N[(x + N[(z / N[(t * N[(1.0 / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+137}:\\
\;\;\;\;x + \frac{z}{t \cdot \frac{1}{y - x}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\
\end{array}
\end{array}
if z < -1e137Initial program 91.7%
flip--78.2%
associate-*l/67.4%
Applied egg-rr67.4%
*-commutative67.4%
associate-/l*78.2%
difference-of-squares82.7%
associate-/r*91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-un-lft-identity91.7%
associate-/l/99.6%
*-inverses99.6%
Applied egg-rr99.6%
if -1e137 < z Initial program 94.0%
+-commutative94.0%
*-commutative94.0%
associate-*l/98.6%
fma-def98.6%
Simplified98.6%
Final simplification98.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* y (/ z t)))))
(if (<= y -5.8e+77)
t_1
(if (<= y -2.4e-16)
(* (- y x) (/ z t))
(if (<= y 3e-41) (* x (- 1.0 (/ z t))) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = x + (y * (z / t));
double tmp;
if (y <= -5.8e+77) {
tmp = t_1;
} else if (y <= -2.4e-16) {
tmp = (y - x) * (z / t);
} else if (y <= 3e-41) {
tmp = x * (1.0 - (z / 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 = x + (y * (z / t))
if (y <= (-5.8d+77)) then
tmp = t_1
else if (y <= (-2.4d-16)) then
tmp = (y - x) * (z / t)
else if (y <= 3d-41) then
tmp = x * (1.0d0 - (z / 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 = x + (y * (z / t));
double tmp;
if (y <= -5.8e+77) {
tmp = t_1;
} else if (y <= -2.4e-16) {
tmp = (y - x) * (z / t);
} else if (y <= 3e-41) {
tmp = x * (1.0 - (z / t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (y * (z / t)) tmp = 0 if y <= -5.8e+77: tmp = t_1 elif y <= -2.4e-16: tmp = (y - x) * (z / t) elif y <= 3e-41: tmp = x * (1.0 - (z / t)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(y * Float64(z / t))) tmp = 0.0 if (y <= -5.8e+77) tmp = t_1; elseif (y <= -2.4e-16) tmp = Float64(Float64(y - x) * Float64(z / t)); elseif (y <= 3e-41) tmp = Float64(x * Float64(1.0 - Float64(z / t))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (y * (z / t)); tmp = 0.0; if (y <= -5.8e+77) tmp = t_1; elseif (y <= -2.4e-16) tmp = (y - x) * (z / t); elseif (y <= 3e-41) tmp = x * (1.0 - (z / t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.8e+77], t$95$1, If[LessEqual[y, -2.4e-16], N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e-41], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + y \cdot \frac{z}{t}\\
\mathbf{if}\;y \leq -5.8 \cdot 10^{+77}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{-16}:\\
\;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-41}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -5.8000000000000003e77 or 2.99999999999999989e-41 < y Initial program 89.7%
Taylor expanded in y around inf 86.0%
associate-*r/67.1%
Simplified94.5%
if -5.8000000000000003e77 < y < -2.40000000000000005e-16Initial program 95.5%
Taylor expanded in t around 0 91.4%
*-commutative91.4%
associate-*l/95.7%
Applied egg-rr95.7%
if -2.40000000000000005e-16 < y < 2.99999999999999989e-41Initial program 96.8%
Taylor expanded in x around inf 85.4%
*-commutative85.4%
distribute-lft-in85.4%
*-rgt-identity85.4%
mul-1-neg85.4%
distribute-rgt-neg-in85.4%
unsub-neg85.4%
Simplified85.4%
Taylor expanded in x around 0 85.4%
Final simplification90.2%
(FPCore (x y z t)
:precision binary64
(if (<= y -5.8e+77)
(+ x (/ y (/ t z)))
(if (<= y -3.5e-16)
(* (- y x) (/ z t))
(if (<= y 2.8e-40) (* x (- 1.0 (/ z t))) (+ x (* y (/ z t)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.8e+77) {
tmp = x + (y / (t / z));
} else if (y <= -3.5e-16) {
tmp = (y - x) * (z / t);
} else if (y <= 2.8e-40) {
tmp = x * (1.0 - (z / t));
} else {
tmp = x + (y * (z / t));
}
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 (y <= (-5.8d+77)) then
tmp = x + (y / (t / z))
else if (y <= (-3.5d-16)) then
tmp = (y - x) * (z / t)
else if (y <= 2.8d-40) then
tmp = x * (1.0d0 - (z / t))
else
tmp = x + (y * (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.8e+77) {
tmp = x + (y / (t / z));
} else if (y <= -3.5e-16) {
tmp = (y - x) * (z / t);
} else if (y <= 2.8e-40) {
tmp = x * (1.0 - (z / t));
} else {
tmp = x + (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5.8e+77: tmp = x + (y / (t / z)) elif y <= -3.5e-16: tmp = (y - x) * (z / t) elif y <= 2.8e-40: tmp = x * (1.0 - (z / t)) else: tmp = x + (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5.8e+77) tmp = Float64(x + Float64(y / Float64(t / z))); elseif (y <= -3.5e-16) tmp = Float64(Float64(y - x) * Float64(z / t)); elseif (y <= 2.8e-40) tmp = Float64(x * Float64(1.0 - Float64(z / t))); else tmp = Float64(x + Float64(y * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -5.8e+77) tmp = x + (y / (t / z)); elseif (y <= -3.5e-16) tmp = (y - x) * (z / t); elseif (y <= 2.8e-40) tmp = x * (1.0 - (z / t)); else tmp = x + (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.8e+77], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -3.5e-16], N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-40], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+77}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\mathbf{elif}\;y \leq -3.5 \cdot 10^{-16}:\\
\;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-40}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if y < -5.8000000000000003e77Initial program 84.2%
flip--51.9%
associate-*l/45.2%
Applied egg-rr45.2%
*-commutative45.2%
associate-/l*51.8%
difference-of-squares56.8%
associate-/r*84.2%
+-commutative84.2%
+-commutative84.2%
Simplified84.2%
Taylor expanded in x around 0 84.2%
associate-/l*95.6%
Simplified95.6%
if -5.8000000000000003e77 < y < -3.50000000000000017e-16Initial program 95.5%
Taylor expanded in t around 0 91.4%
*-commutative91.4%
associate-*l/95.7%
Applied egg-rr95.7%
if -3.50000000000000017e-16 < y < 2.8e-40Initial program 96.8%
Taylor expanded in x around inf 85.4%
*-commutative85.4%
distribute-lft-in85.4%
*-rgt-identity85.4%
mul-1-neg85.4%
distribute-rgt-neg-in85.4%
unsub-neg85.4%
Simplified85.4%
Taylor expanded in x around 0 85.4%
if 2.8e-40 < y Initial program 93.0%
Taylor expanded in y around inf 87.1%
associate-*r/67.8%
Simplified93.9%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (if (<= z -9e+132) (+ x (/ z (* t (/ 1.0 (- y x))))) (+ x (/ (- y x) (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+132) {
tmp = x + (z / (t * (1.0 / (y - x))));
} else {
tmp = x + ((y - x) / (t / 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 <= (-9d+132)) then
tmp = x + (z / (t * (1.0d0 / (y - x))))
else
tmp = x + ((y - x) / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+132) {
tmp = x + (z / (t * (1.0 / (y - x))));
} else {
tmp = x + ((y - x) / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9e+132: tmp = x + (z / (t * (1.0 / (y - x)))) else: tmp = x + ((y - x) / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9e+132) tmp = Float64(x + Float64(z / Float64(t * Float64(1.0 / Float64(y - x))))); else tmp = Float64(x + Float64(Float64(y - x) / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -9e+132) tmp = x + (z / (t * (1.0 / (y - x)))); else tmp = x + ((y - x) / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9e+132], N[(x + N[(z / N[(t * N[(1.0 / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+132}:\\
\;\;\;\;x + \frac{z}{t \cdot \frac{1}{y - x}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -8.99999999999999944e132Initial program 91.7%
flip--78.2%
associate-*l/67.4%
Applied egg-rr67.4%
*-commutative67.4%
associate-/l*78.2%
difference-of-squares82.7%
associate-/r*91.7%
+-commutative91.7%
+-commutative91.7%
Simplified91.7%
*-un-lft-identity91.7%
associate-/l/99.6%
*-inverses99.6%
Applied egg-rr99.6%
if -8.99999999999999944e132 < z Initial program 94.0%
associate-/l*98.5%
Simplified98.5%
Final simplification98.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.9e-16) (not (<= y 2.7e-18))) (* y (/ z t)) (* x (- 1.0 (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.9e-16) || !(y <= 2.7e-18)) {
tmp = y * (z / t);
} else {
tmp = x * (1.0 - (z / t));
}
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 ((y <= (-3.9d-16)) .or. (.not. (y <= 2.7d-18))) then
tmp = y * (z / t)
else
tmp = x * (1.0d0 - (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.9e-16) || !(y <= 2.7e-18)) {
tmp = y * (z / t);
} else {
tmp = x * (1.0 - (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.9e-16) or not (y <= 2.7e-18): tmp = y * (z / t) else: tmp = x * (1.0 - (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.9e-16) || !(y <= 2.7e-18)) tmp = Float64(y * Float64(z / t)); else tmp = Float64(x * Float64(1.0 - Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -3.9e-16) || ~((y <= 2.7e-18))) tmp = y * (z / t); else tmp = x * (1.0 - (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.9e-16], N[Not[LessEqual[y, 2.7e-18]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{-16} \lor \neg \left(y \leq 2.7 \cdot 10^{-18}\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\end{array}
\end{array}
if y < -3.89999999999999977e-16 or 2.69999999999999989e-18 < y Initial program 90.2%
Taylor expanded in t around 0 68.9%
Taylor expanded in y around inf 61.9%
associate-*r/68.5%
Simplified68.5%
if -3.89999999999999977e-16 < y < 2.69999999999999989e-18Initial program 97.0%
Taylor expanded in x around inf 85.3%
*-commutative85.3%
distribute-lft-in85.3%
*-rgt-identity85.3%
mul-1-neg85.3%
distribute-rgt-neg-in85.3%
unsub-neg85.3%
Simplified85.3%
Taylor expanded in x around 0 85.3%
Final simplification77.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.96e-16) (not (<= y 2.7e-18))) (* (- y x) (/ z t)) (* x (- 1.0 (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.96e-16) || !(y <= 2.7e-18)) {
tmp = (y - x) * (z / t);
} else {
tmp = x * (1.0 - (z / t));
}
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 ((y <= (-1.96d-16)) .or. (.not. (y <= 2.7d-18))) then
tmp = (y - x) * (z / t)
else
tmp = x * (1.0d0 - (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.96e-16) || !(y <= 2.7e-18)) {
tmp = (y - x) * (z / t);
} else {
tmp = x * (1.0 - (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.96e-16) or not (y <= 2.7e-18): tmp = (y - x) * (z / t) else: tmp = x * (1.0 - (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.96e-16) || !(y <= 2.7e-18)) tmp = Float64(Float64(y - x) * Float64(z / t)); else tmp = Float64(x * Float64(1.0 - Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.96e-16) || ~((y <= 2.7e-18))) tmp = (y - x) * (z / t); else tmp = x * (1.0 - (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.96e-16], N[Not[LessEqual[y, 2.7e-18]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.96 \cdot 10^{-16} \lor \neg \left(y \leq 2.7 \cdot 10^{-18}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\end{array}
\end{array}
if y < -1.96000000000000005e-16 or 2.69999999999999989e-18 < y Initial program 90.2%
Taylor expanded in t around 0 68.9%
*-commutative68.9%
associate-*l/77.8%
Applied egg-rr77.8%
if -1.96000000000000005e-16 < y < 2.69999999999999989e-18Initial program 97.0%
Taylor expanded in x around inf 85.3%
*-commutative85.3%
distribute-lft-in85.3%
*-rgt-identity85.3%
mul-1-neg85.3%
distribute-rgt-neg-in85.3%
unsub-neg85.3%
Simplified85.3%
Taylor expanded in x around 0 85.3%
Final simplification81.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -8.5e-45) (not (<= z 8.8e-66))) (* y (/ z t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.5e-45) || !(z <= 8.8e-66)) {
tmp = y * (z / t);
} else {
tmp = x;
}
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 <= (-8.5d-45)) .or. (.not. (z <= 8.8d-66))) then
tmp = y * (z / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.5e-45) || !(z <= 8.8e-66)) {
tmp = y * (z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -8.5e-45) or not (z <= 8.8e-66): tmp = y * (z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -8.5e-45) || !(z <= 8.8e-66)) tmp = Float64(y * Float64(z / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -8.5e-45) || ~((z <= 8.8e-66))) tmp = y * (z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -8.5e-45], N[Not[LessEqual[z, 8.8e-66]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-45} \lor \neg \left(z \leq 8.8 \cdot 10^{-66}\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.50000000000000041e-45 or 8.8000000000000004e-66 < z Initial program 90.3%
Taylor expanded in t around 0 74.6%
Taylor expanded in y around inf 49.1%
associate-*r/55.2%
Simplified55.2%
if -8.50000000000000041e-45 < z < 8.8000000000000004e-66Initial program 98.8%
Taylor expanded in z around 0 70.0%
Final simplification60.9%
(FPCore (x y z t) :precision binary64 (if (<= z -3.1e-45) (* z (/ y t)) (if (<= z 7e-66) x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e-45) {
tmp = z * (y / t);
} else if (z <= 7e-66) {
tmp = x;
} else {
tmp = y * (z / t);
}
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 <= (-3.1d-45)) then
tmp = z * (y / t)
else if (z <= 7d-66) then
tmp = x
else
tmp = y * (z / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e-45) {
tmp = z * (y / t);
} else if (z <= 7e-66) {
tmp = x;
} else {
tmp = y * (z / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.1e-45: tmp = z * (y / t) elif z <= 7e-66: tmp = x else: tmp = y * (z / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.1e-45) tmp = Float64(z * Float64(y / t)); elseif (z <= 7e-66) tmp = x; else tmp = Float64(y * Float64(z / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.1e-45) tmp = z * (y / t); elseif (z <= 7e-66) tmp = x; else tmp = y * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.1e-45], N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7e-66], x, N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-45}:\\
\;\;\;\;z \cdot \frac{y}{t}\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-66}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -3.1000000000000001e-45Initial program 94.1%
Taylor expanded in t around 0 81.0%
Taylor expanded in y around inf 56.8%
associate-*l/59.0%
*-commutative59.0%
Simplified59.0%
if -3.1000000000000001e-45 < z < 7.0000000000000001e-66Initial program 98.8%
Taylor expanded in z around 0 70.0%
if 7.0000000000000001e-66 < z Initial program 86.5%
Taylor expanded in t around 0 68.0%
Taylor expanded in y around inf 41.2%
associate-*r/52.2%
Simplified52.2%
Final simplification61.2%
(FPCore (x y z t) :precision binary64 (+ x (/ (- y x) (/ t z))))
double code(double x, double y, double z, double t) {
return x + ((y - x) / (t / z));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - x) / (t / z))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) / (t / z));
}
def code(x, y, z, t): return x + ((y - x) / (t / z))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) / Float64(t / z))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) / (t / z)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y - x}{\frac{t}{z}}
\end{array}
Initial program 93.6%
associate-/l*97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return 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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.6%
Taylor expanded in z around 0 38.0%
Final simplification38.0%
(FPCore (x y z t)
:precision binary64
(if (< x -9.025511195533005e-135)
(- x (* (/ z t) (- x y)))
(if (< x 4.275032163700715e-250)
(+ x (* (/ (- y x) t) z))
(+ x (/ (- y x) (/ t z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (x < -9.025511195533005e-135) {
tmp = x - ((z / t) * (x - y));
} else if (x < 4.275032163700715e-250) {
tmp = x + (((y - x) / t) * z);
} else {
tmp = x + ((y - x) / (t / 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 (x < (-9.025511195533005d-135)) then
tmp = x - ((z / t) * (x - y))
else if (x < 4.275032163700715d-250) then
tmp = x + (((y - x) / t) * z)
else
tmp = x + ((y - x) / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x < -9.025511195533005e-135) {
tmp = x - ((z / t) * (x - y));
} else if (x < 4.275032163700715e-250) {
tmp = x + (((y - x) / t) * z);
} else {
tmp = x + ((y - x) / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x < -9.025511195533005e-135: tmp = x - ((z / t) * (x - y)) elif x < 4.275032163700715e-250: tmp = x + (((y - x) / t) * z) else: tmp = x + ((y - x) / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (x < -9.025511195533005e-135) tmp = Float64(x - Float64(Float64(z / t) * Float64(x - y))); elseif (x < 4.275032163700715e-250) tmp = Float64(x + Float64(Float64(Float64(y - x) / t) * z)); else tmp = Float64(x + Float64(Float64(y - x) / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x < -9.025511195533005e-135) tmp = x - ((z / t) * (x - y)); elseif (x < 4.275032163700715e-250) tmp = x + (((y - x) / t) * z); else tmp = x + ((y - x) / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Less[x, -9.025511195533005e-135], N[(x - N[(N[(z / t), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[x, 4.275032163700715e-250], N[(x + N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x < -9.025511195533005 \cdot 10^{-135}:\\
\;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\
\mathbf{elif}\;x < 4.275032163700715 \cdot 10^{-250}:\\
\;\;\;\;x + \frac{y - x}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\
\end{array}
\end{array}
herbie shell --seed 2023230
(FPCore (x y z t)
:name "Numeric.Histogram:binBounds from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))
(+ x (/ (* (- y x) z) t)))