
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cosh x) (/ y x))))
(if (or (<= t_0 -4e+266) (not (<= t_0 1e+117)))
(/ (/ (* (cosh x) y) z) x)
(/ (+ (/ y x) (* 0.5 (* x y))) z))))
double code(double x, double y, double z) {
double t_0 = cosh(x) * (y / x);
double tmp;
if ((t_0 <= -4e+266) || !(t_0 <= 1e+117)) {
tmp = ((cosh(x) * y) / z) / x;
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = cosh(x) * (y / x)
if ((t_0 <= (-4d+266)) .or. (.not. (t_0 <= 1d+117))) then
tmp = ((cosh(x) * y) / z) / x
else
tmp = ((y / x) + (0.5d0 * (x * y))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.cosh(x) * (y / x);
double tmp;
if ((t_0 <= -4e+266) || !(t_0 <= 1e+117)) {
tmp = ((Math.cosh(x) * y) / z) / x;
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
def code(x, y, z): t_0 = math.cosh(x) * (y / x) tmp = 0 if (t_0 <= -4e+266) or not (t_0 <= 1e+117): tmp = ((math.cosh(x) * y) / z) / x else: tmp = ((y / x) + (0.5 * (x * y))) / z return tmp
function code(x, y, z) t_0 = Float64(cosh(x) * Float64(y / x)) tmp = 0.0 if ((t_0 <= -4e+266) || !(t_0 <= 1e+117)) tmp = Float64(Float64(Float64(cosh(x) * y) / z) / x); else tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = cosh(x) * (y / x); tmp = 0.0; if ((t_0 <= -4e+266) || ~((t_0 <= 1e+117))) tmp = ((cosh(x) * y) / z) / x; else tmp = ((y / x) + (0.5 * (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+266], N[Not[LessEqual[t$95$0, 1e+117]], $MachinePrecision]], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{x}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{+266} \lor \neg \left(t_0 \leq 10^{+117}\right):\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\end{array}
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 y x)) < -4.0000000000000001e266 or 1.00000000000000005e117 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 78.3%
associate-*r/67.7%
associate-/r*76.8%
Simplified76.8%
associate-*r/82.0%
*-commutative82.0%
associate-/r*99.9%
Applied egg-rr99.9%
if -4.0000000000000001e266 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 1.00000000000000005e117Initial program 99.9%
Taylor expanded in x around 0 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cosh x) (/ y x))))
(if (or (<= t_0 -4e+266) (not (<= t_0 1e+295)))
(* (/ (cosh x) x) (/ y z))
(/ (+ (/ y x) (* 0.5 (* x y))) z))))
double code(double x, double y, double z) {
double t_0 = cosh(x) * (y / x);
double tmp;
if ((t_0 <= -4e+266) || !(t_0 <= 1e+295)) {
tmp = (cosh(x) / x) * (y / z);
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = cosh(x) * (y / x)
if ((t_0 <= (-4d+266)) .or. (.not. (t_0 <= 1d+295))) then
tmp = (cosh(x) / x) * (y / z)
else
tmp = ((y / x) + (0.5d0 * (x * y))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.cosh(x) * (y / x);
double tmp;
if ((t_0 <= -4e+266) || !(t_0 <= 1e+295)) {
tmp = (Math.cosh(x) / x) * (y / z);
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
def code(x, y, z): t_0 = math.cosh(x) * (y / x) tmp = 0 if (t_0 <= -4e+266) or not (t_0 <= 1e+295): tmp = (math.cosh(x) / x) * (y / z) else: tmp = ((y / x) + (0.5 * (x * y))) / z return tmp
function code(x, y, z) t_0 = Float64(cosh(x) * Float64(y / x)) tmp = 0.0 if ((t_0 <= -4e+266) || !(t_0 <= 1e+295)) tmp = Float64(Float64(cosh(x) / x) * Float64(y / z)); else tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = cosh(x) * (y / x); tmp = 0.0; if ((t_0 <= -4e+266) || ~((t_0 <= 1e+295))) tmp = (cosh(x) / x) * (y / z); else tmp = ((y / x) + (0.5 * (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+266], N[Not[LessEqual[t$95$0, 1e+295]], $MachinePrecision]], N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{x}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{+266} \lor \neg \left(t_0 \leq 10^{+295}\right):\\
\;\;\;\;\frac{\cosh x}{x} \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\end{array}
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 y x)) < -4.0000000000000001e266 or 9.9999999999999998e294 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 76.3%
associate-/l*64.8%
Simplified64.8%
associate-/r/76.3%
frac-times80.4%
*-commutative80.4%
times-frac92.5%
Applied egg-rr92.5%
if -4.0000000000000001e266 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 9.9999999999999998e294Initial program 99.9%
Taylor expanded in x around 0 99.9%
Final simplification94.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.22e+242) (not (<= x 9e+223))) (* 0.5 (/ (* x y) z)) (* (cosh x) (/ y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.22e+242) || !(x <= 9e+223)) {
tmp = 0.5 * ((x * y) / z);
} else {
tmp = cosh(x) * (y / (x * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.22d+242)) .or. (.not. (x <= 9d+223))) then
tmp = 0.5d0 * ((x * y) / z)
else
tmp = cosh(x) * (y / (x * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.22e+242) || !(x <= 9e+223)) {
tmp = 0.5 * ((x * y) / z);
} else {
tmp = Math.cosh(x) * (y / (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.22e+242) or not (x <= 9e+223): tmp = 0.5 * ((x * y) / z) else: tmp = math.cosh(x) * (y / (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.22e+242) || !(x <= 9e+223)) tmp = Float64(0.5 * Float64(Float64(x * y) / z)); else tmp = Float64(cosh(x) * Float64(y / Float64(x * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.22e+242) || ~((x <= 9e+223))) tmp = 0.5 * ((x * y) / z); else tmp = cosh(x) * (y / (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.22e+242], N[Not[LessEqual[x, 9e+223]], $MachinePrecision]], N[(0.5 * N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[Cosh[x], $MachinePrecision] * N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22 \cdot 10^{+242} \lor \neg \left(x \leq 9 \cdot 10^{+223}\right):\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\
\end{array}
\end{array}
if x < -1.2199999999999999e242 or 9e223 < x Initial program 70.7%
Taylor expanded in x around 0 71.9%
Taylor expanded in x around inf 71.9%
if -1.2199999999999999e242 < x < 9e223Initial program 86.3%
associate-*r/81.7%
associate-/r*87.8%
Simplified87.8%
Final simplification85.3%
(FPCore (x y z) :precision binary64 (if (<= y 200000000000.0) (/ (- y) (/ z (+ (* x -0.5) (/ -1.0 x)))) (/ (+ (/ y x) (* 0.5 (* x y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 200000000000.0) {
tmp = -y / (z / ((x * -0.5) + (-1.0 / x)));
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 200000000000.0d0) then
tmp = -y / (z / ((x * (-0.5d0)) + ((-1.0d0) / x)))
else
tmp = ((y / x) + (0.5d0 * (x * y))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 200000000000.0) {
tmp = -y / (z / ((x * -0.5) + (-1.0 / x)));
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 200000000000.0: tmp = -y / (z / ((x * -0.5) + (-1.0 / x))) else: tmp = ((y / x) + (0.5 * (x * y))) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 200000000000.0) tmp = Float64(Float64(-y) / Float64(z / Float64(Float64(x * -0.5) + Float64(-1.0 / x)))); else tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 200000000000.0) tmp = -y / (z / ((x * -0.5) + (-1.0 / x))); else tmp = ((y / x) + (0.5 * (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 200000000000.0], N[((-y) / N[(z / N[(N[(x * -0.5), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 200000000000:\\
\;\;\;\;\frac{-y}{\frac{z}{x \cdot -0.5 + \frac{-1}{x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\end{array}
\end{array}
if y < 2e11Initial program 79.2%
Taylor expanded in x around 0 59.1%
Taylor expanded in y around -inf 59.0%
mul-1-neg59.0%
associate-/l*65.9%
*-commutative65.9%
Simplified65.9%
if 2e11 < y Initial program 97.1%
Taylor expanded in x around 0 88.6%
Final simplification71.7%
(FPCore (x y z) :precision binary64 (if (<= x -6.2e-72) (/ (+ (/ y x) (* 0.5 (* x y))) z) (if (<= x 1.4) (* y (/ (/ 1.0 z) x)) (* y (/ x (/ z 0.5))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.2e-72) {
tmp = ((y / x) + (0.5 * (x * y))) / z;
} else if (x <= 1.4) {
tmp = y * ((1.0 / z) / x);
} else {
tmp = y * (x / (z / 0.5));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-6.2d-72)) then
tmp = ((y / x) + (0.5d0 * (x * y))) / z
else if (x <= 1.4d0) then
tmp = y * ((1.0d0 / z) / x)
else
tmp = y * (x / (z / 0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -6.2e-72) {
tmp = ((y / x) + (0.5 * (x * y))) / z;
} else if (x <= 1.4) {
tmp = y * ((1.0 / z) / x);
} else {
tmp = y * (x / (z / 0.5));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.2e-72: tmp = ((y / x) + (0.5 * (x * y))) / z elif x <= 1.4: tmp = y * ((1.0 / z) / x) else: tmp = y * (x / (z / 0.5)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.2e-72) tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z); elseif (x <= 1.4) tmp = Float64(y * Float64(Float64(1.0 / z) / x)); else tmp = Float64(y * Float64(x / Float64(z / 0.5))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6.2e-72) tmp = ((y / x) + (0.5 * (x * y))) / z; elseif (x <= 1.4) tmp = y * ((1.0 / z) / x); else tmp = y * (x / (z / 0.5)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.2e-72], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 1.4], N[(y * N[(N[(1.0 / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / N[(z / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-72}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;y \cdot \frac{\frac{1}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{\frac{z}{0.5}}\\
\end{array}
\end{array}
if x < -6.1999999999999996e-72Initial program 84.5%
Taylor expanded in x around 0 54.0%
if -6.1999999999999996e-72 < x < 1.3999999999999999Initial program 90.0%
associate-*r/90.0%
associate-/r*97.2%
Simplified97.2%
Taylor expanded in x around 0 97.1%
clear-num95.8%
associate-/r/97.1%
*-commutative97.1%
associate-/r*97.1%
Applied egg-rr97.1%
if 1.3999999999999999 < x Initial program 72.3%
Taylor expanded in x around 0 40.9%
Taylor expanded in x around inf 40.9%
expm1-log1p-u23.2%
expm1-udef23.1%
associate-*r/23.1%
*-commutative23.1%
associate-*r*23.1%
Applied egg-rr23.1%
expm1-def23.2%
expm1-log1p40.9%
*-commutative40.9%
associate-*r*40.9%
*-commutative40.9%
associate-*l/42.4%
*-commutative42.4%
*-commutative42.4%
associate-/l*42.4%
Simplified42.4%
Final simplification70.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.45) (not (<= x 1.4))) (* 0.5 (* x (/ y z))) (/ y (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.45) || !(x <= 1.4)) {
tmp = 0.5 * (x * (y / z));
} else {
tmp = y / (x * z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.45d0)) .or. (.not. (x <= 1.4d0))) then
tmp = 0.5d0 * (x * (y / z))
else
tmp = y / (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.45) || !(x <= 1.4)) {
tmp = 0.5 * (x * (y / z));
} else {
tmp = y / (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.45) or not (x <= 1.4): tmp = 0.5 * (x * (y / z)) else: tmp = y / (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.45) || !(x <= 1.4)) tmp = Float64(0.5 * Float64(x * Float64(y / z))); else tmp = Float64(y / Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.45) || ~((x <= 1.4))) tmp = 0.5 * (x * (y / z)); else tmp = y / (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.45], N[Not[LessEqual[x, 1.4]], $MachinePrecision]], N[(0.5 * N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \lor \neg \left(x \leq 1.4\right):\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\end{array}
\end{array}
if x < -1.44999999999999996 or 1.3999999999999999 < x Initial program 77.3%
Taylor expanded in x around 0 43.0%
Taylor expanded in x around inf 43.0%
*-un-lft-identity43.0%
times-frac32.0%
/-rgt-identity32.0%
Applied egg-rr32.0%
if -1.44999999999999996 < x < 1.3999999999999999Initial program 90.3%
associate-*r/90.3%
associate-/r*96.8%
Simplified96.8%
Taylor expanded in x around 0 96.7%
Final simplification64.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.45) (not (<= x 1.4))) (* 0.5 (/ (* x y) z)) (/ y (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.45) || !(x <= 1.4)) {
tmp = 0.5 * ((x * y) / z);
} else {
tmp = y / (x * z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.45d0)) .or. (.not. (x <= 1.4d0))) then
tmp = 0.5d0 * ((x * y) / z)
else
tmp = y / (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.45) || !(x <= 1.4)) {
tmp = 0.5 * ((x * y) / z);
} else {
tmp = y / (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.45) or not (x <= 1.4): tmp = 0.5 * ((x * y) / z) else: tmp = y / (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.45) || !(x <= 1.4)) tmp = Float64(0.5 * Float64(Float64(x * y) / z)); else tmp = Float64(y / Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.45) || ~((x <= 1.4))) tmp = 0.5 * ((x * y) / z); else tmp = y / (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.45], N[Not[LessEqual[x, 1.4]], $MachinePrecision]], N[(0.5 * N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \lor \neg \left(x \leq 1.4\right):\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\end{array}
\end{array}
if x < -1.44999999999999996 or 1.3999999999999999 < x Initial program 77.3%
Taylor expanded in x around 0 43.0%
Taylor expanded in x around inf 43.0%
if -1.44999999999999996 < x < 1.3999999999999999Initial program 90.3%
associate-*r/90.3%
associate-/r*96.8%
Simplified96.8%
Taylor expanded in x around 0 96.7%
Final simplification69.9%
(FPCore (x y z) :precision binary64 (if (<= x -1.45) (* 0.5 (/ (* x y) z)) (if (<= x 1.4) (/ y (* x z)) (* y (/ x (/ z 0.5))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.45) {
tmp = 0.5 * ((x * y) / z);
} else if (x <= 1.4) {
tmp = y / (x * z);
} else {
tmp = y * (x / (z / 0.5));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.45d0)) then
tmp = 0.5d0 * ((x * y) / z)
else if (x <= 1.4d0) then
tmp = y / (x * z)
else
tmp = y * (x / (z / 0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.45) {
tmp = 0.5 * ((x * y) / z);
} else if (x <= 1.4) {
tmp = y / (x * z);
} else {
tmp = y * (x / (z / 0.5));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.45: tmp = 0.5 * ((x * y) / z) elif x <= 1.4: tmp = y / (x * z) else: tmp = y * (x / (z / 0.5)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.45) tmp = Float64(0.5 * Float64(Float64(x * y) / z)); elseif (x <= 1.4) tmp = Float64(y / Float64(x * z)); else tmp = Float64(y * Float64(x / Float64(z / 0.5))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.45) tmp = 0.5 * ((x * y) / z); elseif (x <= 1.4) tmp = y / (x * z); else tmp = y * (x / (z / 0.5)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.45], N[(0.5 * N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / N[(z / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{z}\\
\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{\frac{z}{0.5}}\\
\end{array}
\end{array}
if x < -1.44999999999999996Initial program 82.5%
Taylor expanded in x around 0 45.2%
Taylor expanded in x around inf 45.2%
if -1.44999999999999996 < x < 1.3999999999999999Initial program 90.3%
associate-*r/90.3%
associate-/r*96.8%
Simplified96.8%
Taylor expanded in x around 0 96.7%
if 1.3999999999999999 < x Initial program 72.3%
Taylor expanded in x around 0 40.9%
Taylor expanded in x around inf 40.9%
expm1-log1p-u23.2%
expm1-udef23.1%
associate-*r/23.1%
*-commutative23.1%
associate-*r*23.1%
Applied egg-rr23.1%
expm1-def23.2%
expm1-log1p40.9%
*-commutative40.9%
associate-*r*40.9%
*-commutative40.9%
associate-*l/42.4%
*-commutative42.4%
*-commutative42.4%
associate-/l*42.4%
Simplified42.4%
Final simplification70.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.45) (* 0.5 (/ (* x y) z)) (if (<= x 1.4) (* y (/ (/ 1.0 z) x)) (* y (/ x (/ z 0.5))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.45) {
tmp = 0.5 * ((x * y) / z);
} else if (x <= 1.4) {
tmp = y * ((1.0 / z) / x);
} else {
tmp = y * (x / (z / 0.5));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.45d0)) then
tmp = 0.5d0 * ((x * y) / z)
else if (x <= 1.4d0) then
tmp = y * ((1.0d0 / z) / x)
else
tmp = y * (x / (z / 0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.45) {
tmp = 0.5 * ((x * y) / z);
} else if (x <= 1.4) {
tmp = y * ((1.0 / z) / x);
} else {
tmp = y * (x / (z / 0.5));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.45: tmp = 0.5 * ((x * y) / z) elif x <= 1.4: tmp = y * ((1.0 / z) / x) else: tmp = y * (x / (z / 0.5)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.45) tmp = Float64(0.5 * Float64(Float64(x * y) / z)); elseif (x <= 1.4) tmp = Float64(y * Float64(Float64(1.0 / z) / x)); else tmp = Float64(y * Float64(x / Float64(z / 0.5))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.45) tmp = 0.5 * ((x * y) / z); elseif (x <= 1.4) tmp = y * ((1.0 / z) / x); else tmp = y * (x / (z / 0.5)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.45], N[(0.5 * N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4], N[(y * N[(N[(1.0 / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / N[(z / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{z}\\
\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;y \cdot \frac{\frac{1}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{\frac{z}{0.5}}\\
\end{array}
\end{array}
if x < -1.44999999999999996Initial program 82.5%
Taylor expanded in x around 0 45.2%
Taylor expanded in x around inf 45.2%
if -1.44999999999999996 < x < 1.3999999999999999Initial program 90.3%
associate-*r/90.3%
associate-/r*96.8%
Simplified96.8%
Taylor expanded in x around 0 96.7%
clear-num95.5%
associate-/r/96.6%
*-commutative96.6%
associate-/r*96.7%
Applied egg-rr96.7%
if 1.3999999999999999 < x Initial program 72.3%
Taylor expanded in x around 0 40.9%
Taylor expanded in x around inf 40.9%
expm1-log1p-u23.2%
expm1-udef23.1%
associate-*r/23.1%
*-commutative23.1%
associate-*r*23.1%
Applied egg-rr23.1%
expm1-def23.2%
expm1-log1p40.9%
*-commutative40.9%
associate-*r*40.9%
*-commutative40.9%
associate-*l/42.4%
*-commutative42.4%
*-commutative42.4%
associate-/l*42.4%
Simplified42.4%
Final simplification70.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.9e+30) (/ y (* x z)) (/ (/ y z) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.9e+30) {
tmp = y / (x * z);
} else {
tmp = (y / z) / x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.9d+30)) then
tmp = y / (x * z)
else
tmp = (y / z) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.9e+30) {
tmp = y / (x * z);
} else {
tmp = (y / z) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.9e+30: tmp = y / (x * z) else: tmp = (y / z) / x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.9e+30) tmp = Float64(y / Float64(x * z)); else tmp = Float64(Float64(y / z) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.9e+30) tmp = y / (x * z); else tmp = (y / z) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.9e+30], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+30}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\end{array}
\end{array}
if z < -1.9000000000000001e30Initial program 84.8%
associate-*r/67.6%
associate-/r*72.2%
Simplified72.2%
Taylor expanded in x around 0 55.7%
if -1.9000000000000001e30 < z Initial program 83.6%
associate-*r/78.5%
associate-/r*83.8%
Simplified83.8%
associate-*r/87.9%
*-commutative87.9%
associate-/r*98.5%
Applied egg-rr98.5%
Taylor expanded in x around 0 55.2%
Final simplification55.3%
(FPCore (x y z) :precision binary64 (/ y (* x z)))
double code(double x, double y, double z) {
return y / (x * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y / (x * z)
end function
public static double code(double x, double y, double z) {
return y / (x * z);
}
def code(x, y, z): return y / (x * z)
function code(x, y, z) return Float64(y / Float64(x * z)) end
function tmp = code(x, y, z) tmp = y / (x * z); end
code[x_, y_, z_] := N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{x \cdot z}
\end{array}
Initial program 83.8%
associate-*r/76.0%
associate-/r*81.2%
Simplified81.2%
Taylor expanded in x around 0 50.4%
Final simplification50.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (/ y z) x) (cosh x))))
(if (< y -4.618902267687042e-52)
t_0
(if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y / z) / x) * cosh(x);
double tmp;
if (y < -4.618902267687042e-52) {
tmp = t_0;
} else if (y < 1.038530535935153e-39) {
tmp = ((cosh(x) * y) / x) / z;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y / z) / x) * cosh(x)
if (y < (-4.618902267687042d-52)) then
tmp = t_0
else if (y < 1.038530535935153d-39) then
tmp = ((cosh(x) * y) / x) / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y / z) / x) * Math.cosh(x);
double tmp;
if (y < -4.618902267687042e-52) {
tmp = t_0;
} else if (y < 1.038530535935153e-39) {
tmp = ((Math.cosh(x) * y) / x) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y / z) / x) * math.cosh(x) tmp = 0 if y < -4.618902267687042e-52: tmp = t_0 elif y < 1.038530535935153e-39: tmp = ((math.cosh(x) * y) / x) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y / z) / x) * cosh(x)) tmp = 0.0 if (y < -4.618902267687042e-52) tmp = t_0; elseif (y < 1.038530535935153e-39) tmp = Float64(Float64(Float64(cosh(x) * y) / x) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y / z) / x) * cosh(x); tmp = 0.0; if (y < -4.618902267687042e-52) tmp = t_0; elseif (y < 1.038530535935153e-39) tmp = ((cosh(x) * y) / x) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision]}, If[Less[y, -4.618902267687042e-52], t$95$0, If[Less[y, 1.038530535935153e-39], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{y}{z}}{x} \cdot \cosh x\\
\mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 1.038530535935153 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023285
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))
(/ (* (cosh x) (/ y x)) z))