
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \frac{\sinh y}{y}
\end{array}
(FPCore (x y) :precision binary64 (* (cos x) (/ (sinh y) y)))
double code(double x, double y) {
return cos(x) * (sinh(y) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = cos(x) * (sinh(y) / y)
end function
public static double code(double x, double y) {
return Math.cos(x) * (Math.sinh(y) / y);
}
def code(x, y): return math.cos(x) * (math.sinh(y) / y)
function code(x, y) return Float64(cos(x) * Float64(sinh(y) / y)) end
function tmp = code(x, y) tmp = cos(x) * (sinh(y) / y); end
code[x_, y_] := N[(N[Cos[x], $MachinePrecision] * N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos 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 1.0000000005) (cos x) t_0)))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (t_0 <= 1.0000000005) {
tmp = cos(x);
} else {
tmp = 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 <= 1.0000000005d0) then
tmp = cos(x)
else
tmp = 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 <= 1.0000000005) {
tmp = Math.cos(x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if t_0 <= 1.0000000005: tmp = math.cos(x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (t_0 <= 1.0000000005) tmp = cos(x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (t_0 <= 1.0000000005) tmp = cos(x); else tmp = 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, 1.0000000005], N[Cos[x], $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;t_0 \leq 1.0000000005:\\
\;\;\;\;\cos x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (/.f64 (sinh.f64 y) y) < 1.0000000005Initial program 100.0%
Taylor expanded in y around 0 99.9%
if 1.0000000005 < (/.f64 (sinh.f64 y) y) Initial program 100.0%
add-log-exp99.2%
*-un-lft-identity99.2%
log-prod99.2%
metadata-eval99.2%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/r/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 76.5%
expm1-log1p-u76.5%
expm1-udef76.5%
un-div-inv76.5%
Applied egg-rr76.5%
expm1-def76.5%
expm1-log1p76.5%
Simplified76.5%
Final simplification88.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (sinh y) y)))
(if (<= y 0.064)
(* (cos x) (+ 1.0 (* 0.16666666666666666 (* y y))))
(if (<= y 1e+116)
t_0
(if (<= y 1.5e+151)
(*
(/
(+ (* 0.027777777777777776 (pow y 4.0)) -1.0)
(+ (* y (* y 0.16666666666666666)) -1.0))
(+ 1.0 (* -0.5 (* x x))))
(if (<= y 4e+154)
t_0
(* y (* 0.16666666666666666 (* (cos x) y)))))))))
double code(double x, double y) {
double t_0 = sinh(y) / y;
double tmp;
if (y <= 0.064) {
tmp = cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
} else if (y <= 1e+116) {
tmp = t_0;
} else if (y <= 1.5e+151) {
tmp = (((0.027777777777777776 * pow(y, 4.0)) + -1.0) / ((y * (y * 0.16666666666666666)) + -1.0)) * (1.0 + (-0.5 * (x * x)));
} else if (y <= 4e+154) {
tmp = t_0;
} else {
tmp = y * (0.16666666666666666 * (cos(x) * y));
}
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 (y <= 0.064d0) then
tmp = cos(x) * (1.0d0 + (0.16666666666666666d0 * (y * y)))
else if (y <= 1d+116) then
tmp = t_0
else if (y <= 1.5d+151) then
tmp = (((0.027777777777777776d0 * (y ** 4.0d0)) + (-1.0d0)) / ((y * (y * 0.16666666666666666d0)) + (-1.0d0))) * (1.0d0 + ((-0.5d0) * (x * x)))
else if (y <= 4d+154) then
tmp = t_0
else
tmp = y * (0.16666666666666666d0 * (cos(x) * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sinh(y) / y;
double tmp;
if (y <= 0.064) {
tmp = Math.cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
} else if (y <= 1e+116) {
tmp = t_0;
} else if (y <= 1.5e+151) {
tmp = (((0.027777777777777776 * Math.pow(y, 4.0)) + -1.0) / ((y * (y * 0.16666666666666666)) + -1.0)) * (1.0 + (-0.5 * (x * x)));
} else if (y <= 4e+154) {
tmp = t_0;
} else {
tmp = y * (0.16666666666666666 * (Math.cos(x) * y));
}
return tmp;
}
def code(x, y): t_0 = math.sinh(y) / y tmp = 0 if y <= 0.064: tmp = math.cos(x) * (1.0 + (0.16666666666666666 * (y * y))) elif y <= 1e+116: tmp = t_0 elif y <= 1.5e+151: tmp = (((0.027777777777777776 * math.pow(y, 4.0)) + -1.0) / ((y * (y * 0.16666666666666666)) + -1.0)) * (1.0 + (-0.5 * (x * x))) elif y <= 4e+154: tmp = t_0 else: tmp = y * (0.16666666666666666 * (math.cos(x) * y)) return tmp
function code(x, y) t_0 = Float64(sinh(y) / y) tmp = 0.0 if (y <= 0.064) tmp = Float64(cos(x) * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))); elseif (y <= 1e+116) tmp = t_0; elseif (y <= 1.5e+151) tmp = Float64(Float64(Float64(Float64(0.027777777777777776 * (y ^ 4.0)) + -1.0) / Float64(Float64(y * Float64(y * 0.16666666666666666)) + -1.0)) * Float64(1.0 + Float64(-0.5 * Float64(x * x)))); elseif (y <= 4e+154) tmp = t_0; else tmp = Float64(y * Float64(0.16666666666666666 * Float64(cos(x) * y))); end return tmp end
function tmp_2 = code(x, y) t_0 = sinh(y) / y; tmp = 0.0; if (y <= 0.064) tmp = cos(x) * (1.0 + (0.16666666666666666 * (y * y))); elseif (y <= 1e+116) tmp = t_0; elseif (y <= 1.5e+151) tmp = (((0.027777777777777776 * (y ^ 4.0)) + -1.0) / ((y * (y * 0.16666666666666666)) + -1.0)) * (1.0 + (-0.5 * (x * x))); elseif (y <= 4e+154) tmp = t_0; else tmp = y * (0.16666666666666666 * (cos(x) * y)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, 0.064], N[(N[Cos[x], $MachinePrecision] * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+116], t$95$0, If[LessEqual[y, 1.5e+151], N[(N[(N[(N[(0.027777777777777776 * N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / N[(N[(y * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+154], t$95$0, N[(y * N[(0.16666666666666666 * N[(N[Cos[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sinh y}{y}\\
\mathbf{if}\;y \leq 0.064:\\
\;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\mathbf{elif}\;y \leq 10^{+116}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+151}:\\
\;\;\;\;\frac{0.027777777777777776 \cdot {y}^{4} + -1}{y \cdot \left(y \cdot 0.16666666666666666\right) + -1} \cdot \left(1 + -0.5 \cdot \left(x \cdot x\right)\right)\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.16666666666666666 \cdot \left(\cos x \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 0.064000000000000001Initial program 100.0%
Taylor expanded in y around 0 87.6%
unpow287.6%
Simplified87.6%
if 0.064000000000000001 < y < 1.00000000000000002e116 or 1.5e151 < y < 4.00000000000000015e154Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/r/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 78.6%
expm1-log1p-u78.6%
expm1-udef78.6%
un-div-inv78.6%
Applied egg-rr78.6%
expm1-def78.6%
expm1-log1p78.6%
Simplified78.6%
if 1.00000000000000002e116 < y < 1.5e151Initial program 100.0%
Taylor expanded in y around 0 9.0%
unpow29.0%
Simplified9.0%
Taylor expanded in x around 0 54.5%
+-commutative54.5%
unpow254.5%
associate-+l+54.5%
*-commutative54.5%
associate-*l*54.5%
+-commutative54.5%
unpow254.5%
associate-*r*54.5%
*-commutative54.5%
fma-udef54.5%
*-commutative54.5%
associate-*r*54.5%
*-commutative54.5%
fma-udef54.5%
*-rgt-identity54.5%
distribute-lft-out54.5%
Simplified54.5%
fma-udef54.5%
flip-+100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
*-commutative100.0%
swap-sqr100.0%
metadata-eval100.0%
pow2100.0%
pow2100.0%
pow-prod-up100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
Applied egg-rr100.0%
if 4.00000000000000015e154 < y Initial program 100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
unpow2100.0%
*-commutative100.0%
associate-*l*100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification88.3%
(FPCore (x y)
:precision binary64
(if (<= y 5.7e-5)
(cos x)
(if (<= y 3.6e+154)
(/ (sinh y) y)
(* y (* 0.16666666666666666 (* (cos x) y))))))
double code(double x, double y) {
double tmp;
if (y <= 5.7e-5) {
tmp = cos(x);
} else if (y <= 3.6e+154) {
tmp = sinh(y) / y;
} else {
tmp = y * (0.16666666666666666 * (cos(x) * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.7d-5) then
tmp = cos(x)
else if (y <= 3.6d+154) then
tmp = sinh(y) / y
else
tmp = y * (0.16666666666666666d0 * (cos(x) * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 5.7e-5) {
tmp = Math.cos(x);
} else if (y <= 3.6e+154) {
tmp = Math.sinh(y) / y;
} else {
tmp = y * (0.16666666666666666 * (Math.cos(x) * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5.7e-5: tmp = math.cos(x) elif y <= 3.6e+154: tmp = math.sinh(y) / y else: tmp = y * (0.16666666666666666 * (math.cos(x) * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 5.7e-5) tmp = cos(x); elseif (y <= 3.6e+154) tmp = Float64(sinh(y) / y); else tmp = Float64(y * Float64(0.16666666666666666 * Float64(cos(x) * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.7e-5) tmp = cos(x); elseif (y <= 3.6e+154) tmp = sinh(y) / y; else tmp = y * (0.16666666666666666 * (cos(x) * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5.7e-5], N[Cos[x], $MachinePrecision], If[LessEqual[y, 3.6e+154], N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], N[(y * N[(0.16666666666666666 * N[(N[Cos[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.7 \cdot 10^{-5}:\\
\;\;\;\;\cos x\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+154}:\\
\;\;\;\;\frac{\sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.16666666666666666 \cdot \left(\cos x \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 5.7000000000000003e-5Initial program 100.0%
Taylor expanded in y around 0 68.6%
if 5.7000000000000003e-5 < y < 3.6000000000000001e154Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/r/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 69.4%
expm1-log1p-u69.4%
expm1-udef69.4%
un-div-inv69.4%
Applied egg-rr69.4%
expm1-def69.5%
expm1-log1p69.5%
Simplified69.5%
if 3.6000000000000001e154 < y Initial program 100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
unpow2100.0%
*-commutative100.0%
associate-*l*100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification72.1%
(FPCore (x y)
:precision binary64
(if (<= y 0.034)
(* (cos x) (+ 1.0 (* 0.16666666666666666 (* y y))))
(if (<= y 3.9e+154)
(/ (sinh y) y)
(* y (* 0.16666666666666666 (* (cos x) y))))))
double code(double x, double y) {
double tmp;
if (y <= 0.034) {
tmp = cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
} else if (y <= 3.9e+154) {
tmp = sinh(y) / y;
} else {
tmp = y * (0.16666666666666666 * (cos(x) * 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.034d0) then
tmp = cos(x) * (1.0d0 + (0.16666666666666666d0 * (y * y)))
else if (y <= 3.9d+154) then
tmp = sinh(y) / y
else
tmp = y * (0.16666666666666666d0 * (cos(x) * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.034) {
tmp = Math.cos(x) * (1.0 + (0.16666666666666666 * (y * y)));
} else if (y <= 3.9e+154) {
tmp = Math.sinh(y) / y;
} else {
tmp = y * (0.16666666666666666 * (Math.cos(x) * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.034: tmp = math.cos(x) * (1.0 + (0.16666666666666666 * (y * y))) elif y <= 3.9e+154: tmp = math.sinh(y) / y else: tmp = y * (0.16666666666666666 * (math.cos(x) * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.034) tmp = Float64(cos(x) * Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y)))); elseif (y <= 3.9e+154) tmp = Float64(sinh(y) / y); else tmp = Float64(y * Float64(0.16666666666666666 * Float64(cos(x) * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.034) tmp = cos(x) * (1.0 + (0.16666666666666666 * (y * y))); elseif (y <= 3.9e+154) tmp = sinh(y) / y; else tmp = y * (0.16666666666666666 * (cos(x) * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.034], N[(N[Cos[x], $MachinePrecision] * N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.9e+154], N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision], N[(y * N[(0.16666666666666666 * N[(N[Cos[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.034:\\
\;\;\;\;\cos x \cdot \left(1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\right)\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{+154}:\\
\;\;\;\;\frac{\sinh y}{y}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.16666666666666666 \cdot \left(\cos x \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 0.034000000000000002Initial program 100.0%
Taylor expanded in y around 0 87.6%
unpow287.6%
Simplified87.6%
if 0.034000000000000002 < y < 3.9000000000000003e154Initial program 100.0%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/r/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 69.4%
expm1-log1p-u69.4%
expm1-udef69.4%
un-div-inv69.4%
Applied egg-rr69.4%
expm1-def69.5%
expm1-log1p69.5%
Simplified69.5%
if 3.9000000000000003e154 < y Initial program 100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
unpow2100.0%
*-commutative100.0%
associate-*l*100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification86.4%
(FPCore (x y)
:precision binary64
(if (<= y 5.7e-5)
(cos x)
(if (or (<= y 3.4e+198) (not (<= y 1.76e+255)))
(* (+ 1.0 (* -0.5 (* x x))) (+ 1.0 (* y (* y 0.16666666666666666))))
(+ 1.0 (* 0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 5.7e-5) {
tmp = cos(x);
} else if ((y <= 3.4e+198) || !(y <= 1.76e+255)) {
tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
} else {
tmp = 1.0 + (0.16666666666666666 * (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 <= 5.7d-5) then
tmp = cos(x)
else if ((y <= 3.4d+198) .or. (.not. (y <= 1.76d+255))) then
tmp = (1.0d0 + ((-0.5d0) * (x * x))) * (1.0d0 + (y * (y * 0.16666666666666666d0)))
else
tmp = 1.0d0 + (0.16666666666666666d0 * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 5.7e-5) {
tmp = Math.cos(x);
} else if ((y <= 3.4e+198) || !(y <= 1.76e+255)) {
tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
} else {
tmp = 1.0 + (0.16666666666666666 * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5.7e-5: tmp = math.cos(x) elif (y <= 3.4e+198) or not (y <= 1.76e+255): tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666))) else: tmp = 1.0 + (0.16666666666666666 * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 5.7e-5) tmp = cos(x); elseif ((y <= 3.4e+198) || !(y <= 1.76e+255)) tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(x * x))) * Float64(1.0 + Float64(y * Float64(y * 0.16666666666666666)))); else tmp = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.7e-5) tmp = cos(x); elseif ((y <= 3.4e+198) || ~((y <= 1.76e+255))) tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666))); else tmp = 1.0 + (0.16666666666666666 * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5.7e-5], N[Cos[x], $MachinePrecision], If[Or[LessEqual[y, 3.4e+198], N[Not[LessEqual[y, 1.76e+255]], $MachinePrecision]], N[(N[(1.0 + N[(-0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(y * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.7 \cdot 10^{-5}:\\
\;\;\;\;\cos x\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+198} \lor \neg \left(y \leq 1.76 \cdot 10^{+255}\right):\\
\;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 5.7000000000000003e-5Initial program 100.0%
Taylor expanded in y around 0 68.6%
if 5.7000000000000003e-5 < y < 3.4e198 or 1.7600000000000001e255 < y Initial program 100.0%
Taylor expanded in y around 0 29.4%
unpow229.4%
Simplified29.4%
Taylor expanded in x around 0 18.4%
+-commutative18.4%
unpow218.4%
associate-+l+18.4%
*-commutative18.4%
associate-*l*18.4%
+-commutative18.4%
unpow218.4%
associate-*r*18.4%
*-commutative18.4%
fma-udef18.4%
*-commutative18.4%
associate-*r*18.4%
*-commutative18.4%
fma-udef18.4%
*-rgt-identity18.4%
distribute-lft-out33.2%
Simplified33.2%
fma-udef33.2%
*-commutative33.2%
Applied egg-rr33.2%
if 3.4e198 < y < 1.7600000000000001e255Initial program 100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around 0 93.8%
unpow293.8%
Simplified93.8%
Final simplification63.7%
(FPCore (x y)
:precision binary64
(if (<= y 2.25e-57)
1.0
(if (or (<= y 5e+198) (not (<= y 1e+256)))
(* (+ 1.0 (* -0.5 (* x x))) (+ 1.0 (* y (* y 0.16666666666666666))))
(+ 1.0 (* 0.16666666666666666 (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= 2.25e-57) {
tmp = 1.0;
} else if ((y <= 5e+198) || !(y <= 1e+256)) {
tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
} else {
tmp = 1.0 + (0.16666666666666666 * (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 <= 2.25d-57) then
tmp = 1.0d0
else if ((y <= 5d+198) .or. (.not. (y <= 1d+256))) then
tmp = (1.0d0 + ((-0.5d0) * (x * x))) * (1.0d0 + (y * (y * 0.16666666666666666d0)))
else
tmp = 1.0d0 + (0.16666666666666666d0 * (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.25e-57) {
tmp = 1.0;
} else if ((y <= 5e+198) || !(y <= 1e+256)) {
tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666)));
} else {
tmp = 1.0 + (0.16666666666666666 * (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.25e-57: tmp = 1.0 elif (y <= 5e+198) or not (y <= 1e+256): tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666))) else: tmp = 1.0 + (0.16666666666666666 * (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.25e-57) tmp = 1.0; elseif ((y <= 5e+198) || !(y <= 1e+256)) tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(x * x))) * Float64(1.0 + Float64(y * Float64(y * 0.16666666666666666)))); else tmp = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.25e-57) tmp = 1.0; elseif ((y <= 5e+198) || ~((y <= 1e+256))) tmp = (1.0 + (-0.5 * (x * x))) * (1.0 + (y * (y * 0.16666666666666666))); else tmp = 1.0 + (0.16666666666666666 * (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.25e-57], 1.0, If[Or[LessEqual[y, 5e+198], N[Not[LessEqual[y, 1e+256]], $MachinePrecision]], N[(N[(1.0 + N[(-0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(y * N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.25 \cdot 10^{-57}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+198} \lor \neg \left(y \leq 10^{+256}\right):\\
\;\;\;\;\left(1 + -0.5 \cdot \left(x \cdot x\right)\right) \cdot \left(1 + y \cdot \left(y \cdot 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 2.24999999999999986e-57Initial program 100.0%
add-log-exp99.1%
*-un-lft-identity99.1%
log-prod99.1%
metadata-eval99.1%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/r/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 64.4%
Taylor expanded in y around 0 38.1%
if 2.24999999999999986e-57 < y < 5.00000000000000049e198 or 1e256 < y Initial program 100.0%
Taylor expanded in y around 0 49.7%
unpow249.7%
Simplified49.7%
Taylor expanded in x around 0 30.2%
+-commutative30.2%
unpow230.2%
associate-+l+30.2%
*-commutative30.2%
associate-*l*30.2%
+-commutative30.2%
unpow230.2%
associate-*r*30.2%
*-commutative30.2%
fma-udef30.2%
*-commutative30.2%
associate-*r*30.2%
*-commutative30.2%
fma-udef30.2%
*-rgt-identity30.2%
distribute-lft-out40.8%
Simplified40.8%
fma-udef40.8%
*-commutative40.8%
Applied egg-rr40.8%
if 5.00000000000000049e198 < y < 1e256Initial program 100.0%
Taylor expanded in y around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around 0 93.8%
unpow293.8%
Simplified93.8%
Final simplification42.2%
(FPCore (x y) :precision binary64 (if (or (<= y 1.35e+30) (not (<= y 2.05e+151))) (+ 1.0 (* 0.16666666666666666 (* y y))) (* (* y (* y (* x x))) -0.08333333333333333)))
double code(double x, double y) {
double tmp;
if ((y <= 1.35e+30) || !(y <= 2.05e+151)) {
tmp = 1.0 + (0.16666666666666666 * (y * y));
} else {
tmp = (y * (y * (x * x))) * -0.08333333333333333;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= 1.35d+30) .or. (.not. (y <= 2.05d+151))) then
tmp = 1.0d0 + (0.16666666666666666d0 * (y * y))
else
tmp = (y * (y * (x * x))) * (-0.08333333333333333d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 1.35e+30) || !(y <= 2.05e+151)) {
tmp = 1.0 + (0.16666666666666666 * (y * y));
} else {
tmp = (y * (y * (x * x))) * -0.08333333333333333;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 1.35e+30) or not (y <= 2.05e+151): tmp = 1.0 + (0.16666666666666666 * (y * y)) else: tmp = (y * (y * (x * x))) * -0.08333333333333333 return tmp
function code(x, y) tmp = 0.0 if ((y <= 1.35e+30) || !(y <= 2.05e+151)) tmp = Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))); else tmp = Float64(Float64(y * Float64(y * Float64(x * x))) * -0.08333333333333333); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 1.35e+30) || ~((y <= 2.05e+151))) tmp = 1.0 + (0.16666666666666666 * (y * y)); else tmp = (y * (y * (x * x))) * -0.08333333333333333; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 1.35e+30], N[Not[LessEqual[y, 2.05e+151]], $MachinePrecision]], N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.08333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+30} \lor \neg \left(y \leq 2.05 \cdot 10^{+151}\right):\\
\;\;\;\;1 + 0.16666666666666666 \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot \left(y \cdot \left(x \cdot x\right)\right)\right) \cdot -0.08333333333333333\\
\end{array}
\end{array}
if y < 1.3499999999999999e30 or 2.0499999999999999e151 < y Initial program 100.0%
Taylor expanded in y around 0 86.5%
unpow286.5%
Simplified86.5%
Taylor expanded in x around 0 55.4%
unpow255.4%
Simplified55.4%
if 1.3499999999999999e30 < y < 2.0499999999999999e151Initial program 100.0%
Taylor expanded in y around 0 5.9%
unpow25.9%
Simplified5.9%
Taylor expanded in x around 0 28.2%
+-commutative28.2%
unpow228.2%
associate-+l+28.2%
*-commutative28.2%
associate-*l*28.2%
+-commutative28.2%
unpow228.2%
associate-*r*28.2%
*-commutative28.2%
fma-udef28.2%
*-commutative28.2%
associate-*r*28.2%
*-commutative28.2%
fma-udef28.2%
*-rgt-identity28.2%
distribute-lft-out28.2%
Simplified28.2%
Taylor expanded in y around inf 28.2%
unpow228.2%
+-commutative28.2%
unpow228.2%
associate-*r*28.2%
*-commutative28.2%
fma-udef28.2%
Simplified28.2%
Taylor expanded in x around inf 25.8%
*-commutative25.8%
unpow225.8%
unpow225.8%
associate-*l*25.8%
Simplified25.8%
Final simplification52.1%
(FPCore (x y) :precision binary64 (if (<= y 0.96) 1.0 (* 0.16666666666666666 (* y y))))
double code(double x, double y) {
double tmp;
if (y <= 0.96) {
tmp = 1.0;
} else {
tmp = 0.16666666666666666 * (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 <= 0.96d0) then
tmp = 1.0d0
else
tmp = 0.16666666666666666d0 * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.96) {
tmp = 1.0;
} else {
tmp = 0.16666666666666666 * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.96: tmp = 1.0 else: tmp = 0.16666666666666666 * (y * y) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.96) tmp = 1.0; else tmp = Float64(0.16666666666666666 * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.96) tmp = 1.0; else tmp = 0.16666666666666666 * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.96], 1.0, N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.96:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if y < 0.95999999999999996Initial program 100.0%
add-log-exp99.2%
*-un-lft-identity99.2%
log-prod99.2%
metadata-eval99.2%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/r/99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 63.9%
Taylor expanded in y around 0 39.9%
if 0.95999999999999996 < y Initial program 100.0%
Taylor expanded in y around 0 47.3%
unpow247.3%
Simplified47.3%
Taylor expanded in y around inf 47.1%
unpow247.1%
*-commutative47.1%
associate-*l*47.1%
associate-*r*47.1%
*-commutative47.1%
associate-*l*47.1%
Simplified47.1%
Taylor expanded in x around 0 39.4%
unpow239.4%
Simplified39.4%
Final simplification39.8%
(FPCore (x y) :precision binary64 (+ 1.0 (* 0.16666666666666666 (* y y))))
double code(double x, double y) {
return 1.0 + (0.16666666666666666 * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + (0.16666666666666666d0 * (y * y))
end function
public static double code(double x, double y) {
return 1.0 + (0.16666666666666666 * (y * y));
}
def code(x, y): return 1.0 + (0.16666666666666666 * (y * y))
function code(x, y) return Float64(1.0 + Float64(0.16666666666666666 * Float64(y * y))) end
function tmp = code(x, y) tmp = 1.0 + (0.16666666666666666 * (y * y)); end
code[x_, y_] := N[(1.0 + N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 0.16666666666666666 \cdot \left(y \cdot y\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 77.7%
unpow277.7%
Simplified77.7%
Taylor expanded in x around 0 49.7%
unpow249.7%
Simplified49.7%
Final simplification49.7%
(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%
add-log-exp99.4%
*-un-lft-identity99.4%
log-prod99.4%
metadata-eval99.4%
add-log-exp100.0%
clear-num100.0%
un-div-inv100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
associate-/r/99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 66.8%
Taylor expanded in y around 0 30.8%
Final simplification30.8%
herbie shell --seed 2023214
(FPCore (x y)
:name "Linear.Quaternion:$csin from linear-1.19.1.3"
:precision binary64
(* (cos x) (/ (sinh y) y)))