
(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 12 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 (- INFINITY)) (not (<= t_0 1e+226)))
(* y (/ (/ (cosh x) x) z))
(/ (/ y x) z))))
double code(double x, double y, double z) {
double t_0 = (cosh(x) * (y / x)) / z;
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e+226)) {
tmp = y * ((cosh(x) / x) / z);
} else {
tmp = (y / x) / z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (Math.cosh(x) * (y / x)) / z;
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e+226)) {
tmp = y * ((Math.cosh(x) / x) / z);
} else {
tmp = (y / x) / z;
}
return tmp;
}
def code(x, y, z): t_0 = (math.cosh(x) * (y / x)) / z tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e+226): tmp = y * ((math.cosh(x) / x) / z) else: tmp = (y / x) / z return tmp
function code(x, y, z) t_0 = Float64(Float64(cosh(x) * Float64(y / x)) / z) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e+226)) tmp = Float64(y * Float64(Float64(cosh(x) / x) / z)); else tmp = Float64(Float64(y / x) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (cosh(x) * (y / x)) / z; tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 1e+226))) tmp = y * ((cosh(x) / x) / z); else tmp = (y / x) / z; 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, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+226]], $MachinePrecision]], N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{+226}\right):\\
\;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -inf.0 or 9.99999999999999961e225 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 78.2%
associate-*l/78.2%
Simplified78.2%
associate-/r/65.0%
associate-/l*67.2%
*-commutative67.2%
expm1-log1p-u36.1%
expm1-udef36.1%
associate-/l*41.4%
times-frac48.8%
Applied egg-rr48.8%
expm1-def48.8%
expm1-log1p88.9%
associate-*r/94.1%
*-commutative94.1%
associate-*r/99.9%
Simplified99.9%
if -inf.0 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 9.99999999999999961e225Initial program 99.6%
Taylor expanded in x around 0 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(Float64(Float64(y * cosh(x)) / z) / x) end
function tmp = code(x, y, z) tmp = ((y * cosh(x)) / z) / x; end
code[x_, y_, z_] := N[(N[(N[(y * N[Cosh[x], $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y \cdot \cosh x}{z}}{x}
\end{array}
Initial program 83.8%
associate-*l/83.8%
Simplified83.8%
associate-/r/74.0%
associate-/l*71.1%
*-commutative71.1%
expm1-log1p-u43.4%
expm1-udef35.5%
associate-/l*39.4%
times-frac46.9%
Applied egg-rr46.9%
expm1-def54.0%
expm1-log1p90.8%
associate-*r/95.5%
*-commutative95.5%
associate-*r/94.6%
Simplified94.6%
associate-/r*77.5%
*-commutative77.5%
associate-*l/78.1%
*-commutative78.1%
associate-/r*99.1%
*-commutative99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ (+ 1.0 (* x (* x 0.5))) (* x z)))))
(if (<= x -2.2e-12)
t_0
(if (<= x 1.2e-102)
(/ (/ y z) x)
(if (<= x 2.1e+121)
(/ (+ (/ y x) (* 0.5 (* y x))) z)
(if (<= x 9.5e+237) t_0 (* (* y x) (/ 0.5 z))))))))
double code(double x, double y, double z) {
double t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z));
double tmp;
if (x <= -2.2e-12) {
tmp = t_0;
} else if (x <= 1.2e-102) {
tmp = (y / z) / x;
} else if (x <= 2.1e+121) {
tmp = ((y / x) + (0.5 * (y * x))) / z;
} else if (x <= 9.5e+237) {
tmp = t_0;
} else {
tmp = (y * x) * (0.5 / 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 = y * ((1.0d0 + (x * (x * 0.5d0))) / (x * z))
if (x <= (-2.2d-12)) then
tmp = t_0
else if (x <= 1.2d-102) then
tmp = (y / z) / x
else if (x <= 2.1d+121) then
tmp = ((y / x) + (0.5d0 * (y * x))) / z
else if (x <= 9.5d+237) then
tmp = t_0
else
tmp = (y * x) * (0.5d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z));
double tmp;
if (x <= -2.2e-12) {
tmp = t_0;
} else if (x <= 1.2e-102) {
tmp = (y / z) / x;
} else if (x <= 2.1e+121) {
tmp = ((y / x) + (0.5 * (y * x))) / z;
} else if (x <= 9.5e+237) {
tmp = t_0;
} else {
tmp = (y * x) * (0.5 / z);
}
return tmp;
}
def code(x, y, z): t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z)) tmp = 0 if x <= -2.2e-12: tmp = t_0 elif x <= 1.2e-102: tmp = (y / z) / x elif x <= 2.1e+121: tmp = ((y / x) + (0.5 * (y * x))) / z elif x <= 9.5e+237: tmp = t_0 else: tmp = (y * x) * (0.5 / z) return tmp
function code(x, y, z) t_0 = Float64(y * Float64(Float64(1.0 + Float64(x * Float64(x * 0.5))) / Float64(x * z))) tmp = 0.0 if (x <= -2.2e-12) tmp = t_0; elseif (x <= 1.2e-102) tmp = Float64(Float64(y / z) / x); elseif (x <= 2.1e+121) tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(y * x))) / z); elseif (x <= 9.5e+237) tmp = t_0; else tmp = Float64(Float64(y * x) * Float64(0.5 / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * ((1.0 + (x * (x * 0.5))) / (x * z)); tmp = 0.0; if (x <= -2.2e-12) tmp = t_0; elseif (x <= 1.2e-102) tmp = (y / z) / x; elseif (x <= 2.1e+121) tmp = ((y / x) + (0.5 * (y * x))) / z; elseif (x <= 9.5e+237) tmp = t_0; else tmp = (y * x) * (0.5 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[(1.0 + N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.2e-12], t$95$0, If[LessEqual[x, 1.2e-102], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 2.1e+121], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 9.5e+237], t$95$0, N[(N[(y * x), $MachinePrecision] * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{1 + x \cdot \left(x \cdot 0.5\right)}{x \cdot z}\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{-12}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+121}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+237}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot x\right) \cdot \frac{0.5}{z}\\
\end{array}
\end{array}
if x < -2.19999999999999992e-12 or 2.1000000000000002e121 < x < 9.50000000000000061e237Initial program 73.2%
associate-*l/73.2%
Simplified73.2%
associate-/r/56.7%
associate-/l*58.8%
*-commutative58.8%
expm1-log1p-u31.8%
expm1-udef31.8%
associate-/l*38.0%
times-frac47.3%
Applied egg-rr47.3%
expm1-def47.3%
expm1-log1p85.6%
associate-*r/100.0%
*-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 44.4%
+-commutative44.4%
associate-/l/44.4%
associate-*r/44.4%
frac-add53.4%
*-commutative53.4%
Applied egg-rr53.4%
Taylor expanded in z around 0 53.4%
if -2.19999999999999992e-12 < x < 1.2e-102Initial program 87.0%
associate-*l/86.8%
Simplified86.8%
associate-/r/86.9%
associate-/l*87.4%
*-commutative87.4%
expm1-log1p-u57.0%
expm1-udef42.7%
associate-/l*42.7%
times-frac47.7%
Applied egg-rr47.7%
expm1-def60.6%
expm1-log1p98.3%
associate-*r/86.8%
*-commutative86.8%
associate-*r/85.4%
Simplified85.4%
associate-/r*85.5%
*-commutative85.5%
associate-*l/87.5%
*-commutative87.5%
associate-/r*98.5%
*-commutative98.5%
Applied egg-rr98.5%
Taylor expanded in x around 0 87.5%
associate-/l/98.5%
Simplified98.5%
if 1.2e-102 < x < 2.1000000000000002e121Initial program 98.2%
Taylor expanded in x around 0 56.8%
if 9.50000000000000061e237 < x Initial program 72.7%
Taylor expanded in x around 0 74.3%
Taylor expanded in x around inf 74.3%
associate-*r/74.3%
*-commutative74.3%
Simplified74.3%
associate-/l*74.3%
associate-/r/74.3%
Applied egg-rr74.3%
Final simplification70.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* y x) (/ 0.5 z))))
(if (<= x -65.0)
t_0
(if (<= x 1.4)
(/ (/ y z) x)
(if (or (<= x 1.95e+100) (not (<= x 5.4e+237)))
t_0
(* 0.5 (/ y (/ z x))))))))
double code(double x, double y, double z) {
double t_0 = (y * x) * (0.5 / z);
double tmp;
if (x <= -65.0) {
tmp = t_0;
} else if (x <= 1.4) {
tmp = (y / z) / x;
} else if ((x <= 1.95e+100) || !(x <= 5.4e+237)) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = (y * x) * (0.5d0 / z)
if (x <= (-65.0d0)) then
tmp = t_0
else if (x <= 1.4d0) then
tmp = (y / z) / x
else if ((x <= 1.95d+100) .or. (.not. (x <= 5.4d+237))) then
tmp = t_0
else
tmp = 0.5d0 * (y / (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * x) * (0.5 / z);
double tmp;
if (x <= -65.0) {
tmp = t_0;
} else if (x <= 1.4) {
tmp = (y / z) / x;
} else if ((x <= 1.95e+100) || !(x <= 5.4e+237)) {
tmp = t_0;
} else {
tmp = 0.5 * (y / (z / x));
}
return tmp;
}
def code(x, y, z): t_0 = (y * x) * (0.5 / z) tmp = 0 if x <= -65.0: tmp = t_0 elif x <= 1.4: tmp = (y / z) / x elif (x <= 1.95e+100) or not (x <= 5.4e+237): tmp = t_0 else: tmp = 0.5 * (y / (z / x)) return tmp
function code(x, y, z) t_0 = Float64(Float64(y * x) * Float64(0.5 / z)) tmp = 0.0 if (x <= -65.0) tmp = t_0; elseif (x <= 1.4) tmp = Float64(Float64(y / z) / x); elseif ((x <= 1.95e+100) || !(x <= 5.4e+237)) tmp = t_0; else tmp = Float64(0.5 * Float64(y / Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * x) * (0.5 / z); tmp = 0.0; if (x <= -65.0) tmp = t_0; elseif (x <= 1.4) tmp = (y / z) / x; elseif ((x <= 1.95e+100) || ~((x <= 5.4e+237))) tmp = t_0; else tmp = 0.5 * (y / (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * x), $MachinePrecision] * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -65.0], t$95$0, If[LessEqual[x, 1.4], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision], If[Or[LessEqual[x, 1.95e+100], N[Not[LessEqual[x, 5.4e+237]], $MachinePrecision]], t$95$0, N[(0.5 * N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot x\right) \cdot \frac{0.5}{z}\\
\mathbf{if}\;x \leq -65:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+100} \lor \neg \left(x \leq 5.4 \cdot 10^{+237}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if x < -65 or 1.3999999999999999 < x < 1.95e100 or 5.3999999999999999e237 < x Initial program 81.5%
Taylor expanded in x around 0 40.0%
Taylor expanded in x around inf 40.0%
associate-*r/40.0%
*-commutative40.0%
Simplified40.0%
associate-/l*40.0%
associate-/r/40.0%
Applied egg-rr40.0%
if -65 < x < 1.3999999999999999Initial program 89.8%
associate-*l/89.7%
Simplified89.7%
associate-/r/89.8%
associate-/l*89.3%
*-commutative89.3%
expm1-log1p-u62.5%
expm1-udef44.5%
associate-/l*44.5%
times-frac49.2%
Applied egg-rr49.2%
expm1-def65.3%
expm1-log1p97.7%
associate-*r/89.7%
*-commutative89.7%
associate-*r/87.7%
Simplified87.7%
associate-/r*87.8%
*-commutative87.8%
associate-*l/89.3%
*-commutative89.3%
associate-/r*97.9%
*-commutative97.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 89.3%
associate-/l/97.8%
Simplified97.8%
if 1.95e100 < x < 5.3999999999999999e237Initial program 68.0%
Taylor expanded in x around 0 35.2%
Taylor expanded in x around inf 35.2%
associate-*r/35.2%
*-commutative35.2%
Simplified35.2%
Taylor expanded in y around 0 35.2%
associate-*r/35.2%
*-commutative35.2%
associate-*r/35.2%
associate-/l*54.1%
Simplified54.1%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (if (<= y -2e-123) (* y (+ (* 0.5 (/ x z)) (/ 1.0 (* x z)))) (/ (+ (/ y x) (* 0.5 (* y x))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-123) {
tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z)));
} else {
tmp = ((y / x) + (0.5 * (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 <= (-2d-123)) then
tmp = y * ((0.5d0 * (x / z)) + (1.0d0 / (x * z)))
else
tmp = ((y / x) + (0.5d0 * (y * x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2e-123) {
tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z)));
} else {
tmp = ((y / x) + (0.5 * (y * x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e-123: tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z))) else: tmp = ((y / x) + (0.5 * (y * x))) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e-123) tmp = Float64(y * Float64(Float64(0.5 * Float64(x / z)) + Float64(1.0 / Float64(x * z)))); else tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(y * x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e-123) tmp = y * ((0.5 * (x / z)) + (1.0 / (x * z))); else tmp = ((y / x) + (0.5 * (y * x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e-123], N[(y * N[(N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-123}:\\
\;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{z} + \frac{1}{x \cdot z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\
\end{array}
\end{array}
if y < -2.0000000000000001e-123Initial program 88.0%
associate-*l/88.0%
Simplified88.0%
associate-/r/81.6%
associate-/l*83.9%
*-commutative83.9%
expm1-log1p-u51.2%
expm1-udef44.9%
associate-/l*44.9%
times-frac53.4%
Applied egg-rr53.4%
expm1-def59.7%
expm1-log1p97.7%
associate-*r/89.1%
*-commutative89.1%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in x around 0 72.4%
if -2.0000000000000001e-123 < y Initial program 81.4%
Taylor expanded in x around 0 59.9%
Final simplification64.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -65.0) (not (<= x 6200.0))) (* 0.5 (* x (/ y z))) (/ (/ y z) x)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -65.0) || !(x <= 6200.0)) {
tmp = 0.5 * (x * (y / 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 ((x <= (-65.0d0)) .or. (.not. (x <= 6200.0d0))) then
tmp = 0.5d0 * (x * (y / 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 ((x <= -65.0) || !(x <= 6200.0)) {
tmp = 0.5 * (x * (y / z));
} else {
tmp = (y / z) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -65.0) or not (x <= 6200.0): tmp = 0.5 * (x * (y / z)) else: tmp = (y / z) / x return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -65.0) || !(x <= 6200.0)) tmp = Float64(0.5 * Float64(x * Float64(y / z))); else tmp = Float64(Float64(y / z) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -65.0) || ~((x <= 6200.0))) tmp = 0.5 * (x * (y / z)); else tmp = (y / z) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -65.0], N[Not[LessEqual[x, 6200.0]], $MachinePrecision]], N[(0.5 * N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\end{array}
\end{array}
if x < -65 or 6200 < x Initial program 79.0%
Taylor expanded in x around 0 39.4%
Taylor expanded in x around inf 39.4%
associate-*r/39.4%
*-commutative39.4%
Simplified39.4%
associate-/l*39.4%
div-inv39.4%
Applied egg-rr39.4%
associate-/r*29.5%
associate-/r/29.5%
clear-num29.5%
Applied egg-rr29.5%
if -65 < x < 6200Initial program 89.9%
associate-*l/89.8%
Simplified89.8%
associate-/r/89.0%
associate-/l*88.5%
*-commutative88.5%
expm1-log1p-u62.0%
expm1-udef44.1%
associate-/l*44.1%
times-frac48.7%
Applied egg-rr48.7%
expm1-def64.7%
expm1-log1p96.8%
associate-*r/89.7%
*-commutative89.7%
associate-*r/87.8%
Simplified87.8%
associate-/r*87.9%
*-commutative87.9%
associate-*l/89.4%
*-commutative89.4%
associate-/r*97.9%
*-commutative97.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 88.5%
associate-/l/97.0%
Simplified97.0%
Final simplification59.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -65.0) (not (<= x 6200.0))) (* 0.5 (/ y (/ z x))) (/ (/ y z) x)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -65.0) || !(x <= 6200.0)) {
tmp = 0.5 * (y / (z / x));
} 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 ((x <= (-65.0d0)) .or. (.not. (x <= 6200.0d0))) then
tmp = 0.5d0 * (y / (z / x))
else
tmp = (y / z) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -65.0) || !(x <= 6200.0)) {
tmp = 0.5 * (y / (z / x));
} else {
tmp = (y / z) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -65.0) or not (x <= 6200.0): tmp = 0.5 * (y / (z / x)) else: tmp = (y / z) / x return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -65.0) || !(x <= 6200.0)) tmp = Float64(0.5 * Float64(y / Float64(z / x))); else tmp = Float64(Float64(y / z) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -65.0) || ~((x <= 6200.0))) tmp = 0.5 * (y / (z / x)); else tmp = (y / z) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -65.0], N[Not[LessEqual[x, 6200.0]], $MachinePrecision]], N[(0.5 * N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -65 \lor \neg \left(x \leq 6200\right):\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\end{array}
\end{array}
if x < -65 or 6200 < x Initial program 79.0%
Taylor expanded in x around 0 39.4%
Taylor expanded in x around inf 39.4%
associate-*r/39.4%
*-commutative39.4%
Simplified39.4%
Taylor expanded in y around 0 39.4%
associate-*r/39.4%
*-commutative39.4%
associate-*r/39.4%
associate-/l*36.0%
Simplified36.0%
if -65 < x < 6200Initial program 89.9%
associate-*l/89.8%
Simplified89.8%
associate-/r/89.0%
associate-/l*88.5%
*-commutative88.5%
expm1-log1p-u62.0%
expm1-udef44.1%
associate-/l*44.1%
times-frac48.7%
Applied egg-rr48.7%
expm1-def64.7%
expm1-log1p96.8%
associate-*r/89.7%
*-commutative89.7%
associate-*r/87.8%
Simplified87.8%
associate-/r*87.9%
*-commutative87.9%
associate-*l/89.4%
*-commutative89.4%
associate-/r*97.9%
*-commutative97.9%
Applied egg-rr97.9%
Taylor expanded in x around 0 88.5%
associate-/l/97.0%
Simplified97.0%
Final simplification62.9%
(FPCore (x y z) :precision binary64 (/ (* y (+ (* x 0.5) (/ 1.0 x))) z))
double code(double x, double y, double z) {
return (y * ((x * 0.5) + (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 * ((x * 0.5d0) + (1.0d0 / x))) / z
end function
public static double code(double x, double y, double z) {
return (y * ((x * 0.5) + (1.0 / x))) / z;
}
def code(x, y, z): return (y * ((x * 0.5) + (1.0 / x))) / z
function code(x, y, z) return Float64(Float64(y * Float64(Float64(x * 0.5) + Float64(1.0 / x))) / z) end
function tmp = code(x, y, z) tmp = (y * ((x * 0.5) + (1.0 / x))) / z; end
code[x_, y_, z_] := N[(N[(y * N[(N[(x * 0.5), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{y \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)}{z}
\end{array}
Initial program 83.8%
Taylor expanded in x around 0 61.3%
Taylor expanded in y around 0 61.3%
Final simplification61.3%
(FPCore (x y z) :precision binary64 (/ (+ (/ y x) (* 0.5 (* y x))) z))
double code(double x, double y, double z) {
return ((y / x) + (0.5 * (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) + (0.5d0 * (y * x))) / z
end function
public static double code(double x, double y, double z) {
return ((y / x) + (0.5 * (y * x))) / z;
}
def code(x, y, z): return ((y / x) + (0.5 * (y * x))) / z
function code(x, y, z) return Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(y * x))) / z) end
function tmp = code(x, y, z) tmp = ((y / x) + (0.5 * (y * x))) / z; end
code[x_, y_, z_] := N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}
\end{array}
Initial program 83.8%
Taylor expanded in x around 0 61.3%
Final simplification61.3%
(FPCore (x y z) :precision binary64 (if (<= y -2e-66) (/ y (* x z)) (/ (/ y x) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-66) {
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 <= (-2d-66)) 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 <= -2e-66) {
tmp = y / (x * z);
} else {
tmp = (y / x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e-66: tmp = y / (x * z) else: tmp = (y / x) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e-66) tmp = Float64(y / Float64(x * z)); else tmp = Float64(Float64(y / x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e-66) tmp = y / (x * z); else tmp = (y / x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e-66], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-66}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if y < -2e-66Initial program 87.8%
associate-*l/87.8%
Simplified87.8%
Taylor expanded in x around 0 51.3%
if -2e-66 < y Initial program 81.9%
Taylor expanded in x around 0 46.6%
Final simplification48.1%
(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-*l/83.8%
Simplified83.8%
Taylor expanded in x around 0 43.9%
Final simplification43.9%
(FPCore (x y z) :precision binary64 (/ (/ y z) x))
double code(double x, double y, double z) {
return (y / 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 / z) / x
end function
public static double code(double x, double y, double z) {
return (y / z) / x;
}
def code(x, y, z): return (y / z) / x
function code(x, y, z) return Float64(Float64(y / z) / x) end
function tmp = code(x, y, z) tmp = (y / z) / x; end
code[x_, y_, z_] := N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{z}}{x}
\end{array}
Initial program 83.8%
associate-*l/83.8%
Simplified83.8%
associate-/r/74.0%
associate-/l*71.1%
*-commutative71.1%
expm1-log1p-u43.4%
expm1-udef35.5%
associate-/l*39.4%
times-frac46.9%
Applied egg-rr46.9%
expm1-def54.0%
expm1-log1p90.8%
associate-*r/95.5%
*-commutative95.5%
associate-*r/94.6%
Simplified94.6%
associate-/r*77.5%
*-commutative77.5%
associate-*l/78.1%
*-commutative78.1%
associate-/r*99.1%
*-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in x around 0 43.9%
associate-/l/51.4%
Simplified51.4%
Final simplification51.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 2023305
(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))