
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (sin x) (/ (sinh y) y)))
double code(double x, double y) {
return sin(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.sin(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.sin(x) * (math.sinh(y) / y)
function code(x, y) return Float64(sin(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = sin(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Sin[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin x \cdot \frac{\sinh y}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (sinh y) y))) (if (<= t_0 2.0) (sin x) (* x t_0))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 2.0) {
tmp = sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = sinh(y) / y
if (t_0 <= 2.0d0) then
tmp = sin(x)
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if (t_0 <= 2.0) {
tmp = Math.sin(x);
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if t_0 <= 2.0: tmp = math.sin(x) else: tmp = x * t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (t_0 <= 2.0) tmp = sin(x); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (t_0 <= 2.0) tmp = sin(x); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], N[Sin[x], $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t\_0 \leq 2:\\
\;\;\;\;\sin x\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 2Initial program 100.0%
Taylor expanded in y around 0 98.9%
if 2 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
Taylor expanded in x around 0 79.4%
Final simplification89.3%
(FPCore (x y) :precision binary64 (sin x))
double code(double x, double y) {
return sin(x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sin(x)
end function
public static double code(double x, double y) {
return Math.sin(x);
}
def code(x, y): return math.sin(x)
function code(x, y) return sin(x) end
function tmp = code(x, y) tmp = sin(x); end
code[x_, y_] := N[Sin[x], $MachinePrecision]
\begin{array}{l}
\\
\sin x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 51.5%
Final simplification51.5%
(FPCore (x y) :precision binary64 (if (<= x 1900000000000.0) x 0.5))
double code(double x, double y) {
double tmp;
if (x <= 1900000000000.0) {
tmp = x;
} else {
tmp = 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1900000000000.0d0) then
tmp = x
else
tmp = 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1900000000000.0) {
tmp = x;
} else {
tmp = 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1900000000000.0: tmp = x else: tmp = 0.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 1900000000000.0) tmp = x; else tmp = 0.5; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1900000000000.0) tmp = x; else tmp = 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1900000000000.0], x, 0.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1900000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < 1.9e12Initial program 100.0%
Taylor expanded in x around 0 79.5%
Taylor expanded in y around 0 34.8%
if 1.9e12 < x Initial program 99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Applied egg-rr8.1%
Final simplification27.6%
(FPCore (x y) :precision binary64 -3.0)
double code(double x, double y) {
return -3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -3.0d0
end function
public static double code(double x, double y) {
return -3.0;
}
def code(x, y): return -3.0
function code(x, y) return -3.0 end
function tmp = code(x, y) tmp = -3.0; end
code[x_, y_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Applied egg-rr4.2%
Final simplification4.2%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Applied egg-rr4.7%
Final simplification4.7%
(FPCore (x y) :precision binary64 -0.5)
double code(double x, double y) {
return -0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -0.5d0
end function
public static double code(double x, double y) {
return -0.5;
}
def code(x, y): return -0.5
function code(x, y) return -0.5 end
function tmp = code(x, y) tmp = -0.5; end
code[x_, y_] := -0.5
\begin{array}{l}
\\
-0.5
\end{array}
Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Applied egg-rr4.6%
Final simplification4.6%
(FPCore (x y) :precision binary64 0.25)
double code(double x, double y) {
return 0.25;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.25d0
end function
public static double code(double x, double y) {
return 0.25;
}
def code(x, y): return 0.25
function code(x, y) return 0.25 end
function tmp = code(x, y) tmp = 0.25; end
code[x_, y_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Applied egg-rr4.7%
Final simplification4.7%
(FPCore (x y) :precision binary64 0.3333333333333333)
double code(double x, double y) {
return 0.3333333333333333;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.3333333333333333d0
end function
public static double code(double x, double y) {
return 0.3333333333333333;
}
def code(x, y): return 0.3333333333333333
function code(x, y) return 0.3333333333333333 end
function tmp = code(x, y) tmp = 0.3333333333333333; end
code[x_, y_] := 0.3333333333333333
\begin{array}{l}
\\
0.3333333333333333
\end{array}
Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Applied egg-rr4.7%
Final simplification4.7%
(FPCore (x y) :precision binary64 0.5)
double code(double x, double y) {
return 0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.5d0
end function
public static double code(double x, double y) {
return 0.5;
}
def code(x, y): return 0.5
function code(x, y) return 0.5 end
function tmp = code(x, y) tmp = 0.5; end
code[x_, y_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
Applied egg-rr4.9%
Final simplification4.9%
herbie shell --seed 2024067
(FPCore (x y)
:name "Linear.Quaternion:$ccos from linear-1.19.1.3"
:precision binary64
(* (sin x) (/ (sinh y) y)))