(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (cosh x) (/ y (* z x))))) (if (<= z -1e+20) t_0 (if (<= z 1e-60) (* (cosh x) (/ (/ y z) x)) t_0))))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
double t_0 = cosh(x) * (y / (z * x));
double tmp;
if (z <= -1e+20) {
tmp = t_0;
} else if (z <= 1e-60) {
tmp = cosh(x) * ((y / 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
code = (cosh(x) * (y / x)) / z
end function
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 / (z * x))
if (z <= (-1d+20)) then
tmp = t_0
else if (z <= 1d-60) then
tmp = cosh(x) * ((y / z) / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
public static double code(double x, double y, double z) {
double t_0 = Math.cosh(x) * (y / (z * x));
double tmp;
if (z <= -1e+20) {
tmp = t_0;
} else if (z <= 1e-60) {
tmp = Math.cosh(x) * ((y / z) / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
def code(x, y, z): t_0 = math.cosh(x) * (y / (z * x)) tmp = 0 if z <= -1e+20: tmp = t_0 elif z <= 1e-60: tmp = math.cosh(x) * ((y / z) / x) else: tmp = t_0 return tmp
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function code(x, y, z) t_0 = Float64(cosh(x) * Float64(y / Float64(z * x))) tmp = 0.0 if (z <= -1e+20) tmp = t_0; elseif (z <= 1e-60) tmp = Float64(cosh(x) * Float64(Float64(y / z) / x)); else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
function tmp_2 = code(x, y, z) t_0 = cosh(x) * (y / (z * x)); tmp = 0.0; if (z <= -1e+20) tmp = t_0; elseif (z <= 1e-60) tmp = cosh(x) * ((y / z) / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+20], t$95$0, If[LessEqual[z, 1e-60], N[(N[Cosh[x], $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{z \cdot x}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+20}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 10^{-60}:\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
| Original | 8.1 |
|---|---|
| Target | 0.4 |
| Herbie | 0.4 |
if z < -1e20 or 9.9999999999999997e-61 < z Initial program 11.6
Applied egg-rr11.7
Applied egg-rr10.9
Taylor expanded in z around 0 0.5
if -1e20 < z < 9.9999999999999997e-61Initial program 0.3
Applied egg-rr0.4
Applied egg-rr0.4
Taylor expanded in z around 0 20.5
Simplified0.3
Final simplification0.4
herbie shell --seed 2022210
(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))