
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (sin x) (sinh y)) x))
double code(double x, double y) {
return (sin(x) * sinh(y)) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) * sinh(y)) / x
end function
public static double code(double x, double y) {
return (Math.sin(x) * Math.sinh(y)) / x;
}
def code(x, y): return (math.sin(x) * math.sinh(y)) / x
function code(x, y) return Float64(Float64(sin(x) * sinh(y)) / x) end
function tmp = code(x, y) tmp = (sin(x) * sinh(y)) / x; end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x \cdot \sinh y}{x}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 88.5%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-13) (/ y (/ x (sin x))) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-13) {
tmp = y / (x / sin(x));
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 2d-13) then
tmp = y / (x / sin(x))
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 2e-13) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-13: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-13) tmp = Float64(y / Float64(x / sin(x))); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 2e-13) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-13], N[(y / N[(x / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.0000000000000001e-13Initial program 84.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 55.9%
associate-/l*71.4%
Simplified71.4%
clear-num71.3%
un-div-inv71.4%
Applied egg-rr71.4%
if 2.0000000000000001e-13 < (sinh.f64 y) Initial program 100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 69.7%
clear-num69.7%
un-div-inv69.7%
Applied egg-rr69.7%
associate-/r/69.7%
*-inverses69.7%
*-lft-identity69.7%
Simplified69.7%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 2e-13) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 2e-13) {
tmp = y * (sin(x) / x);
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 2d-13) then
tmp = y * (sin(x) / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 2e-13) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 2e-13: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 2e-13) tmp = Float64(y * Float64(sin(x) / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 2e-13) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 2e-13], N[(y * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 2 \cdot 10^{-13}:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2.0000000000000001e-13Initial program 84.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 55.9%
associate-/l*71.4%
Simplified71.4%
if 2.0000000000000001e-13 < (sinh.f64 y) Initial program 100.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 69.7%
clear-num69.7%
un-div-inv69.7%
Applied egg-rr69.7%
associate-/r/69.7%
*-inverses69.7%
*-lft-identity69.7%
Simplified69.7%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 1e-58) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 1e-58) {
tmp = x / (x / y);
} else {
tmp = sinh(y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (sinh(y) <= 1d-58) then
tmp = x / (x / y)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.sinh(y) <= 1e-58) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 1e-58: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 1e-58) tmp = Float64(x / Float64(x / y)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= 1e-58) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 1e-58], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 10^{-58}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 1e-58Initial program 83.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 78.8%
Taylor expanded in x around 0 64.5%
clear-num64.9%
un-div-inv64.9%
Applied egg-rr64.9%
if 1e-58 < (sinh.f64 y) Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 67.3%
clear-num67.3%
un-div-inv67.4%
Applied egg-rr67.4%
associate-/r/67.4%
*-inverses67.4%
*-lft-identity67.4%
Simplified67.4%
(FPCore (x y) :precision binary64 (* x (/ (sinh y) x)))
double code(double x, double y) {
return x * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (sinh(y) / x)
end function
public static double code(double x, double y) {
return x * (Math.sinh(y) / x);
}
def code(x, y): return x * (math.sinh(y) / x)
function code(x, y) return Float64(x * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = x * (sinh(y) / x); end
code[x_, y_] := N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\sinh y}{x}
\end{array}
Initial program 88.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 73.9%
(FPCore (x y)
:precision binary64
(if (<= x 4e-13)
(* x (/ y x))
(if (<= x 5.5e+210)
(* y (+ 1.0 (* (* x x) -0.16666666666666666)))
(/ x (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= 4e-13) {
tmp = x * (y / x);
} else if (x <= 5.5e+210) {
tmp = y * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = x / (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 4d-13) then
tmp = x * (y / x)
else if (x <= 5.5d+210) then
tmp = y * (1.0d0 + ((x * x) * (-0.16666666666666666d0)))
else
tmp = x / (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 4e-13) {
tmp = x * (y / x);
} else if (x <= 5.5e+210) {
tmp = y * (1.0 + ((x * x) * -0.16666666666666666));
} else {
tmp = x / (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 4e-13: tmp = x * (y / x) elif x <= 5.5e+210: tmp = y * (1.0 + ((x * x) * -0.16666666666666666)) else: tmp = x / (x / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 4e-13) tmp = Float64(x * Float64(y / x)); elseif (x <= 5.5e+210) tmp = Float64(y * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))); else tmp = Float64(x / Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 4e-13) tmp = x * (y / x); elseif (x <= 5.5e+210) tmp = y * (1.0 + ((x * x) * -0.16666666666666666)); else tmp = x / (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 4e-13], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e+210], N[(y * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-13}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+210}:\\
\;\;\;\;y \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\end{array}
\end{array}
if x < 4.0000000000000001e-13Initial program 84.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 71.2%
Taylor expanded in x around 0 65.2%
if 4.0000000000000001e-13 < x < 5.50000000000000011e210Initial program 99.2%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 57.9%
associate-/l*58.5%
Simplified58.5%
Taylor expanded in x around 0 36.1%
*-commutative36.1%
Simplified36.1%
unpow236.1%
Applied egg-rr36.1%
if 5.50000000000000011e210 < x Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 81.7%
Taylor expanded in x around 0 81.5%
clear-num81.5%
un-div-inv81.5%
Applied egg-rr81.5%
(FPCore (x y) :precision binary64 (if (<= x 1.4e+26) (* x (/ y x)) (if (<= x 6.8e+208) (* (* x x) (* y -0.16666666666666666)) (/ x (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= 1.4e+26) {
tmp = x * (y / x);
} else if (x <= 6.8e+208) {
tmp = (x * x) * (y * -0.16666666666666666);
} else {
tmp = x / (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.4d+26) then
tmp = x * (y / x)
else if (x <= 6.8d+208) then
tmp = (x * x) * (y * (-0.16666666666666666d0))
else
tmp = x / (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.4e+26) {
tmp = x * (y / x);
} else if (x <= 6.8e+208) {
tmp = (x * x) * (y * -0.16666666666666666);
} else {
tmp = x / (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.4e+26: tmp = x * (y / x) elif x <= 6.8e+208: tmp = (x * x) * (y * -0.16666666666666666) else: tmp = x / (x / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.4e+26) tmp = Float64(x * Float64(y / x)); elseif (x <= 6.8e+208) tmp = Float64(Float64(x * x) * Float64(y * -0.16666666666666666)); else tmp = Float64(x / Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.4e+26) tmp = x * (y / x); elseif (x <= 6.8e+208) tmp = (x * x) * (y * -0.16666666666666666); else tmp = x / (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.4e+26], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.8e+208], N[(N[(x * x), $MachinePrecision] * N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4 \cdot 10^{+26}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+208}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot -0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\end{array}
\end{array}
if x < 1.4e26Initial program 84.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 72.5%
Taylor expanded in x around 0 63.7%
if 1.4e26 < x < 6.7999999999999997e208Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 50.8%
associate-/l*50.6%
Simplified50.6%
Taylor expanded in x around 0 36.1%
*-commutative36.1%
Simplified36.1%
Taylor expanded in x around inf 36.1%
*-commutative36.1%
associate-*r*36.1%
Simplified36.1%
unpow236.1%
Applied egg-rr36.1%
if 6.7999999999999997e208 < x Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 81.7%
Taylor expanded in x around 0 81.5%
clear-num81.5%
un-div-inv81.5%
Applied egg-rr81.5%
(FPCore (x y) :precision binary64 (* x (/ y x)))
double code(double x, double y) {
return x * (y / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y / x)
end function
public static double code(double x, double y) {
return x * (y / x);
}
def code(x, y): return x * (y / x)
function code(x, y) return Float64(x * Float64(y / x)) end
function tmp = code(x, y) tmp = x * (y / x); end
code[x_, y_] := N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{x}
\end{array}
Initial program 88.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 69.1%
Taylor expanded in x around 0 57.0%
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 88.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 73.9%
Taylor expanded in y around 0 31.9%
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) x)))
double code(double x, double y) {
return sin(x) * (sinh(y) / x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / x)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / x);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / x)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / x)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / x); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{x}
\end{array}
herbie shell --seed 2024191
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:alt
(! :herbie-platform default (* (sin x) (/ (sinh y) x)))
(/ (* (sin x) (sinh y)) x))