
(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 11 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 (/ (* (- y x) z) t))))
(if (or (<= t_1 -5e+297) (not (<= t_1 5e+307)))
(+ x (/ z (/ t (- y x))))
t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + (((y - x) * z) / t);
double tmp;
if ((t_1 <= -5e+297) || !(t_1 <= 5e+307)) {
tmp = x + (z / (t / (y - x)));
} 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 - x) * z) / t)
if ((t_1 <= (-5d+297)) .or. (.not. (t_1 <= 5d+307))) then
tmp = x + (z / (t / (y - x)))
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 - x) * z) / t);
double tmp;
if ((t_1 <= -5e+297) || !(t_1 <= 5e+307)) {
tmp = x + (z / (t / (y - x)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (((y - x) * z) / t) tmp = 0 if (t_1 <= -5e+297) or not (t_1 <= 5e+307): tmp = x + (z / (t / (y - x))) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(Float64(y - x) * z) / t)) tmp = 0.0 if ((t_1 <= -5e+297) || !(t_1 <= 5e+307)) tmp = Float64(x + Float64(z / Float64(t / Float64(y - x)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (((y - x) * z) / t); tmp = 0.0; if ((t_1 <= -5e+297) || ~((t_1 <= 5e+307))) tmp = x + (z / (t / (y - x))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+297], N[Not[LessEqual[t$95$1, 5e+307]], $MachinePrecision]], N[(x + N[(z / N[(t / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+297} \lor \neg \left(t_1 \leq 5 \cdot 10^{+307}\right):\\
\;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -4.9999999999999998e297 or 5e307 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) Initial program 76.4%
associate-/l*99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
clear-num99.8%
associate-/r/99.9%
clear-num99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
if -4.9999999999999998e297 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 5e307Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.5e-99) (not (<= y 1.2e-108))) (+ x (* y (/ z t))) (* x (- 1.0 (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.5e-99) || !(y <= 1.2e-108)) {
tmp = x + (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 <= (-1.5d-99)) .or. (.not. (y <= 1.2d-108))) then
tmp = x + (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 <= -1.5e-99) || !(y <= 1.2e-108)) {
tmp = x + (y * (z / t));
} else {
tmp = x * (1.0 - (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.5e-99) or not (y <= 1.2e-108): tmp = x + (y * (z / t)) else: tmp = x * (1.0 - (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.5e-99) || !(y <= 1.2e-108)) tmp = Float64(x + 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 <= -1.5e-99) || ~((y <= 1.2e-108))) tmp = x + (y * (z / t)); else tmp = x * (1.0 - (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.5e-99], N[Not[LessEqual[y, 1.2e-108]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-99} \lor \neg \left(y \leq 1.2 \cdot 10^{-108}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\end{array}
\end{array}
if y < -1.50000000000000003e-99 or 1.20000000000000009e-108 < y Initial program 91.4%
Taylor expanded in y around inf 83.7%
associate-*r/88.7%
Simplified88.7%
if -1.50000000000000003e-99 < y < 1.20000000000000009e-108Initial program 94.7%
Taylor expanded in x around inf 90.4%
mul-1-neg90.4%
unsub-neg90.4%
Simplified90.4%
Final simplification89.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -5.2e-99) (not (<= y 6e-109))) (+ x (* y (/ z t))) (- x (/ x (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.2e-99) || !(y <= 6e-109)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (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 ((y <= (-5.2d-99)) .or. (.not. (y <= 6d-109))) then
tmp = x + (y * (z / t))
else
tmp = x - (x / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.2e-99) || !(y <= 6e-109)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (x / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -5.2e-99) or not (y <= 6e-109): tmp = x + (y * (z / t)) else: tmp = x - (x / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -5.2e-99) || !(y <= 6e-109)) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(x - Float64(x / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -5.2e-99) || ~((y <= 6e-109))) tmp = x + (y * (z / t)); else tmp = x - (x / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -5.2e-99], N[Not[LessEqual[y, 6e-109]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-99} \lor \neg \left(y \leq 6 \cdot 10^{-109}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{t}{z}}\\
\end{array}
\end{array}
if y < -5.2000000000000001e-99 or 6.00000000000000043e-109 < y Initial program 91.4%
Taylor expanded in y around inf 83.7%
associate-*r/88.7%
Simplified88.7%
if -5.2000000000000001e-99 < y < 6.00000000000000043e-109Initial program 94.7%
associate-*l/98.8%
Applied egg-rr98.8%
Taylor expanded in y around 0 92.5%
neg-mul-192.5%
distribute-neg-frac92.5%
Simplified92.5%
add-sqr-sqrt44.0%
sqrt-unprod54.0%
sqr-neg54.0%
sqrt-unprod26.1%
add-sqr-sqrt52.0%
cancel-sign-sub52.0%
distribute-frac-neg52.0%
associate-*l/47.6%
associate-/l*53.0%
add-sqr-sqrt25.9%
sqrt-unprod56.9%
sqr-neg56.9%
sqrt-unprod47.4%
add-sqr-sqrt90.4%
Applied egg-rr90.4%
Final simplification89.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.2e-99) (not (<= y 2.9e-108))) (+ x (* y (/ z t))) (- x (* z (/ x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.2e-99) || !(y <= 2.9e-108)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (z * (x / 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.2d-99)) .or. (.not. (y <= 2.9d-108))) then
tmp = x + (y * (z / t))
else
tmp = x - (z * (x / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.2e-99) || !(y <= 2.9e-108)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (z * (x / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.2e-99) or not (y <= 2.9e-108): tmp = x + (y * (z / t)) else: tmp = x - (z * (x / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.2e-99) || !(y <= 2.9e-108)) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(x - Float64(z * Float64(x / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -3.2e-99) || ~((y <= 2.9e-108))) tmp = x + (y * (z / t)); else tmp = x - (z * (x / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.2e-99], N[Not[LessEqual[y, 2.9e-108]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-99} \lor \neg \left(y \leq 2.9 \cdot 10^{-108}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{x}{t}\\
\end{array}
\end{array}
if y < -3.2000000000000001e-99 or 2.9000000000000001e-108 < y Initial program 91.4%
Taylor expanded in y around inf 83.7%
associate-*r/88.7%
Simplified88.7%
if -3.2000000000000001e-99 < y < 2.9000000000000001e-108Initial program 94.7%
associate-*l/98.8%
Applied egg-rr98.8%
Taylor expanded in y around 0 92.5%
neg-mul-192.5%
distribute-neg-frac92.5%
Simplified92.5%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (<= y 8.5e+80) (+ x (* z (/ (- y x) t))) (+ x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.5e+80) {
tmp = x + (z * ((y - x) / 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 <= 8.5d+80) then
tmp = x + (z * ((y - x) / 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 <= 8.5e+80) {
tmp = x + (z * ((y - x) / t));
} else {
tmp = x + (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.5e+80: tmp = x + (z * ((y - x) / t)) else: tmp = x + (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.5e+80) tmp = Float64(x + Float64(z * Float64(Float64(y - x) / 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 <= 8.5e+80) tmp = x + (z * ((y - x) / t)); else tmp = x + (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.5e+80], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{+80}:\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if y < 8.50000000000000007e80Initial program 93.0%
associate-*l/94.9%
Applied egg-rr94.9%
if 8.50000000000000007e80 < y Initial program 90.0%
Taylor expanded in y around inf 90.0%
associate-*r/99.8%
Simplified99.8%
Final simplification95.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.26e+88) (+ x (/ z (/ t (- y x)))) (+ x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.26e+88) {
tmp = x + (z / (t / (y - x)));
} 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 <= 1.26d+88) then
tmp = x + (z / (t / (y - x)))
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 <= 1.26e+88) {
tmp = x + (z / (t / (y - x)));
} else {
tmp = x + (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.26e+88: tmp = x + (z / (t / (y - x))) else: tmp = x + (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.26e+88) tmp = Float64(x + Float64(z / Float64(t / Float64(y - x)))); 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 <= 1.26e+88) tmp = x + (z / (t / (y - x))); else tmp = x + (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.26e+88], N[(x + N[(z / N[(t / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.26 \cdot 10^{+88}:\\
\;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if y < 1.26e88Initial program 93.0%
associate-/l*96.9%
clear-num96.9%
inv-pow96.9%
Applied egg-rr96.9%
unpow-196.9%
clear-num96.9%
associate-/r/94.9%
clear-num94.6%
associate-*l/95.4%
*-un-lft-identity95.4%
Applied egg-rr95.4%
if 1.26e88 < y Initial program 90.0%
Taylor expanded in y around inf 90.0%
associate-*r/99.8%
Simplified99.8%
Final simplification96.1%
(FPCore (x y z t) :precision binary64 (if (<= t -6.5e-18) x (if (<= t 7.8e-51) (* z (/ (- x) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6.5e-18) {
tmp = x;
} else if (t <= 7.8e-51) {
tmp = z * (-x / 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 (t <= (-6.5d-18)) then
tmp = x
else if (t <= 7.8d-51) then
tmp = z * (-x / 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 (t <= -6.5e-18) {
tmp = x;
} else if (t <= 7.8e-51) {
tmp = z * (-x / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -6.5e-18: tmp = x elif t <= 7.8e-51: tmp = z * (-x / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -6.5e-18) tmp = x; elseif (t <= 7.8e-51) tmp = Float64(z * Float64(Float64(-x) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -6.5e-18) tmp = x; elseif (t <= 7.8e-51) tmp = z * (-x / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -6.5e-18], x, If[LessEqual[t, 7.8e-51], N[(z * N[((-x) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{-18}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 7.8 \cdot 10^{-51}:\\
\;\;\;\;z \cdot \frac{-x}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -6.50000000000000008e-18 or 7.7999999999999995e-51 < t Initial program 86.4%
Taylor expanded in z around 0 61.4%
if -6.50000000000000008e-18 < t < 7.7999999999999995e-51Initial program 99.9%
associate-*l/87.8%
Applied egg-rr87.8%
Taylor expanded in y around 0 54.5%
neg-mul-154.5%
distribute-neg-frac54.5%
Simplified54.5%
add-sqr-sqrt23.8%
sqrt-unprod27.1%
sqr-neg27.1%
sqrt-unprod7.3%
add-sqr-sqrt14.1%
cancel-sign-sub14.1%
distribute-frac-neg14.1%
associate-*l/18.2%
associate-/l*20.6%
add-sqr-sqrt10.9%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod31.3%
add-sqr-sqrt59.3%
Applied egg-rr59.3%
Taylor expanded in t around 0 45.8%
mul-1-neg45.8%
associate-*l/45.5%
*-commutative45.5%
distribute-rgt-neg-in45.5%
Simplified45.5%
Final simplification54.1%
(FPCore (x y z t) :precision binary64 (if (<= t -7e-18) x (if (<= t 1.25e-33) (* x (- (/ z t))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -7e-18) {
tmp = x;
} else if (t <= 1.25e-33) {
tmp = x * -(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 (t <= (-7d-18)) then
tmp = x
else if (t <= 1.25d-33) then
tmp = x * -(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 (t <= -7e-18) {
tmp = x;
} else if (t <= 1.25e-33) {
tmp = x * -(z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -7e-18: tmp = x elif t <= 1.25e-33: tmp = x * -(z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -7e-18) tmp = x; elseif (t <= 1.25e-33) tmp = Float64(x * Float64(-Float64(z / t))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -7e-18) tmp = x; elseif (t <= 1.25e-33) tmp = x * -(z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -7e-18], x, If[LessEqual[t, 1.25e-33], N[(x * (-N[(z / t), $MachinePrecision])), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7 \cdot 10^{-18}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 1.25 \cdot 10^{-33}:\\
\;\;\;\;x \cdot \left(-\frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -6.9999999999999997e-18 or 1.25000000000000007e-33 < t Initial program 86.4%
Taylor expanded in z around 0 61.4%
if -6.9999999999999997e-18 < t < 1.25000000000000007e-33Initial program 99.9%
associate-*l/87.8%
Applied egg-rr87.8%
Taylor expanded in y around 0 54.5%
neg-mul-154.5%
distribute-neg-frac54.5%
Simplified54.5%
add-sqr-sqrt23.8%
sqrt-unprod27.1%
sqr-neg27.1%
sqrt-unprod7.3%
add-sqr-sqrt14.1%
cancel-sign-sub14.1%
distribute-frac-neg14.1%
associate-*l/18.2%
associate-/l*20.6%
add-sqr-sqrt10.9%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod31.3%
add-sqr-sqrt59.3%
Applied egg-rr59.3%
Taylor expanded in t around 0 45.8%
mul-1-neg45.8%
associate-*r/45.9%
distribute-lft-neg-out45.9%
*-commutative45.9%
Simplified45.9%
Final simplification54.3%
(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 92.6%
associate-/l*97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x y z t) :precision binary64 (* x (- 1.0 (/ z t))))
double code(double x, double y, double z, double t) {
return x * (1.0 - (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 * (1.0d0 - (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x * (1.0 - (z / t));
}
def code(x, y, z, t): return x * (1.0 - (z / t))
function code(x, y, z, t) return Float64(x * Float64(1.0 - Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x * (1.0 - (z / t)); end
code[x_, y_, z_, t_] := N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \frac{z}{t}\right)
\end{array}
Initial program 92.6%
Taylor expanded in x around inf 64.6%
mul-1-neg64.6%
unsub-neg64.6%
Simplified64.6%
Final simplification64.6%
(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 92.6%
Taylor expanded in z around 0 40.5%
Final simplification40.5%
(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 2024013
(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)))