
(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 13 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)) z)))
(if (or (<= t_0 -2e-104) (not (<= t_0 5e+302)))
(* y (/ (/ (cosh x) z) x))
t_0)))
double code(double x, double y, double z) {
double t_0 = (cosh(x) * (y / x)) / z;
double tmp;
if ((t_0 <= -2e-104) || !(t_0 <= 5e+302)) {
tmp = y * ((cosh(x) / z) / x);
} 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 = (cosh(x) * (y / x)) / z
if ((t_0 <= (-2d-104)) .or. (.not. (t_0 <= 5d+302))) then
tmp = y * ((cosh(x) / z) / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (Math.cosh(x) * (y / x)) / z;
double tmp;
if ((t_0 <= -2e-104) || !(t_0 <= 5e+302)) {
tmp = y * ((Math.cosh(x) / z) / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (math.cosh(x) * (y / x)) / z tmp = 0 if (t_0 <= -2e-104) or not (t_0 <= 5e+302): tmp = y * ((math.cosh(x) / z) / x) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(cosh(x) * Float64(y / x)) / z) tmp = 0.0 if ((t_0 <= -2e-104) || !(t_0 <= 5e+302)) tmp = Float64(y * Float64(Float64(cosh(x) / z) / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (cosh(x) * (y / x)) / z; tmp = 0.0; if ((t_0 <= -2e-104) || ~((t_0 <= 5e+302))) tmp = y * ((cosh(x) / z) / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e-104], N[Not[LessEqual[t$95$0, 5e+302]], $MachinePrecision]], N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{-104} \lor \neg \left(t_0 \leq 5 \cdot 10^{+302}\right):\\
\;\;\;\;y \cdot \frac{\frac{\cosh x}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -1.99999999999999985e-104 or 5e302 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 80.6%
associate-*r/73.7%
associate-/r*80.7%
Simplified80.7%
associate-/r*73.7%
associate-*r/80.6%
associate-/l*72.7%
add-log-exp61.8%
*-un-lft-identity61.8%
log-prod61.8%
metadata-eval61.8%
add-log-exp72.7%
associate-/l*80.6%
associate-*r/73.7%
Applied egg-rr73.7%
+-lft-identity73.7%
associate-*r/80.6%
associate-*l/80.6%
associate-*r/99.4%
*-commutative99.4%
associate-*r/99.9%
Simplified99.9%
if -1.99999999999999985e-104 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 5e302Initial program 99.6%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (* y (/ (/ (cosh x) z) x)))
double code(double x, double y, double z) {
return y * ((cosh(x) / z) / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * ((cosh(x) / z) / x)
end function
public static double code(double x, double y, double z) {
return y * ((Math.cosh(x) / z) / x);
}
def code(x, y, z): return y * ((math.cosh(x) / z) / x)
function code(x, y, z) return Float64(y * Float64(Float64(cosh(x) / z) / x)) end
function tmp = code(x, y, z) tmp = y * ((cosh(x) / z) / x); end
code[x_, y_, z_] := N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{\frac{\cosh x}{z}}{x}
\end{array}
Initial program 84.5%
associate-*r/79.1%
associate-/r*81.6%
Simplified81.6%
associate-/r*79.1%
associate-*r/84.5%
associate-/l*77.6%
add-log-exp51.7%
*-un-lft-identity51.7%
log-prod51.7%
metadata-eval51.7%
add-log-exp77.6%
associate-/l*84.5%
associate-*r/79.1%
Applied egg-rr79.1%
+-lft-identity79.1%
associate-*r/84.5%
associate-*l/84.5%
associate-*r/93.8%
*-commutative93.8%
associate-*r/96.6%
Simplified96.6%
Final simplification96.6%
(FPCore (x y z) :precision binary64 (if (<= x -390.0) (/ (* z (+ y (* 0.5 (* y (* x x))))) (* x (* z z))) (+ (* y (* x (/ 0.5 z))) (/ y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -390.0) {
tmp = (z * (y + (0.5 * (y * (x * x))))) / (x * (z * z));
} else {
tmp = (y * (x * (0.5 / z))) + (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 <= (-390.0d0)) then
tmp = (z * (y + (0.5d0 * (y * (x * x))))) / (x * (z * z))
else
tmp = (y * (x * (0.5d0 / z))) + (y / (x * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -390.0) {
tmp = (z * (y + (0.5 * (y * (x * x))))) / (x * (z * z));
} else {
tmp = (y * (x * (0.5 / z))) + (y / (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -390.0: tmp = (z * (y + (0.5 * (y * (x * x))))) / (x * (z * z)) else: tmp = (y * (x * (0.5 / z))) + (y / (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -390.0) tmp = Float64(Float64(z * Float64(y + Float64(0.5 * Float64(y * Float64(x * x))))) / Float64(x * Float64(z * z))); else tmp = Float64(Float64(y * Float64(x * Float64(0.5 / z))) + Float64(y / Float64(x * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -390.0) tmp = (z * (y + (0.5 * (y * (x * x))))) / (x * (z * z)); else tmp = (y * (x * (0.5 / z))) + (y / (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -390.0], N[(N[(z * N[(y + N[(0.5 * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -390:\\
\;\;\;\;\frac{z \cdot \left(y + 0.5 \cdot \left(y \cdot \left(x \cdot x\right)\right)\right)}{x \cdot \left(z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{0.5}{z}\right) + \frac{y}{x \cdot z}\\
\end{array}
\end{array}
if x < -390Initial program 74.6%
associate-*r/64.8%
associate-/r*69.0%
Simplified69.0%
Taylor expanded in x around 0 41.8%
associate-*r/41.8%
frac-add46.1%
*-commutative46.1%
*-commutative46.1%
Applied egg-rr46.1%
+-commutative46.1%
*-commutative46.1%
associate-*r*47.4%
distribute-rgt-out47.4%
*-commutative47.4%
associate-*l*47.4%
*-commutative47.4%
associate-*r*47.4%
*-commutative47.4%
associate-*r*54.1%
*-commutative54.1%
associate-*l*54.1%
Simplified54.1%
if -390 < x Initial program 88.3%
associate-*r/84.5%
associate-/r*86.5%
Simplified86.5%
Taylor expanded in x around 0 80.0%
div-inv80.0%
*-commutative80.0%
associate-*l*82.0%
Applied egg-rr82.0%
Taylor expanded in y around 0 80.0%
associate-*l/82.0%
associate-*r*82.0%
*-commutative82.0%
associate-*r/82.0%
associate-*l/82.0%
*-commutative82.0%
Simplified82.0%
Final simplification74.2%
(FPCore (x y z) :precision binary64 (if (<= z -1.95e-134) (/ (+ (/ y x) (* 0.5 (* x y))) z) (+ (/ y (* x z)) (* 0.5 (/ y (/ z x))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.95e-134) {
tmp = ((y / x) + (0.5 * (x * y))) / z;
} else {
tmp = (y / (x * z)) + (0.5 * (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.95d-134)) then
tmp = ((y / x) + (0.5d0 * (x * y))) / z
else
tmp = (y / (x * z)) + (0.5d0 * (y / (z / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.95e-134) {
tmp = ((y / x) + (0.5 * (x * y))) / z;
} else {
tmp = (y / (x * z)) + (0.5 * (y / (z / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.95e-134: tmp = ((y / x) + (0.5 * (x * y))) / z else: tmp = (y / (x * z)) + (0.5 * (y / (z / x))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.95e-134) tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z); else tmp = Float64(Float64(y / Float64(x * z)) + Float64(0.5 * Float64(y / Float64(z / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.95e-134) tmp = ((y / x) + (0.5 * (x * y))) / z; else tmp = (y / (x * z)) + (0.5 * (y / (z / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.95e-134], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-134}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if z < -1.95e-134Initial program 88.3%
associate-*r/80.9%
associate-/r*77.7%
Simplified77.7%
Taylor expanded in x around 0 67.1%
Taylor expanded in z around 0 67.1%
if -1.95e-134 < z Initial program 82.3%
associate-*r/78.0%
associate-/r*83.9%
Simplified83.9%
Taylor expanded in x around 0 70.7%
div-inv70.7%
*-commutative70.7%
associate-*l*77.7%
Applied egg-rr77.7%
associate-*r*70.7%
div-inv70.7%
associate-/l*77.7%
Applied egg-rr77.7%
Final simplification73.8%
(FPCore (x y z) :precision binary64 (if (<= z -2e-63) (+ (/ y (* x z)) (* 0.5 (/ (* x y) z))) (* y (+ (* 0.5 (/ x z)) (/ 1.0 (* x z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e-63) {
tmp = (y / (x * z)) + (0.5 * ((x * y) / z));
} else {
tmp = y * ((0.5 * (x / z)) + (1.0 / (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 (z <= (-2d-63)) then
tmp = (y / (x * z)) + (0.5d0 * ((x * y) / z))
else
tmp = y * ((0.5d0 * (x / z)) + (1.0d0 / (x * z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2e-63) {
tmp = (y / (x * z)) + (0.5 * ((x * y) / z));
} else {
tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e-63: tmp = (y / (x * z)) + (0.5 * ((x * y) / z)) else: tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e-63) tmp = Float64(Float64(y / Float64(x * z)) + Float64(0.5 * Float64(Float64(x * y) / z))); else tmp = Float64(y * Float64(Float64(0.5 * Float64(x / z)) + Float64(1.0 / Float64(x * z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e-63) tmp = (y / (x * z)) + (0.5 * ((x * y) / z)); else tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e-63], N[(N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-63}:\\
\;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{z} + \frac{1}{x \cdot z}\right)\\
\end{array}
\end{array}
if z < -2.00000000000000013e-63Initial program 88.9%
associate-*r/80.3%
associate-/r*77.6%
Simplified77.6%
Taylor expanded in x around 0 67.6%
if -2.00000000000000013e-63 < z Initial program 82.5%
associate-*r/78.5%
associate-/r*83.5%
Simplified83.5%
associate-/r*78.5%
associate-*r/82.5%
associate-/l*77.5%
add-log-exp53.3%
*-un-lft-identity53.3%
log-prod53.3%
metadata-eval53.3%
add-log-exp77.5%
associate-/l*82.5%
associate-*r/78.5%
Applied egg-rr78.5%
+-lft-identity78.5%
associate-*r/82.5%
associate-*l/82.5%
associate-*r/93.2%
*-commutative93.2%
associate-*r/95.1%
Simplified95.1%
Taylor expanded in x around 0 76.8%
Final simplification73.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (* x z))))
(if (<= z -2e+78)
(+ t_0 (* 0.5 (/ (* x y) z)))
(+ (* y (* x (/ 0.5 z))) t_0))))
double code(double x, double y, double z) {
double t_0 = y / (x * z);
double tmp;
if (z <= -2e+78) {
tmp = t_0 + (0.5 * ((x * y) / z));
} else {
tmp = (y * (x * (0.5 / z))) + 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 / (x * z)
if (z <= (-2d+78)) then
tmp = t_0 + (0.5d0 * ((x * y) / z))
else
tmp = (y * (x * (0.5d0 / z))) + t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (x * z);
double tmp;
if (z <= -2e+78) {
tmp = t_0 + (0.5 * ((x * y) / z));
} else {
tmp = (y * (x * (0.5 / z))) + t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (x * z) tmp = 0 if z <= -2e+78: tmp = t_0 + (0.5 * ((x * y) / z)) else: tmp = (y * (x * (0.5 / z))) + t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(x * z)) tmp = 0.0 if (z <= -2e+78) tmp = Float64(t_0 + Float64(0.5 * Float64(Float64(x * y) / z))); else tmp = Float64(Float64(y * Float64(x * Float64(0.5 / z))) + t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (x * z); tmp = 0.0; if (z <= -2e+78) tmp = t_0 + (0.5 * ((x * y) / z)); else tmp = (y * (x * (0.5 / z))) + t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2e+78], N[(t$95$0 + N[(0.5 * N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x \cdot z}\\
\mathbf{if}\;z \leq -2 \cdot 10^{+78}:\\
\;\;\;\;t_0 + 0.5 \cdot \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \frac{0.5}{z}\right) + t_0\\
\end{array}
\end{array}
if z < -2.00000000000000002e78Initial program 79.7%
associate-*r/63.8%
associate-/r*61.1%
Simplified61.1%
Taylor expanded in x around 0 64.3%
if -2.00000000000000002e78 < z Initial program 85.5%
associate-*r/82.2%
associate-/r*85.9%
Simplified85.9%
Taylor expanded in x around 0 70.4%
div-inv70.4%
*-commutative70.4%
associate-*l*76.2%
Applied egg-rr76.2%
Taylor expanded in y around 0 70.4%
associate-*l/76.2%
associate-*r*76.2%
*-commutative76.2%
associate-*r/76.2%
associate-*l/76.2%
*-commutative76.2%
Simplified76.2%
Final simplification74.2%
(FPCore (x y z) :precision binary64 (if (<= x -8e+101) (* 0.5 (* y (/ x z))) (/ (* y (+ (* x 0.5) (/ 1.0 x))) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= -8e+101) {
tmp = 0.5 * (y * (x / z));
} else {
tmp = (y * ((x * 0.5) + (1.0 / 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 <= (-8d+101)) then
tmp = 0.5d0 * (y * (x / z))
else
tmp = (y * ((x * 0.5d0) + (1.0d0 / x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -8e+101) {
tmp = 0.5 * (y * (x / z));
} else {
tmp = (y * ((x * 0.5) + (1.0 / x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -8e+101: tmp = 0.5 * (y * (x / z)) else: tmp = (y * ((x * 0.5) + (1.0 / x))) / z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -8e+101) tmp = Float64(0.5 * Float64(y * Float64(x / z))); else tmp = Float64(Float64(y * Float64(Float64(x * 0.5) + Float64(1.0 / x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -8e+101) tmp = 0.5 * (y * (x / z)); else tmp = (y * ((x * 0.5) + (1.0 / x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8e+101], N[(0.5 * N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(N[(x * 0.5), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{+101}:\\
\;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)}{z}\\
\end{array}
\end{array}
if x < -7.9999999999999998e101Initial program 66.7%
associate-*r/55.6%
associate-/r*64.4%
Simplified64.4%
Taylor expanded in x around 0 53.1%
Taylor expanded in x around inf 53.1%
associate-*l/65.9%
*-commutative65.9%
Simplified65.9%
if -7.9999999999999998e101 < x Initial program 88.3%
associate-*r/84.1%
associate-/r*85.3%
Simplified85.3%
Taylor expanded in x around 0 72.8%
Taylor expanded in z around 0 71.6%
Taylor expanded in y around 0 71.6%
Final simplification70.6%
(FPCore (x y z) :precision binary64 (if (<= x -7e+102) (* 0.5 (* y (/ x z))) (/ (+ (/ y x) (* 0.5 (* x y))) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= -7e+102) {
tmp = 0.5 * (y * (x / 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) :: tmp
if (x <= (-7d+102)) then
tmp = 0.5d0 * (y * (x / 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 tmp;
if (x <= -7e+102) {
tmp = 0.5 * (y * (x / z));
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7e+102: tmp = 0.5 * (y * (x / z)) else: tmp = ((y / x) + (0.5 * (x * y))) / z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7e+102) tmp = Float64(0.5 * Float64(y * Float64(x / 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) tmp = 0.0; if (x <= -7e+102) tmp = 0.5 * (y * (x / z)); else tmp = ((y / x) + (0.5 * (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7e+102], N[(0.5 * N[(y * N[(x / z), $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}\;x \leq -7 \cdot 10^{+102}:\\
\;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\end{array}
\end{array}
if x < -7.00000000000000021e102Initial program 66.7%
associate-*r/55.6%
associate-/r*64.4%
Simplified64.4%
Taylor expanded in x around 0 53.1%
Taylor expanded in x around inf 53.1%
associate-*l/65.9%
*-commutative65.9%
Simplified65.9%
if -7.00000000000000021e102 < x Initial program 88.3%
associate-*r/84.1%
associate-/r*85.3%
Simplified85.3%
Taylor expanded in x around 0 72.8%
Taylor expanded in z around 0 71.6%
Final simplification70.6%
(FPCore (x y z) :precision binary64 (* y (+ (* 0.5 (/ x z)) (/ 1.0 (* x z)))))
double code(double x, double y, double z) {
return y * ((0.5 * (x / z)) + (1.0 / (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 * ((0.5d0 * (x / z)) + (1.0d0 / (x * z)))
end function
public static double code(double x, double y, double z) {
return y * ((0.5 * (x / z)) + (1.0 / (x * z)));
}
def code(x, y, z): return y * ((0.5 * (x / z)) + (1.0 / (x * z)))
function code(x, y, z) return Float64(y * Float64(Float64(0.5 * Float64(x / z)) + Float64(1.0 / Float64(x * z)))) end
function tmp = code(x, y, z) tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z))); end
code[x_, y_, z_] := N[(y * N[(N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(0.5 \cdot \frac{x}{z} + \frac{1}{x \cdot z}\right)
\end{array}
Initial program 84.5%
associate-*r/79.1%
associate-/r*81.6%
Simplified81.6%
associate-/r*79.1%
associate-*r/84.5%
associate-/l*77.6%
add-log-exp51.7%
*-un-lft-identity51.7%
log-prod51.7%
metadata-eval51.7%
add-log-exp77.6%
associate-/l*84.5%
associate-*r/79.1%
Applied egg-rr79.1%
+-lft-identity79.1%
associate-*r/84.5%
associate-*l/84.5%
associate-*r/93.8%
*-commutative93.8%
associate-*r/96.6%
Simplified96.6%
Taylor expanded in x around 0 72.1%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.5) (not (<= x 1.4))) (* 0.5 (* y (/ x z))) (/ y (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.5) || !(x <= 1.4)) {
tmp = 0.5 * (y * (x / 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 <= (-2.5d0)) .or. (.not. (x <= 1.4d0))) then
tmp = 0.5d0 * (y * (x / 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 <= -2.5) || !(x <= 1.4)) {
tmp = 0.5 * (y * (x / z));
} else {
tmp = y / (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.5) or not (x <= 1.4): tmp = 0.5 * (y * (x / z)) else: tmp = y / (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.5) || !(x <= 1.4)) tmp = Float64(0.5 * Float64(y * Float64(x / z))); else tmp = Float64(y / Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.5) || ~((x <= 1.4))) tmp = 0.5 * (y * (x / z)); else tmp = y / (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.5], N[Not[LessEqual[x, 1.4]], $MachinePrecision]], N[(0.5 * N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \lor \neg \left(x \leq 1.4\right):\\
\;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\end{array}
\end{array}
if x < -2.5 or 1.3999999999999999 < x Initial program 78.0%
associate-*r/67.4%
associate-/r*70.5%
Simplified70.5%
Taylor expanded in x around 0 47.0%
Taylor expanded in x around inf 47.0%
associate-*l/52.8%
*-commutative52.8%
Simplified52.8%
if -2.5 < x < 1.3999999999999999Initial program 91.4%
associate-*r/91.4%
associate-/r*93.5%
Simplified93.5%
Taylor expanded in x around 0 92.7%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (<= y 3.5e-91) (/ (/ y x) z) (/ y (* x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e-91) {
tmp = (y / x) / 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 (y <= 3.5d-91) then
tmp = (y / x) / 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 (y <= 3.5e-91) {
tmp = (y / x) / z;
} else {
tmp = y / (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.5e-91: tmp = (y / x) / z else: tmp = y / (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.5e-91) tmp = Float64(Float64(y / x) / z); else tmp = Float64(y / Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.5e-91) tmp = (y / x) / z; else tmp = y / (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.5e-91], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-91}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\end{array}
\end{array}
if y < 3.4999999999999999e-91Initial program 82.6%
associate-*l/82.5%
Simplified82.5%
Taylor expanded in x around 0 50.0%
associate-*l/50.0%
*-un-lft-identity50.0%
Applied egg-rr50.0%
if 3.4999999999999999e-91 < y Initial program 89.0%
associate-*r/81.2%
associate-/r*84.3%
Simplified84.3%
Taylor expanded in x around 0 48.5%
Final simplification49.6%
(FPCore (x y z) :precision binary64 (if (<= z 3.35e+41) (/ (/ y z) x) (/ y (* x z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 3.35e+41) {
tmp = (y / z) / x;
} 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 (z <= 3.35d+41) then
tmp = (y / z) / x
else
tmp = y / (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 3.35e+41) {
tmp = (y / z) / x;
} else {
tmp = y / (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 3.35e+41: tmp = (y / z) / x else: tmp = y / (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 3.35e+41) tmp = Float64(Float64(y / z) / x); else tmp = Float64(y / Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 3.35e+41) tmp = (y / z) / x; else tmp = y / (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 3.35e+41], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.35 \cdot 10^{+41}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\end{array}
\end{array}
if z < 3.3499999999999998e41Initial program 86.3%
associate-*r/82.8%
associate-/r*85.8%
Simplified85.8%
Taylor expanded in x around 0 44.0%
*-commutative44.0%
associate-/r*52.7%
Simplified52.7%
if 3.3499999999999998e41 < z Initial program 77.7%
associate-*r/64.2%
associate-/r*65.1%
Simplified65.1%
Taylor expanded in x around 0 62.1%
Final simplification54.6%
(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 84.5%
associate-*r/79.1%
associate-/r*81.6%
Simplified81.6%
Taylor expanded in x around 0 47.7%
Final simplification47.7%
(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 2023290
(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))