
(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) x) (sinh y)))
double code(double x, double y) {
return (sin(x) / x) * sinh(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (sin(x) / x) * sinh(y)
end function
public static double code(double x, double y) {
return (Math.sin(x) / x) * Math.sinh(y);
}
def code(x, y): return (math.sin(x) / x) * math.sinh(y)
function code(x, y) return Float64(Float64(sin(x) / x) * sinh(y)) end
function tmp = code(x, y) tmp = (sin(x) / x) * sinh(y); end
code[x_, y_] := N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * N[Sinh[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin x}{x} \cdot \sinh y
\end{array}
Initial program 87.1%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -4e-6) (sinh y) (if (<= (sinh y) 4000000000000.0) (* (sin x) (/ y x)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -4e-6) {
tmp = sinh(y);
} else if (sinh(y) <= 4000000000000.0) {
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 (sinh(y) <= (-4d-6)) then
tmp = sinh(y)
else if (sinh(y) <= 4000000000000.0d0) 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 (Math.sinh(y) <= -4e-6) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 4000000000000.0) {
tmp = Math.sin(x) * (y / x);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -4e-6: tmp = math.sinh(y) elif math.sinh(y) <= 4000000000000.0: tmp = math.sin(x) * (y / x) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -4e-6) tmp = sinh(y); elseif (sinh(y) <= 4000000000000.0) 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 (sinh(y) <= -4e-6) tmp = sinh(y); elseif (sinh(y) <= 4000000000000.0) tmp = sin(x) * (y / x); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -4e-6], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 4000000000000.0], N[(N[Sin[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -4 \cdot 10^{-6}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 4000000000000:\\
\;\;\;\;\sin x \cdot \frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.99999999999999982e-6 or 4e12 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
if -3.99999999999999982e-6 < (sinh.f64 y) < 4e12Initial program 76.2%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in y around 0 74.8%
associate-/l*98.5%
associate-/r/98.3%
Simplified98.3%
Final simplification88.9%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -4e-6) (sinh y) (if (<= (sinh y) 4000000000000.0) (* (/ (sin x) x) y) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -4e-6) {
tmp = sinh(y);
} else if (sinh(y) <= 4000000000000.0) {
tmp = (sin(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-6)) then
tmp = sinh(y)
else if (sinh(y) <= 4000000000000.0d0) then
tmp = (sin(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-6) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 4000000000000.0) {
tmp = (Math.sin(x) / x) * y;
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -4e-6: tmp = math.sinh(y) elif math.sinh(y) <= 4000000000000.0: tmp = (math.sin(x) / x) * y else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -4e-6) tmp = sinh(y); elseif (sinh(y) <= 4000000000000.0) tmp = Float64(Float64(sin(x) / x) * y); else tmp = sinh(y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (sinh(y) <= -4e-6) tmp = sinh(y); elseif (sinh(y) <= 4000000000000.0) tmp = (sin(x) / x) * y; else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -4e-6], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 4000000000000.0], N[(N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -4 \cdot 10^{-6}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 4000000000000:\\
\;\;\;\;\frac{\sin x}{x} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.99999999999999982e-6 or 4e12 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
if -3.99999999999999982e-6 < (sinh.f64 y) < 4e12Initial program 76.2%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in y around 0 98.4%
Final simplification89.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -4e-6) (sinh y) (if (<= (sinh y) 4000000000000.0) (/ y (/ x (sin x))) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -4e-6) {
tmp = sinh(y);
} else if (sinh(y) <= 4000000000000.0) {
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) <= (-4d-6)) then
tmp = sinh(y)
else if (sinh(y) <= 4000000000000.0d0) 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) <= -4e-6) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 4000000000000.0) {
tmp = y / (x / Math.sin(x));
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -4e-6: tmp = math.sinh(y) elif math.sinh(y) <= 4000000000000.0: tmp = y / (x / math.sin(x)) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -4e-6) tmp = sinh(y); elseif (sinh(y) <= 4000000000000.0) 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) <= -4e-6) tmp = sinh(y); elseif (sinh(y) <= 4000000000000.0) tmp = y / (x / sin(x)); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -4e-6], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 4000000000000.0], 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 -4 \cdot 10^{-6}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 4000000000000:\\
\;\;\;\;\frac{y}{\frac{x}{\sin x}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -3.99999999999999982e-6 or 4e12 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 77.8%
if -3.99999999999999982e-6 < (sinh.f64 y) < 4e12Initial program 76.2%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in y around 0 74.8%
associate-/l*98.5%
Simplified98.5%
Final simplification89.0%
(FPCore (x y) :precision binary64 (if (<= (sinh y) -2e-15) (sinh y) (if (<= (sinh y) 4e-40) (/ x (/ x y)) (sinh y))))
double code(double x, double y) {
double tmp;
if (sinh(y) <= -2e-15) {
tmp = sinh(y);
} else if (sinh(y) <= 4e-40) {
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) <= (-2d-15)) then
tmp = sinh(y)
else if (sinh(y) <= 4d-40) 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) <= -2e-15) {
tmp = Math.sinh(y);
} else if (Math.sinh(y) <= 4e-40) {
tmp = x / (x / y);
} else {
tmp = Math.sinh(y);
}
return tmp;
}
def code(x, y): tmp = 0 if math.sinh(y) <= -2e-15: tmp = math.sinh(y) elif math.sinh(y) <= 4e-40: tmp = x / (x / y) else: tmp = math.sinh(y) return tmp
function code(x, y) tmp = 0.0 if (sinh(y) <= -2e-15) tmp = sinh(y); elseif (sinh(y) <= 4e-40) 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) <= -2e-15) tmp = sinh(y); elseif (sinh(y) <= 4e-40) tmp = x / (x / y); else tmp = sinh(y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Sinh[y], $MachinePrecision], -2e-15], N[Sinh[y], $MachinePrecision], If[LessEqual[N[Sinh[y], $MachinePrecision], 4e-40], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sinh[y], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sinh y \leq -2 \cdot 10^{-15}:\\
\;\;\;\;\sinh y\\
\mathbf{elif}\;\sinh y \leq 4 \cdot 10^{-40}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sinh y\\
\end{array}
\end{array}
if (sinh.f64 y) < -2.0000000000000002e-15 or 3.9999999999999997e-40 < (sinh.f64 y) Initial program 100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in x around 0 74.8%
if -2.0000000000000002e-15 < (sinh.f64 y) < 3.9999999999999997e-40Initial program 73.7%
Taylor expanded in y around 0 73.7%
Taylor expanded in x around 0 28.3%
associate-/l*54.4%
associate-/r/79.5%
Applied egg-rr79.5%
*-commutative79.5%
clear-num81.5%
un-div-inv81.6%
Applied egg-rr81.6%
Final simplification78.1%
(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.1%
associate-*r/99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= y 1.5e+166) (/ x (/ x y)) (sqrt (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 1.5e+166) {
tmp = x / (x / y);
} else {
tmp = sqrt((y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.5d+166) then
tmp = x / (x / y)
else
tmp = sqrt((y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.5e+166) {
tmp = x / (x / y);
} else {
tmp = Math.sqrt((y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.5e+166: tmp = x / (x / y) else: tmp = math.sqrt((y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.5e+166) tmp = Float64(x / Float64(x / y)); else tmp = sqrt(Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.5e+166) tmp = x / (x / y); else tmp = sqrt((y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.5e+166], N[(x / N[(x / y), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{+166}:\\
\;\;\;\;\frac{x}{\frac{x}{y}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{y \cdot y}\\
\end{array}
\end{array}
if y < 1.49999999999999999e166Initial program 85.7%
Taylor expanded in y around 0 46.9%
Taylor expanded in x around 0 23.3%
associate-/l*34.2%
associate-/r/54.4%
Applied egg-rr54.4%
*-commutative54.4%
clear-num55.5%
un-div-inv55.1%
Applied egg-rr55.1%
if 1.49999999999999999e166 < y Initial program 100.0%
Taylor expanded in y around 0 6.2%
Taylor expanded in x around 0 21.3%
div-inv21.3%
associate-*l*6.0%
div-inv6.0%
*-inverses6.0%
*-commutative6.0%
*-un-lft-identity6.0%
add-sqr-sqrt6.0%
sqrt-unprod79.2%
Applied egg-rr79.2%
Final simplification57.4%
(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.1%
Taylor expanded in y around 0 43.1%
Taylor expanded in x around 0 23.1%
associate-/l*31.6%
associate-/r/53.5%
Applied egg-rr53.5%
Final simplification53.5%
(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.1%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in y around 0 56.0%
Taylor expanded in x around 0 31.6%
Final simplification31.6%
(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 2023274
(FPCore (x y)
:name "Linear.Quaternion:$ccosh from linear-1.19.1.3"
:precision binary64
:herbie-target
(* (sin x) (/ (sinh y) x))
(/ (* (sin x) (sinh y)) x))