
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - 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 / z) - (t / (1.0d0 - z)))
end function
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - 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 / z) - (t / (1.0d0 - z)))
end function
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
function code(x, y, z, t) return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))))
(if (<= t_1 -1e+291)
(* (/ (fma (- 1.0 z) y (* (- z) t)) (- 1.0 z)) (/ x z))
(if (<= t_1 2e+306)
(fma (/ y z) x (* (/ t (+ -1.0 z)) x))
(* y (/ x z))))))
double code(double x, double y, double z, double t) {
double t_1 = (y / z) - (t / (1.0 - z));
double tmp;
if (t_1 <= -1e+291) {
tmp = (fma((1.0 - z), y, (-z * t)) / (1.0 - z)) * (x / z);
} else if (t_1 <= 2e+306) {
tmp = fma((y / z), x, ((t / (-1.0 + z)) * x));
} else {
tmp = y * (x / z);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))) tmp = 0.0 if (t_1 <= -1e+291) tmp = Float64(Float64(fma(Float64(1.0 - z), y, Float64(Float64(-z) * t)) / Float64(1.0 - z)) * Float64(x / z)); elseif (t_1 <= 2e+306) tmp = fma(Float64(y / z), x, Float64(Float64(t / Float64(-1.0 + z)) * x)); else tmp = Float64(y * Float64(x / z)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+291], N[(N[(N[(N[(1.0 - z), $MachinePrecision] * y + N[((-z) * t), $MachinePrecision]), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+306], N[(N[(y / z), $MachinePrecision] * x + N[(N[(t / N[(-1.0 + z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+291}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1 - z, y, \left(-z\right) \cdot t\right)}{1 - z} \cdot \frac{x}{z}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, \frac{t}{-1 + z} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < -9.9999999999999996e290Initial program 72.3%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-subN/A
associate-*l/N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
cancel-sign-sub-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -9.9999999999999996e290 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 2.00000000000000003e306Initial program 99.1%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
metadata-evalN/A
remove-double-negN/A
lower-+.f6499.2
Applied rewrites99.2%
if 2.00000000000000003e306 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) Initial program 70.9%
Taylor expanded in y around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6470.9
Applied rewrites70.9%
Applied rewrites99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+306)))
(* y (/ x z))
(fma (/ y z) x (* (/ t (+ -1.0 z)) x)))))
double code(double x, double y, double z, double t) {
double t_1 = (y / z) - (t / (1.0 - z));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+306)) {
tmp = y * (x / z);
} else {
tmp = fma((y / z), x, ((t / (-1.0 + z)) * x));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+306)) tmp = Float64(y * Float64(x / z)); else tmp = fma(Float64(y / z), x, Float64(Float64(t / Float64(-1.0 + z)) * x)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+306]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x + N[(N[(t / N[(-1.0 + z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 2 \cdot 10^{+306}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, \frac{t}{-1 + z} \cdot x\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < -inf.0 or 2.00000000000000003e306 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) Initial program 70.1%
Taylor expanded in y around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6470.1
Applied rewrites70.1%
Applied rewrites100.0%
if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 2.00000000000000003e306Initial program 99.1%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
metadata-evalN/A
remove-double-negN/A
lower-+.f6499.2
Applied rewrites99.2%
Final simplification99.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+306)))
(* y (/ x z))
(* x t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (y / z) - (t / (1.0 - z));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+306)) {
tmp = y * (x / z);
} else {
tmp = x * t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (y / z) - (t / (1.0 - z));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+306)) {
tmp = y * (x / z);
} else {
tmp = x * t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (y / z) - (t / (1.0 - z)) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 2e+306): tmp = y * (x / z) else: tmp = x * t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+306)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(x * t_1); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (y / z) - (t / (1.0 - z)); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 2e+306))) tmp = y * (x / z); else tmp = x * t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+306]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 2 \cdot 10^{+306}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < -inf.0 or 2.00000000000000003e306 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) Initial program 70.1%
Taylor expanded in y around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6470.1
Applied rewrites70.1%
Applied rewrites100.0%
if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 2.00000000000000003e306Initial program 99.1%
Final simplification99.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.5e+20) (not (<= z 0.6))) (* x (/ (+ t y) z)) (/ (* x (- y (* t z))) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.5e+20) || !(z <= 0.6)) {
tmp = x * ((t + y) / z);
} else {
tmp = (x * (y - (t * z))) / 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 <= (-4.5d+20)) .or. (.not. (z <= 0.6d0))) then
tmp = x * ((t + y) / z)
else
tmp = (x * (y - (t * z))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.5e+20) || !(z <= 0.6)) {
tmp = x * ((t + y) / z);
} else {
tmp = (x * (y - (t * z))) / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.5e+20) or not (z <= 0.6): tmp = x * ((t + y) / z) else: tmp = (x * (y - (t * z))) / z return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.5e+20) || !(z <= 0.6)) tmp = Float64(x * Float64(Float64(t + y) / z)); else tmp = Float64(Float64(x * Float64(y - Float64(t * z))) / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.5e+20) || ~((z <= 0.6))) tmp = x * ((t + y) / z); else tmp = (x * (y - (t * z))) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.5e+20], N[Not[LessEqual[z, 0.6]], $MachinePrecision]], N[(x * N[(N[(t + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+20} \lor \neg \left(z \leq 0.6\right):\\
\;\;\;\;x \cdot \frac{t + y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y - t \cdot z\right)}{z}\\
\end{array}
\end{array}
if z < -4.5e20 or 0.599999999999999978 < z Initial program 98.8%
Taylor expanded in z around inf
lower-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
lower-+.f6498.1
Applied rewrites98.1%
if -4.5e20 < z < 0.599999999999999978Initial program 90.4%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-out--N/A
unsub-negN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f6494.7
Applied rewrites94.7%
Final simplification96.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.5e+20) (not (<= z 0.6))) (* x (/ (+ t y) z)) (* x (- (/ y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.5e+20) || !(z <= 0.6)) {
tmp = x * ((t + y) / z);
} 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 ((z <= (-4.5d+20)) .or. (.not. (z <= 0.6d0))) then
tmp = x * ((t + y) / z)
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 ((z <= -4.5e+20) || !(z <= 0.6)) {
tmp = x * ((t + y) / z);
} else {
tmp = x * ((y / z) - t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.5e+20) or not (z <= 0.6): tmp = x * ((t + y) / z) else: tmp = x * ((y / z) - t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.5e+20) || !(z <= 0.6)) tmp = Float64(x * Float64(Float64(t + y) / z)); else tmp = Float64(x * Float64(Float64(y / z) - t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.5e+20) || ~((z <= 0.6))) tmp = x * ((t + y) / z); else tmp = x * ((y / z) - t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.5e+20], N[Not[LessEqual[z, 0.6]], $MachinePrecision]], N[(x * N[(N[(t + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+20} \lor \neg \left(z \leq 0.6\right):\\
\;\;\;\;x \cdot \frac{t + y}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\
\end{array}
\end{array}
if z < -4.5e20 or 0.599999999999999978 < z Initial program 98.8%
Taylor expanded in z around inf
lower-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
lower-+.f6498.1
Applied rewrites98.1%
if -4.5e20 < z < 0.599999999999999978Initial program 90.4%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-out--N/A
unsub-negN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f6494.7
Applied rewrites94.7%
Taylor expanded in y around 0
Applied rewrites90.4%
Final simplification94.2%
(FPCore (x y z t) :precision binary64 (if (<= z -9.5e+23) (* x (/ t z)) (if (<= z 5.8e-31) (* x (- (/ y z) t)) (* (/ y z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.5e+23) {
tmp = x * (t / z);
} else if (z <= 5.8e-31) {
tmp = x * ((y / z) - t);
} else {
tmp = (y / z) * 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 <= (-9.5d+23)) then
tmp = x * (t / z)
else if (z <= 5.8d-31) then
tmp = x * ((y / z) - t)
else
tmp = (y / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.5e+23) {
tmp = x * (t / z);
} else if (z <= 5.8e-31) {
tmp = x * ((y / z) - t);
} else {
tmp = (y / z) * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9.5e+23: tmp = x * (t / z) elif z <= 5.8e-31: tmp = x * ((y / z) - t) else: tmp = (y / z) * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9.5e+23) tmp = Float64(x * Float64(t / z)); elseif (z <= 5.8e-31) tmp = Float64(x * Float64(Float64(y / z) - t)); else tmp = Float64(Float64(y / z) * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -9.5e+23) tmp = x * (t / z); elseif (z <= 5.8e-31) tmp = x * ((y / z) - t); else tmp = (y / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9.5e+23], N[(x * N[(t / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.8e-31], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+23}:\\
\;\;\;\;x \cdot \frac{t}{z}\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-31}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\end{array}
\end{array}
if z < -9.50000000000000038e23Initial program 97.9%
Taylor expanded in z around inf
lower-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
lower-+.f6497.9
Applied rewrites97.9%
Taylor expanded in y around 0
Applied rewrites66.1%
if -9.50000000000000038e23 < z < 5.8000000000000001e-31Initial program 90.1%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-out--N/A
unsub-negN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f6494.6
Applied rewrites94.6%
Taylor expanded in y around 0
Applied rewrites90.1%
if 5.8000000000000001e-31 < z Initial program 99.7%
Taylor expanded in y around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6465.3
Applied rewrites65.3%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6.2e+176) (not (<= t 3.6e+101))) (* x (/ t z)) (* (/ y z) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.2e+176) || !(t <= 3.6e+101)) {
tmp = x * (t / z);
} else {
tmp = (y / z) * 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.2d+176)) .or. (.not. (t <= 3.6d+101))) then
tmp = x * (t / z)
else
tmp = (y / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.2e+176) || !(t <= 3.6e+101)) {
tmp = x * (t / z);
} else {
tmp = (y / z) * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -6.2e+176) or not (t <= 3.6e+101): tmp = x * (t / z) else: tmp = (y / z) * x return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -6.2e+176) || !(t <= 3.6e+101)) tmp = Float64(x * Float64(t / z)); else tmp = Float64(Float64(y / z) * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -6.2e+176) || ~((t <= 3.6e+101))) tmp = x * (t / z); else tmp = (y / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -6.2e+176], N[Not[LessEqual[t, 3.6e+101]], $MachinePrecision]], N[(x * N[(t / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.2 \cdot 10^{+176} \lor \neg \left(t \leq 3.6 \cdot 10^{+101}\right):\\
\;\;\;\;x \cdot \frac{t}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\end{array}
\end{array}
if t < -6.1999999999999998e176 or 3.60000000000000029e101 < t Initial program 95.0%
Taylor expanded in z around inf
lower-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
lower-+.f6466.2
Applied rewrites66.2%
Taylor expanded in y around 0
Applied rewrites59.8%
if -6.1999999999999998e176 < t < 3.60000000000000029e101Initial program 94.3%
Taylor expanded in y around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
Final simplification72.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6.2e+176) (not (<= t 3.6e+101))) (* (/ x z) t) (* (/ y z) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.2e+176) || !(t <= 3.6e+101)) {
tmp = (x / z) * t;
} else {
tmp = (y / z) * 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.2d+176)) .or. (.not. (t <= 3.6d+101))) then
tmp = (x / z) * t
else
tmp = (y / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.2e+176) || !(t <= 3.6e+101)) {
tmp = (x / z) * t;
} else {
tmp = (y / z) * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -6.2e+176) or not (t <= 3.6e+101): tmp = (x / z) * t else: tmp = (y / z) * x return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -6.2e+176) || !(t <= 3.6e+101)) tmp = Float64(Float64(x / z) * t); else tmp = Float64(Float64(y / z) * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -6.2e+176) || ~((t <= 3.6e+101))) tmp = (x / z) * t; else tmp = (y / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -6.2e+176], N[Not[LessEqual[t, 3.6e+101]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * t), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.2 \cdot 10^{+176} \lor \neg \left(t \leq 3.6 \cdot 10^{+101}\right):\\
\;\;\;\;\frac{x}{z} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\end{array}
\end{array}
if t < -6.1999999999999998e176 or 3.60000000000000029e101 < t Initial program 95.0%
Taylor expanded in y around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6466.1
Applied rewrites66.1%
Taylor expanded in z around inf
Applied rewrites53.8%
if -6.1999999999999998e176 < t < 3.60000000000000029e101Initial program 94.3%
Taylor expanded in y around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
Final simplification70.7%
(FPCore (x y z t) :precision binary64 (if (or (<= z -22000000000.0) (not (<= z 0.6))) (* (/ x z) t) (* (fma z x x) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -22000000000.0) || !(z <= 0.6)) {
tmp = (x / z) * t;
} else {
tmp = fma(z, x, x) * -t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -22000000000.0) || !(z <= 0.6)) tmp = Float64(Float64(x / z) * t); else tmp = Float64(fma(z, x, x) * Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -22000000000.0], N[Not[LessEqual[z, 0.6]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * t), $MachinePrecision], N[(N[(z * x + x), $MachinePrecision] * (-t)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -22000000000 \lor \neg \left(z \leq 0.6\right):\\
\;\;\;\;\frac{x}{z} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right) \cdot \left(-t\right)\\
\end{array}
\end{array}
if z < -2.2e10 or 0.599999999999999978 < z Initial program 98.8%
Taylor expanded in y around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6453.2
Applied rewrites53.2%
Taylor expanded in z around inf
Applied rewrites54.8%
if -2.2e10 < z < 0.599999999999999978Initial program 90.2%
Taylor expanded in y around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6429.5
Applied rewrites29.5%
Taylor expanded in z around 0
Applied rewrites29.6%
Final simplification42.2%
(FPCore (x y z t) :precision binary64 (if (<= z -8.2e+15) (* (/ x z) t) (* y (/ x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e+15) {
tmp = (x / z) * t;
} else {
tmp = y * (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 <= (-8.2d+15)) then
tmp = (x / z) * t
else
tmp = y * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e+15) {
tmp = (x / z) * t;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.2e+15: tmp = (x / z) * t else: tmp = y * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.2e+15) tmp = Float64(Float64(x / z) * t); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.2e+15) tmp = (x / z) * t; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.2e+15], N[(N[(x / z), $MachinePrecision] * t), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{z} \cdot t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -8.2e15Initial program 97.9%
Taylor expanded in y around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6459.4
Applied rewrites59.4%
Taylor expanded in z around inf
Applied rewrites63.5%
if -8.2e15 < z Initial program 93.3%
Taylor expanded in y around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6466.7
Applied rewrites66.7%
Applied rewrites68.3%
(FPCore (x y z t) :precision binary64 (* (- t) x))
double code(double x, double y, double z, double t) {
return -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 = -t * x
end function
public static double code(double x, double y, double z, double t) {
return -t * x;
}
def code(x, y, z, t): return -t * x
function code(x, y, z, t) return Float64(Float64(-t) * x) end
function tmp = code(x, y, z, t) tmp = -t * x; end
code[x_, y_, z_, t_] := N[((-t) * x), $MachinePrecision]
\begin{array}{l}
\\
\left(-t\right) \cdot x
\end{array}
Initial program 94.5%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-out--N/A
unsub-negN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-*.f6465.1
Applied rewrites65.1%
Taylor expanded in y around 0
Applied rewrites20.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))))
(t_2 (* x (- (/ y z) (/ t (- 1.0 z))))))
(if (< t_2 -7.623226303312042e-196)
t_1
(if (< t_2 1.4133944927702302e-211)
(+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z))))
t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z))));
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 < -7.623226303312042e-196) {
tmp = t_1;
} else if (t_2 < 1.4133944927702302e-211) {
tmp = ((y * x) / z) + -((t * x) / (1.0 - z));
} 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) :: t_2
real(8) :: tmp
t_1 = x * ((y / z) - (t * (1.0d0 / (1.0d0 - z))))
t_2 = x * ((y / z) - (t / (1.0d0 - z)))
if (t_2 < (-7.623226303312042d-196)) then
tmp = t_1
else if (t_2 < 1.4133944927702302d-211) then
tmp = ((y * x) / z) + -((t * x) / (1.0d0 - z))
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 * (1.0 / (1.0 - z))));
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 < -7.623226303312042e-196) {
tmp = t_1;
} else if (t_2 < 1.4133944927702302e-211) {
tmp = ((y * x) / z) + -((t * x) / (1.0 - z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z)))) t_2 = x * ((y / z) - (t / (1.0 - z))) tmp = 0 if t_2 < -7.623226303312042e-196: tmp = t_1 elif t_2 < 1.4133944927702302e-211: tmp = ((y * x) / z) + -((t * x) / (1.0 - z)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(Float64(y / z) - Float64(t * Float64(1.0 / Float64(1.0 - z))))) t_2 = Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) tmp = 0.0 if (t_2 < -7.623226303312042e-196) tmp = t_1; elseif (t_2 < 1.4133944927702302e-211) tmp = Float64(Float64(Float64(y * x) / z) + Float64(-Float64(Float64(t * x) / Float64(1.0 - z)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * ((y / z) - (t * (1.0 / (1.0 - z)))); t_2 = x * ((y / z) - (t / (1.0 - z))); tmp = 0.0; if (t_2 < -7.623226303312042e-196) tmp = t_1; elseif (t_2 < 1.4133944927702302e-211) tmp = ((y * x) / z) + -((t * x) / (1.0 - z)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(N[(y / z), $MachinePrecision] - N[(t * N[(1.0 / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$2, -7.623226303312042e-196], t$95$1, If[Less[t$95$2, 1.4133944927702302e-211], N[(N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision] + (-N[(N[(t * x), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\
t_2 := x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\
\mathbf{if}\;t\_2 < -7.623226303312042 \cdot 10^{-196}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 < 1.4133944927702302 \cdot 10^{-211}:\\
\;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024325
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
:precision binary64
:alt
(! :herbie-platform default (if (< (* x (- (/ y z) (/ t (- 1 z)))) -3811613151656021/5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 7066972463851151/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z))))))))
(* x (- (/ y z) (/ t (- 1.0 z)))))