
(FPCore (x y z t) :precision binary64 (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (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) + ((2.0d0 + ((z * 2.0d0) * (1.0d0 - t))) / (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
def code(x, y, z, t): return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (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) + ((2.0d0 + ((z * 2.0d0) * (1.0d0 - t))) / (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
def code(x, y, z, t): return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\end{array}
(FPCore (x y z t) :precision binary64 (+ (/ x y) (+ (/ 2.0 (* t z)) (- (/ 2.0 t) 2.0))))
double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 / (t * z)) + ((2.0 / t) - 2.0));
}
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) + ((2.0d0 / (t * z)) + ((2.0d0 / t) - 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((2.0 / (t * z)) + ((2.0 / t) - 2.0));
}
def code(x, y, z, t): return (x / y) + ((2.0 / (t * z)) + ((2.0 / t) - 2.0))
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(2.0 / Float64(t * z)) + Float64(Float64(2.0 / t) - 2.0))) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((2.0 / (t * z)) + ((2.0 / t) - 2.0)); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \left(\frac{2}{t \cdot z} + \left(\frac{2}{t} - 2\right)\right)
\end{array}
Initial program 89.7%
Taylor expanded in t around 0 99.6%
associate--l+99.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z t)
:precision binary64
(if (<= (/ x y) -5e+24)
(+ (/ x y) (+ (/ 2.0 t) -2.0))
(if (<= (/ x y) 200000000000.0)
(+ (/ 2.0 t) (+ -2.0 (/ (/ 2.0 t) z)))
(+ (/ x y) (/ 2.0 (* t z))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5e+24) {
tmp = (x / y) + ((2.0 / t) + -2.0);
} else if ((x / y) <= 200000000000.0) {
tmp = (2.0 / t) + (-2.0 + ((2.0 / t) / z));
} else {
tmp = (x / y) + (2.0 / (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 / y) <= (-5d+24)) then
tmp = (x / y) + ((2.0d0 / t) + (-2.0d0))
else if ((x / y) <= 200000000000.0d0) then
tmp = (2.0d0 / t) + ((-2.0d0) + ((2.0d0 / t) / z))
else
tmp = (x / y) + (2.0d0 / (t * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -5e+24) {
tmp = (x / y) + ((2.0 / t) + -2.0);
} else if ((x / y) <= 200000000000.0) {
tmp = (2.0 / t) + (-2.0 + ((2.0 / t) / z));
} else {
tmp = (x / y) + (2.0 / (t * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -5e+24: tmp = (x / y) + ((2.0 / t) + -2.0) elif (x / y) <= 200000000000.0: tmp = (2.0 / t) + (-2.0 + ((2.0 / t) / z)) else: tmp = (x / y) + (2.0 / (t * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -5e+24) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) + -2.0)); elseif (Float64(x / y) <= 200000000000.0) tmp = Float64(Float64(2.0 / t) + Float64(-2.0 + Float64(Float64(2.0 / t) / z))); else tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -5e+24) tmp = (x / y) + ((2.0 / t) + -2.0); elseif ((x / y) <= 200000000000.0) tmp = (2.0 / t) + (-2.0 + ((2.0 / t) / z)); else tmp = (x / y) + (2.0 / (t * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -5e+24], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 200000000000.0], N[(N[(2.0 / t), $MachinePrecision] + N[(-2.0 + N[(N[(2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -5 \cdot 10^{+24}:\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} + -2\right)\\
\mathbf{elif}\;\frac{x}{y} \leq 200000000000:\\
\;\;\;\;\frac{2}{t} + \left(-2 + \frac{\frac{2}{t}}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\end{array}
\end{array}
if (/.f64 x y) < -5.00000000000000045e24Initial program 85.9%
Taylor expanded in t around 0 98.4%
associate--l+98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in z around inf 89.6%
associate--l+89.6%
sub-neg89.6%
associate-*r/89.6%
metadata-eval89.6%
metadata-eval89.6%
Simplified89.6%
if -5.00000000000000045e24 < (/.f64 x y) < 2e11Initial program 90.0%
Taylor expanded in t around 0 99.9%
associate--l+99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 97.7%
associate--l+97.7%
associate-*r/97.7%
metadata-eval97.7%
associate-*r/97.7%
metadata-eval97.7%
sub-neg97.7%
associate-/r*97.7%
metadata-eval97.7%
Simplified97.7%
if 2e11 < (/.f64 x y) Initial program 93.1%
Taylor expanded in z around 0 91.7%
Final simplification94.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.8e-177) (not (<= z 1.06e-165))) (+ (/ x y) (+ (/ 2.0 t) -2.0)) (/ (/ 2.0 t) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.8e-177) || !(z <= 1.06e-165)) {
tmp = (x / y) + ((2.0 / t) + -2.0);
} else {
tmp = (2.0 / 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 <= (-1.8d-177)) .or. (.not. (z <= 1.06d-165))) then
tmp = (x / y) + ((2.0d0 / t) + (-2.0d0))
else
tmp = (2.0d0 / t) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.8e-177) || !(z <= 1.06e-165)) {
tmp = (x / y) + ((2.0 / t) + -2.0);
} else {
tmp = (2.0 / t) / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.8e-177) or not (z <= 1.06e-165): tmp = (x / y) + ((2.0 / t) + -2.0) else: tmp = (2.0 / t) / z return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.8e-177) || !(z <= 1.06e-165)) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) + -2.0)); else tmp = Float64(Float64(2.0 / t) / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.8e-177) || ~((z <= 1.06e-165))) tmp = (x / y) + ((2.0 / t) + -2.0); else tmp = (2.0 / t) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.8e-177], N[Not[LessEqual[z, 1.06e-165]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / t), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{-177} \lor \neg \left(z \leq 1.06 \cdot 10^{-165}\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} + -2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{t}}{z}\\
\end{array}
\end{array}
if z < -1.79999999999999991e-177 or 1.05999999999999999e-165 < z Initial program 87.2%
Taylor expanded in t around 0 100.0%
associate--l+100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 88.2%
associate--l+88.2%
sub-neg88.2%
associate-*r/88.2%
metadata-eval88.2%
metadata-eval88.2%
Simplified88.2%
if -1.79999999999999991e-177 < z < 1.05999999999999999e-165Initial program 98.2%
Taylor expanded in t around 0 98.2%
associate--l+98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in z around 0 81.2%
associate-/r*81.3%
Simplified81.3%
Final simplification86.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.8e-46) (not (<= z 0.00014))) (+ (/ x y) (+ (/ 2.0 t) -2.0)) (+ (/ x y) (/ 2.0 (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e-46) || !(z <= 0.00014)) {
tmp = (x / y) + ((2.0 / t) + -2.0);
} else {
tmp = (x / y) + (2.0 / (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 <= (-5.8d-46)) .or. (.not. (z <= 0.00014d0))) then
tmp = (x / y) + ((2.0d0 / t) + (-2.0d0))
else
tmp = (x / y) + (2.0d0 / (t * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.8e-46) || !(z <= 0.00014)) {
tmp = (x / y) + ((2.0 / t) + -2.0);
} else {
tmp = (x / y) + (2.0 / (t * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.8e-46) or not (z <= 0.00014): tmp = (x / y) + ((2.0 / t) + -2.0) else: tmp = (x / y) + (2.0 / (t * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.8e-46) || !(z <= 0.00014)) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) + -2.0)); else tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.8e-46) || ~((z <= 0.00014))) tmp = (x / y) + ((2.0 / t) + -2.0); else tmp = (x / y) + (2.0 / (t * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.8e-46], N[Not[LessEqual[z, 0.00014]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-46} \lor \neg \left(z \leq 0.00014\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} + -2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\end{array}
\end{array}
if z < -5.80000000000000009e-46 or 1.3999999999999999e-4 < z Initial program 82.6%
Taylor expanded in t around 0 100.0%
associate--l+100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 98.3%
associate--l+98.3%
sub-neg98.3%
associate-*r/98.3%
metadata-eval98.3%
metadata-eval98.3%
Simplified98.3%
if -5.80000000000000009e-46 < z < 1.3999999999999999e-4Initial program 99.0%
Taylor expanded in z around 0 88.2%
Final simplification93.9%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -9e+22) (/ x y) (if (<= (/ x y) 31000000000000.0) (+ (/ 2.0 t) -2.0) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -9e+22) {
tmp = x / y;
} else if ((x / y) <= 31000000000000.0) {
tmp = (2.0 / t) + -2.0;
} else {
tmp = x / 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 ((x / y) <= (-9d+22)) then
tmp = x / y
else if ((x / y) <= 31000000000000.0d0) then
tmp = (2.0d0 / t) + (-2.0d0)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -9e+22) {
tmp = x / y;
} else if ((x / y) <= 31000000000000.0) {
tmp = (2.0 / t) + -2.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -9e+22: tmp = x / y elif (x / y) <= 31000000000000.0: tmp = (2.0 / t) + -2.0 else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -9e+22) tmp = Float64(x / y); elseif (Float64(x / y) <= 31000000000000.0) tmp = Float64(Float64(2.0 / t) + -2.0); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -9e+22) tmp = x / y; elseif ((x / y) <= 31000000000000.0) tmp = (2.0 / t) + -2.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -9e+22], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 31000000000000.0], N[(N[(2.0 / t), $MachinePrecision] + -2.0), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -9 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 31000000000000:\\
\;\;\;\;\frac{2}{t} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -8.9999999999999996e22 or 3.1e13 < (/.f64 x y) Initial program 89.4%
Taylor expanded in x around inf 71.7%
if -8.9999999999999996e22 < (/.f64 x y) < 3.1e13Initial program 90.0%
Taylor expanded in t around 0 99.9%
associate--l+99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 65.3%
associate--l+65.3%
sub-neg65.3%
associate-*r/65.3%
metadata-eval65.3%
metadata-eval65.3%
Simplified65.3%
Taylor expanded in x around 0 63.0%
sub-neg63.0%
associate-*r/63.0%
metadata-eval63.0%
metadata-eval63.0%
Simplified63.0%
Final simplification67.2%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -2.5e+21) (/ x y) (if (<= (/ x y) 215000000000.0) (+ (/ 2.0 t) -2.0) (- (/ x y) 2.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -2.5e+21) {
tmp = x / y;
} else if ((x / y) <= 215000000000.0) {
tmp = (2.0 / t) + -2.0;
} else {
tmp = (x / y) - 2.0;
}
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 / y) <= (-2.5d+21)) then
tmp = x / y
else if ((x / y) <= 215000000000.0d0) then
tmp = (2.0d0 / t) + (-2.0d0)
else
tmp = (x / y) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -2.5e+21) {
tmp = x / y;
} else if ((x / y) <= 215000000000.0) {
tmp = (2.0 / t) + -2.0;
} else {
tmp = (x / y) - 2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -2.5e+21: tmp = x / y elif (x / y) <= 215000000000.0: tmp = (2.0 / t) + -2.0 else: tmp = (x / y) - 2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -2.5e+21) tmp = Float64(x / y); elseif (Float64(x / y) <= 215000000000.0) tmp = Float64(Float64(2.0 / t) + -2.0); else tmp = Float64(Float64(x / y) - 2.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -2.5e+21) tmp = x / y; elseif ((x / y) <= 215000000000.0) tmp = (2.0 / t) + -2.0; else tmp = (x / y) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -2.5e+21], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 215000000000.0], N[(N[(2.0 / t), $MachinePrecision] + -2.0), $MachinePrecision], N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -2.5 \cdot 10^{+21}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 215000000000:\\
\;\;\;\;\frac{2}{t} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -2.5e21Initial program 85.9%
Taylor expanded in x around inf 77.4%
if -2.5e21 < (/.f64 x y) < 2.15e11Initial program 90.0%
Taylor expanded in t around 0 99.9%
associate--l+99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 65.3%
associate--l+65.3%
sub-neg65.3%
associate-*r/65.3%
metadata-eval65.3%
metadata-eval65.3%
Simplified65.3%
Taylor expanded in x around 0 63.0%
sub-neg63.0%
associate-*r/63.0%
metadata-eval63.0%
metadata-eval63.0%
Simplified63.0%
if 2.15e11 < (/.f64 x y) Initial program 93.1%
Taylor expanded in t around inf 65.5%
Final simplification67.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ x y) 2.0)))
(if (<= t -3.1e-171)
t_1
(if (<= t -1.2e-260)
(/ 2.0 t)
(if (<= t 5.8e-124) (/ 2.0 (* t z)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (x / y) - 2.0;
double tmp;
if (t <= -3.1e-171) {
tmp = t_1;
} else if (t <= -1.2e-260) {
tmp = 2.0 / t;
} else if (t <= 5.8e-124) {
tmp = 2.0 / (t * 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) :: tmp
t_1 = (x / y) - 2.0d0
if (t <= (-3.1d-171)) then
tmp = t_1
else if (t <= (-1.2d-260)) then
tmp = 2.0d0 / t
else if (t <= 5.8d-124) then
tmp = 2.0d0 / (t * 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) - 2.0;
double tmp;
if (t <= -3.1e-171) {
tmp = t_1;
} else if (t <= -1.2e-260) {
tmp = 2.0 / t;
} else if (t <= 5.8e-124) {
tmp = 2.0 / (t * z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x / y) - 2.0 tmp = 0 if t <= -3.1e-171: tmp = t_1 elif t <= -1.2e-260: tmp = 2.0 / t elif t <= 5.8e-124: tmp = 2.0 / (t * z) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x / y) - 2.0) tmp = 0.0 if (t <= -3.1e-171) tmp = t_1; elseif (t <= -1.2e-260) tmp = Float64(2.0 / t); elseif (t <= 5.8e-124) tmp = Float64(2.0 / Float64(t * z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x / y) - 2.0; tmp = 0.0; if (t <= -3.1e-171) tmp = t_1; elseif (t <= -1.2e-260) tmp = 2.0 / t; elseif (t <= 5.8e-124) tmp = 2.0 / (t * z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]}, If[LessEqual[t, -3.1e-171], t$95$1, If[LessEqual[t, -1.2e-260], N[(2.0 / t), $MachinePrecision], If[LessEqual[t, 5.8e-124], N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y} - 2\\
\mathbf{if}\;t \leq -3.1 \cdot 10^{-171}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -1.2 \cdot 10^{-260}:\\
\;\;\;\;\frac{2}{t}\\
\mathbf{elif}\;t \leq 5.8 \cdot 10^{-124}:\\
\;\;\;\;\frac{2}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if t < -3.1e-171 or 5.8000000000000004e-124 < t Initial program 86.2%
Taylor expanded in t around inf 71.0%
if -3.1e-171 < t < -1.2e-260Initial program 99.6%
Taylor expanded in t around 0 95.6%
associate-*r/95.6%
metadata-eval95.6%
Simplified95.6%
Taylor expanded in z around inf 65.4%
if -1.2e-260 < t < 5.8000000000000004e-124Initial program 99.9%
Taylor expanded in t around 0 100.0%
associate--l+100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around 0 61.2%
Final simplification68.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -4.6e-21) (not (<= t 4e+34))) (- (/ x y) 2.0) (/ (+ 2.0 (/ 2.0 z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.6e-21) || !(t <= 4e+34)) {
tmp = (x / y) - 2.0;
} else {
tmp = (2.0 + (2.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 ((t <= (-4.6d-21)) .or. (.not. (t <= 4d+34))) then
tmp = (x / y) - 2.0d0
else
tmp = (2.0d0 + (2.0d0 / z)) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.6e-21) || !(t <= 4e+34)) {
tmp = (x / y) - 2.0;
} else {
tmp = (2.0 + (2.0 / z)) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -4.6e-21) or not (t <= 4e+34): tmp = (x / y) - 2.0 else: tmp = (2.0 + (2.0 / z)) / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -4.6e-21) || !(t <= 4e+34)) tmp = Float64(Float64(x / y) - 2.0); else tmp = Float64(Float64(2.0 + Float64(2.0 / z)) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -4.6e-21) || ~((t <= 4e+34))) tmp = (x / y) - 2.0; else tmp = (2.0 + (2.0 / z)) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -4.6e-21], N[Not[LessEqual[t, 4e+34]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{-21} \lor \neg \left(t \leq 4 \cdot 10^{+34}\right):\\
\;\;\;\;\frac{x}{y} - 2\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\
\end{array}
\end{array}
if t < -4.59999999999999999e-21 or 3.99999999999999978e34 < t Initial program 80.6%
Taylor expanded in t around inf 85.2%
if -4.59999999999999999e-21 < t < 3.99999999999999978e34Initial program 99.0%
Taylor expanded in t around 0 78.0%
associate-*r/78.0%
metadata-eval78.0%
Simplified78.0%
Final simplification81.7%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -6e-9) (/ x y) (if (<= (/ x y) 0.025) -2.0 (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -6e-9) {
tmp = x / y;
} else if ((x / y) <= 0.025) {
tmp = -2.0;
} else {
tmp = x / 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 ((x / y) <= (-6d-9)) then
tmp = x / y
else if ((x / y) <= 0.025d0) then
tmp = -2.0d0
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -6e-9) {
tmp = x / y;
} else if ((x / y) <= 0.025) {
tmp = -2.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -6e-9: tmp = x / y elif (x / y) <= 0.025: tmp = -2.0 else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -6e-9) tmp = Float64(x / y); elseif (Float64(x / y) <= 0.025) tmp = -2.0; else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -6e-9) tmp = x / y; elseif ((x / y) <= 0.025) tmp = -2.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -6e-9], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 0.025], -2.0, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -6 \cdot 10^{-9}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 0.025:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -5.99999999999999996e-9 or 0.025000000000000001 < (/.f64 x y) Initial program 89.6%
Taylor expanded in x around inf 66.4%
if -5.99999999999999996e-9 < (/.f64 x y) < 0.025000000000000001Initial program 89.9%
Taylor expanded in t around 0 99.9%
associate--l+99.9%
associate-*r/99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 99.0%
associate--l+99.0%
associate-*r/99.0%
metadata-eval99.0%
associate-*r/99.0%
metadata-eval99.0%
sub-neg99.0%
associate-/r*99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in t around inf 40.8%
Final simplification54.3%
(FPCore (x y z t) :precision binary64 (if (<= t -1200.0) -2.0 (if (<= t 2500.0) (/ 2.0 t) -2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1200.0) {
tmp = -2.0;
} else if (t <= 2500.0) {
tmp = 2.0 / t;
} else {
tmp = -2.0;
}
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 <= (-1200.0d0)) then
tmp = -2.0d0
else if (t <= 2500.0d0) then
tmp = 2.0d0 / t
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1200.0) {
tmp = -2.0;
} else if (t <= 2500.0) {
tmp = 2.0 / t;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1200.0: tmp = -2.0 elif t <= 2500.0: tmp = 2.0 / t else: tmp = -2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1200.0) tmp = -2.0; elseif (t <= 2500.0) tmp = Float64(2.0 / t); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1200.0) tmp = -2.0; elseif (t <= 2500.0) tmp = 2.0 / t; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1200.0], -2.0, If[LessEqual[t, 2500.0], N[(2.0 / t), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1200:\\
\;\;\;\;-2\\
\mathbf{elif}\;t \leq 2500:\\
\;\;\;\;\frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if t < -1200 or 2500 < t Initial program 79.6%
Taylor expanded in t around 0 100.0%
associate--l+100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 55.0%
associate--l+55.0%
associate-*r/55.0%
metadata-eval55.0%
associate-*r/55.0%
metadata-eval55.0%
sub-neg55.0%
associate-/r*55.0%
metadata-eval55.0%
Simplified55.0%
Taylor expanded in t around inf 40.1%
if -1200 < t < 2500Initial program 99.0%
Taylor expanded in t around 0 74.3%
associate-*r/74.3%
metadata-eval74.3%
Simplified74.3%
Taylor expanded in z around inf 36.1%
Final simplification38.0%
(FPCore (x y z t) :precision binary64 -2.0)
double code(double x, double y, double z, double t) {
return -2.0;
}
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 = -2.0d0
end function
public static double code(double x, double y, double z, double t) {
return -2.0;
}
def code(x, y, z, t): return -2.0
function code(x, y, z, t) return -2.0 end
function tmp = code(x, y, z, t) tmp = -2.0; end
code[x_, y_, z_, t_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 89.7%
Taylor expanded in t around 0 99.6%
associate--l+99.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 66.2%
associate--l+66.2%
associate-*r/66.2%
metadata-eval66.2%
associate-*r/66.2%
metadata-eval66.2%
sub-neg66.2%
associate-/r*66.2%
metadata-eval66.2%
Simplified66.2%
Taylor expanded in t around inf 20.7%
Final simplification20.7%
(FPCore (x y z t) :precision binary64 (- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y))))
double code(double x, double y, double z, double t) {
return (((2.0 / z) + 2.0) / t) - (2.0 - (x / 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 = (((2.0d0 / z) + 2.0d0) / t) - (2.0d0 - (x / y))
end function
public static double code(double x, double y, double z, double t) {
return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y));
}
def code(x, y, z, t): return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(2.0 / z) + 2.0) / t) - Float64(2.0 - Float64(x / y))) end
function tmp = code(x, y, z, t) tmp = (((2.0 / z) + 2.0) / t) - (2.0 - (x / y)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(2.0 / z), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision] - N[(2.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right)
\end{array}
herbie shell --seed 2023274
(FPCore (x y z t)
:name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
:precision binary64
:herbie-target
(- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y)))
(+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))