
(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 10 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 87.6%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 0.002) (* y (/ (sin x) x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 0.002) {
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) <= 0.002d0) 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) <= 0.002) {
tmp = y * (Math.sin(x) / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 0.002: tmp = y * (math.sin(x) / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 0.002) 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) <= 0.002) tmp = y * (sin(x) / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 0.002], 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 0.002:\\
\;\;\;\;y \cdot \frac{\sin x}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 2e-3Initial program 83.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 49.3%
associate-/l*65.6%
Simplified65.6%
if 2e-3 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 66.1%
clear-num66.1%
un-div-inv66.1%
Applied egg-rr66.1%
associate-/r/66.1%
*-inverses66.1%
*-lft-identity66.1%
Simplified66.1%
(FPCore (x y) :precision binary64 (if (<= (sinh y) 4e-25) (/ x (/ x y)) (sinh y)))
double code(double x, double y) {
double tmp;
if (sinh(y) <= 4e-25) {
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) <= 4d-25) 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) <= 4e-25) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= 4e-25: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= 4e-25) 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) <= 4e-25) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-25], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq 4 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < 4.00000000000000015e-25Initial program 83.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 71.4%
Taylor expanded in x around 0 51.8%
clear-num53.8%
un-div-inv53.3%
Applied egg-rr53.3%
if 4.00000000000000015e-25 < (sinh.f64 y) Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 65.8%
clear-num65.8%
un-div-inv65.8%
Applied egg-rr65.8%
associate-/r/65.8%
*-inverses65.8%
*-lft-identity65.8%
Simplified65.8%
(FPCore (x y)
:precision binary64
(if (<= y 0.0036)
(* (sin x) (/ y x))
(if (<= y 7.9e+192)
(* x (/ (sinh y) x))
(* (/ y x) (+ x (* -0.16666666666666666 (pow x 3.0)))))))
double code(double x, double y) {
double tmp;
if (y <= 0.0036) {
tmp = sin(x) * (y / x);
} else if (y <= 7.9e+192) {
tmp = x * (sinh(y) / x);
} else {
tmp = (y / x) * (x + (-0.16666666666666666 * pow(x, 3.0)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 0.0036d0) then
tmp = sin(x) * (y / x)
else if (y <= 7.9d+192) then
tmp = x * (sinh(y) / x)
else
tmp = (y / x) * (x + ((-0.16666666666666666d0) * (x ** 3.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.0036) {
tmp = Math.sin(x) * (y / x);
} else if (y <= 7.9e+192) {
tmp = x * (Math.sinh(y) / x);
} else {
tmp = (y / x) * (x + (-0.16666666666666666 * Math.pow(x, 3.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.0036: tmp = math.sin(x) * (y / x) elif y <= 7.9e+192: tmp = x * (math.sinh(y) / x) else: tmp = (y / x) * (x + (-0.16666666666666666 * math.pow(x, 3.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.0036) tmp = Float64(sin(x) * Float64(y / x)); elseif (y <= 7.9e+192) tmp = Float64(x * Float64(sinh(y) / x)); else tmp = Float64(Float64(y / x) * Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.0036) tmp = sin(x) * (y / x); elseif (y <= 7.9e+192) tmp = x * (sinh(y) / x); else tmp = (y / x) * (x + (-0.16666666666666666 * (x ^ 3.0))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.0036], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.9e+192], N[(x * N[(N[Sinh[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] * N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0036:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{elif}\;y \leq 7.9 \cdot 10^{+192}:\\
\;\;\;\;x \cdot \frac{\sinh y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} \cdot \left(x + -0.16666666666666666 \cdot {x}^{3}\right)\\
\end{array}
\end{array}
if y < 0.0035999999999999999Initial program 83.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 71.8%
if 0.0035999999999999999 < y < 7.90000000000000046e192Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 74.2%
if 7.90000000000000046e192 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 29.3%
Taylor expanded in x around 0 59.3%
distribute-rgt-in59.3%
*-lft-identity59.3%
associate-*l*59.3%
unpow259.3%
unpow359.3%
Simplified59.3%
Final simplification70.6%
(FPCore (x y) :precision binary64 (if (<= y 0.024) (* (sin x) (/ y x)) (sinh y)))
double code(double x, double y) {
double tmp;
if (y <= 0.024) {
tmp = sin(x) * (y / 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 (y <= 0.024d0) then
tmp = sin(x) * (y / x)
else
tmp = sinh(y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.024) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.024: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.024) tmp = Float64(sin(x) * Float64(y / x)); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.024) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.024], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.024:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if y < 0.024Initial program 83.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 71.8%
if 0.024 < y Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in x around 0 66.1%
clear-num66.1%
un-div-inv66.1%
Applied egg-rr66.1%
associate-/r/66.1%
*-inverses66.1%
*-lft-identity66.1%
Simplified66.1%
(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 87.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 70.7%
(FPCore (x y) :precision binary64 (if (<= x 7.8e+40) (* x (/ y x)) (if (<= x 1.9e+166) (* (* x x) (* y -0.16666666666666666)) (/ x (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= 7.8e+40) {
tmp = x * (y / x);
} else if (x <= 1.9e+166) {
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 <= 7.8d+40) then
tmp = x * (y / x)
else if (x <= 1.9d+166) 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 <= 7.8e+40) {
tmp = x * (y / x);
} else if (x <= 1.9e+166) {
tmp = (x * x) * (y * -0.16666666666666666);
} else {
tmp = x / (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 7.8e+40: tmp = x * (y / x) elif x <= 1.9e+166: tmp = (x * x) * (y * -0.16666666666666666) else: tmp = x / (x / y) return tmp
function code(x, y) tmp = 0.0 if (x <= 7.8e+40) tmp = Float64(x * Float64(y / x)); elseif (x <= 1.9e+166) 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 <= 7.8e+40) tmp = x * (y / x); elseif (x <= 1.9e+166) tmp = (x * x) * (y * -0.16666666666666666); else tmp = x / (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 7.8e+40], N[(x * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e+166], 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 7.8 \cdot 10^{+40}:\\
\;\;\;\;x \cdot \frac{y}{x}\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+166}:\\
\;\;\;\;\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 < 7.8000000000000002e40Initial program 84.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 65.5%
Taylor expanded in x around 0 52.0%
if 7.8000000000000002e40 < x < 1.90000000000000003e166Initial program 99.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 30.7%
Taylor expanded in x around 0 28.9%
distribute-rgt-in28.9%
*-lft-identity28.9%
associate-*l*28.9%
unpow228.9%
unpow328.9%
Simplified28.9%
Taylor expanded in x around inf 28.9%
*-commutative28.9%
associate-*r*28.9%
Simplified28.9%
unpow228.9%
Applied egg-rr28.9%
if 1.90000000000000003e166 < x Initial program 99.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 57.0%
Taylor expanded in x around 0 43.8%
clear-num49.8%
un-div-inv49.8%
Applied egg-rr49.8%
(FPCore (x y) :precision binary64 (/ x (/ x y)))
double code(double x, double y) {
return x / (x / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (x / y)
end function
public static double code(double x, double y) {
return x / (x / y);
}
def code(x, y): return x / (x / y)
function code(x, y) return Float64(x / Float64(x / y)) end
function tmp = code(x, y) tmp = x / (x / y); end
code[x_, y_] := N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x}{y}}
\end{array}
Initial program 87.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 60.3%
Taylor expanded in x around 0 45.1%
clear-num46.5%
un-div-inv45.1%
Applied egg-rr45.1%
(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 87.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 60.3%
Taylor expanded in x around 0 45.1%
(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 87.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 70.7%
Taylor expanded in y around 0 25.8%
(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 2024135
(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))