
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (* (/ (sin b) (fma (sin a) (- (sin b)) (* (cos a) (cos b)))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(sin(a), -sin(b), (cos(a) * cos(b)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))) * r) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)} \cdot r
\end{array}
Initial program 72.4%
associate-/l*72.3%
remove-double-neg72.3%
sin-neg72.3%
neg-mul-172.3%
associate-/r*72.3%
associate-/l*72.4%
*-commutative72.4%
associate-*l/72.4%
associate-/l*72.4%
sin-neg72.4%
distribute-lft-neg-in72.4%
distribute-rgt-neg-in72.4%
associate-/l*72.4%
metadata-eval72.4%
/-rgt-identity72.4%
+-commutative72.4%
Simplified72.4%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
*-commutative99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 72.4%
associate-/l*72.3%
+-commutative72.3%
Simplified72.3%
associate-/r/72.4%
Applied egg-rr72.4%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 72.4%
associate-/l*72.3%
remove-double-neg72.3%
sin-neg72.3%
neg-mul-172.3%
associate-/r*72.3%
associate-/l*72.4%
*-commutative72.4%
associate-*l/72.4%
associate-/l*72.4%
sin-neg72.4%
distribute-lft-neg-in72.4%
distribute-rgt-neg-in72.4%
associate-/l*72.4%
metadata-eval72.4%
/-rgt-identity72.4%
+-commutative72.4%
Simplified72.4%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (fma 1.0 (- (sin a)) (/ (cos b) (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
return r / fma(1.0, -sin(a), (cos(b) / (sin(b) / cos(a))));
}
function code(r, a, b) return Float64(r / fma(1.0, Float64(-sin(a)), Float64(cos(b) / Float64(sin(b) / cos(a))))) end
code[r_, a_, b_] := N[(r / N[(1.0 * (-N[Sin[a], $MachinePrecision]) + N[(N[Cos[b], $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\mathsf{fma}\left(1, -\sin a, \frac{\cos b}{\frac{\sin b}{\cos a}}\right)}
\end{array}
Initial program 72.4%
associate-/l*72.3%
+-commutative72.3%
Simplified72.3%
associate-/r/72.4%
Applied egg-rr72.4%
cos-sum99.5%
Applied egg-rr99.5%
Taylor expanded in r around 0 99.4%
associate-/l*99.3%
*-commutative99.3%
*-commutative99.3%
div-sub99.3%
sub-neg99.3%
*-rgt-identity99.3%
associate-*r/99.3%
distribute-neg-frac99.3%
distribute-rgt-neg-out99.3%
*-rgt-identity99.3%
associate-*r/99.3%
+-commutative99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return sin(b) * (r / (cos(a) * cos(b)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / (cos(a) * cos(b)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / (Math.cos(a) * Math.cos(b)));
}
def code(r, a, b): return math.sin(b) * (r / (math.cos(a) * math.cos(b)))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(cos(a) * cos(b)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / (cos(a) * cos(b))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b}
\end{array}
Initial program 72.4%
associate-/l*72.3%
+-commutative72.3%
Simplified72.3%
associate-/r/72.4%
Applied egg-rr72.4%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult73.9%
div-sub73.9%
cos-diff73.8%
add-sqr-sqrt36.6%
sqrt-unprod73.2%
sqr-neg73.2%
sqrt-unprod36.6%
add-sqr-sqrt71.7%
distribute-lft-neg-in71.7%
sub-neg71.7%
cos-sum73.8%
Applied egg-rr73.8%
+-inverses73.8%
Simplified73.8%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0042) (not (<= a 1.6))) (* (sin b) (/ r (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0042) || !(a <= 1.6)) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = sin(b) * (r / cos(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-0.0042d0)) .or. (.not. (a <= 1.6d0))) then
tmp = sin(b) * (r / cos(a))
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0042) || !(a <= 1.6)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0042) or not (a <= 1.6): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0042) || !(a <= 1.6)) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.0042) || ~((a <= 1.6))) tmp = sin(b) * (r / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0042], N[Not[LessEqual[a, 1.6]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0042 \lor \neg \left(a \leq 1.6\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -0.00419999999999999974 or 1.6000000000000001 < a Initial program 49.9%
associate-/l*49.9%
+-commutative49.9%
Simplified49.9%
associate-/r/49.9%
Applied egg-rr49.9%
Taylor expanded in b around 0 50.4%
if -0.00419999999999999974 < a < 1.6000000000000001Initial program 98.2%
associate-/l*98.1%
remove-double-neg98.1%
sin-neg98.1%
neg-mul-198.1%
associate-/r*98.1%
associate-/l*98.2%
*-commutative98.2%
associate-*l/98.3%
associate-/l*98.3%
sin-neg98.3%
distribute-lft-neg-in98.3%
distribute-rgt-neg-in98.3%
associate-/l*98.3%
metadata-eval98.3%
/-rgt-identity98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in a around 0 98.2%
associate-/l*98.1%
associate-/r/98.3%
Simplified98.3%
Final simplification72.6%
(FPCore (r a b) :precision binary64 (if (<= a -0.016) (/ r (/ (cos a) (sin b))) (if (<= a 1.6) (* (sin b) (/ r (cos b))) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.016) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 1.6) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = sin(b) * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.016d0)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 1.6d0) then
tmp = sin(b) * (r / cos(b))
else
tmp = sin(b) * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.016) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 1.6) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.016: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 1.6: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.016) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 1.6) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(sin(b) * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.016) tmp = r / (cos(a) / sin(b)); elseif (a <= 1.6) tmp = sin(b) * (r / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.016], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.6], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.016:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 1.6:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -0.016Initial program 46.3%
associate-/l*46.3%
+-commutative46.3%
Simplified46.3%
Taylor expanded in b around 0 47.7%
if -0.016 < a < 1.6000000000000001Initial program 98.2%
associate-/l*98.1%
remove-double-neg98.1%
sin-neg98.1%
neg-mul-198.1%
associate-/r*98.1%
associate-/l*98.2%
*-commutative98.2%
associate-*l/98.3%
associate-/l*98.3%
sin-neg98.3%
distribute-lft-neg-in98.3%
distribute-rgt-neg-in98.3%
associate-/l*98.3%
metadata-eval98.3%
/-rgt-identity98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in a around 0 98.2%
associate-/l*98.1%
associate-/r/98.3%
Simplified98.3%
if 1.6000000000000001 < a Initial program 53.4%
associate-/l*53.3%
+-commutative53.3%
Simplified53.3%
associate-/r/53.4%
Applied egg-rr53.4%
Taylor expanded in b around 0 53.0%
Final simplification72.7%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ b a)))))
double code(double r, double a, double b) {
return sin(b) * (r / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((b + a)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((b + a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((b + a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(b + a\right)}
\end{array}
Initial program 72.4%
associate-/l*72.3%
+-commutative72.3%
Simplified72.3%
associate-/r/72.4%
Applied egg-rr72.4%
Final simplification72.4%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / cos(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 72.4%
associate-/l*72.3%
+-commutative72.3%
Simplified72.3%
associate-/r/72.4%
Applied egg-rr72.4%
Taylor expanded in b around 0 52.1%
Final simplification52.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -1100000000.0) (not (<= b 4.2))) (* (sin b) r) (/ r (* (cos (+ b a)) (+ (* b 0.16666666666666666) (/ 1.0 b))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1100000000.0) || !(b <= 4.2)) {
tmp = sin(b) * r;
} else {
tmp = r / (cos((b + a)) * ((b * 0.16666666666666666) + (1.0 / b)));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-1100000000.0d0)) .or. (.not. (b <= 4.2d0))) then
tmp = sin(b) * r
else
tmp = r / (cos((b + a)) * ((b * 0.16666666666666666d0) + (1.0d0 / b)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -1100000000.0) || !(b <= 4.2)) {
tmp = Math.sin(b) * r;
} else {
tmp = r / (Math.cos((b + a)) * ((b * 0.16666666666666666) + (1.0 / b)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1100000000.0) or not (b <= 4.2): tmp = math.sin(b) * r else: tmp = r / (math.cos((b + a)) * ((b * 0.16666666666666666) + (1.0 / b))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1100000000.0) || !(b <= 4.2)) tmp = Float64(sin(b) * r); else tmp = Float64(r / Float64(cos(Float64(b + a)) * Float64(Float64(b * 0.16666666666666666) + Float64(1.0 / b)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1100000000.0) || ~((b <= 4.2))) tmp = sin(b) * r; else tmp = r / (cos((b + a)) * ((b * 0.16666666666666666) + (1.0 / b))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1100000000.0], N[Not[LessEqual[b, 4.2]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(r / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] * N[(N[(b * 0.16666666666666666), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1100000000 \lor \neg \left(b \leq 4.2\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\cos \left(b + a\right) \cdot \left(b \cdot 0.16666666666666666 + \frac{1}{b}\right)}\\
\end{array}
\end{array}
if b < -1.1e9 or 4.20000000000000018 < b Initial program 50.0%
associate-/l*50.0%
remove-double-neg50.0%
sin-neg50.0%
neg-mul-150.0%
associate-/r*50.0%
associate-/l*50.0%
*-commutative50.0%
associate-*l/50.0%
associate-/l*50.0%
sin-neg50.0%
distribute-lft-neg-in50.0%
distribute-rgt-neg-in50.0%
associate-/l*50.0%
metadata-eval50.0%
/-rgt-identity50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in a around 0 49.3%
associate-/l*49.3%
associate-/r/49.4%
Simplified49.4%
Taylor expanded in b around 0 10.9%
if -1.1e9 < b < 4.20000000000000018Initial program 95.8%
associate-/l*95.6%
+-commutative95.6%
Simplified95.6%
clear-num95.5%
associate-/r/95.6%
Applied egg-rr95.6%
Taylor expanded in b around 0 95.7%
Final simplification52.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -850000000.0) (not (<= b 11.0))) (* (sin b) r) (* b (/ r (cos (+ b a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -850000000.0) || !(b <= 11.0)) {
tmp = sin(b) * r;
} else {
tmp = b * (r / cos((b + a)));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-850000000.0d0)) .or. (.not. (b <= 11.0d0))) then
tmp = sin(b) * r
else
tmp = b * (r / cos((b + a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -850000000.0) || !(b <= 11.0)) {
tmp = Math.sin(b) * r;
} else {
tmp = b * (r / Math.cos((b + a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -850000000.0) or not (b <= 11.0): tmp = math.sin(b) * r else: tmp = b * (r / math.cos((b + a))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -850000000.0) || !(b <= 11.0)) tmp = Float64(sin(b) * r); else tmp = Float64(b * Float64(r / cos(Float64(b + a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -850000000.0) || ~((b <= 11.0))) tmp = sin(b) * r; else tmp = b * (r / cos((b + a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -850000000.0], N[Not[LessEqual[b, 11.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(b * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -850000000 \lor \neg \left(b \leq 11\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -8.5e8 or 11 < b Initial program 50.0%
associate-/l*50.0%
remove-double-neg50.0%
sin-neg50.0%
neg-mul-150.0%
associate-/r*50.0%
associate-/l*50.0%
*-commutative50.0%
associate-*l/50.0%
associate-/l*50.0%
sin-neg50.0%
distribute-lft-neg-in50.0%
distribute-rgt-neg-in50.0%
associate-/l*50.0%
metadata-eval50.0%
/-rgt-identity50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in a around 0 49.3%
associate-/l*49.3%
associate-/r/49.4%
Simplified49.4%
Taylor expanded in b around 0 10.9%
if -8.5e8 < b < 11Initial program 95.8%
associate-/l*95.6%
+-commutative95.6%
Simplified95.6%
associate-/r/95.8%
Applied egg-rr95.8%
Taylor expanded in b around 0 95.4%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -920000000.0) (not (<= b 17.0))) (* (sin b) r) (/ (* b r) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -920000000.0) || !(b <= 17.0)) {
tmp = sin(b) * r;
} else {
tmp = (b * r) / cos((b + a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-920000000.0d0)) .or. (.not. (b <= 17.0d0))) then
tmp = sin(b) * r
else
tmp = (b * r) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -920000000.0) || !(b <= 17.0)) {
tmp = Math.sin(b) * r;
} else {
tmp = (b * r) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -920000000.0) or not (b <= 17.0): tmp = math.sin(b) * r else: tmp = (b * r) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -920000000.0) || !(b <= 17.0)) tmp = Float64(sin(b) * r); else tmp = Float64(Float64(b * r) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -920000000.0) || ~((b <= 17.0))) tmp = sin(b) * r; else tmp = (b * r) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -920000000.0], N[Not[LessEqual[b, 17.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -920000000 \lor \neg \left(b \leq 17\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -9.2e8 or 17 < b Initial program 50.0%
associate-/l*50.0%
remove-double-neg50.0%
sin-neg50.0%
neg-mul-150.0%
associate-/r*50.0%
associate-/l*50.0%
*-commutative50.0%
associate-*l/50.0%
associate-/l*50.0%
sin-neg50.0%
distribute-lft-neg-in50.0%
distribute-rgt-neg-in50.0%
associate-/l*50.0%
metadata-eval50.0%
/-rgt-identity50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in a around 0 49.3%
associate-/l*49.3%
associate-/r/49.4%
Simplified49.4%
Taylor expanded in b around 0 10.9%
if -9.2e8 < b < 17Initial program 95.8%
+-commutative95.8%
Simplified95.8%
Taylor expanded in b around 0 95.4%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -38000000.0) (not (<= b 2.9e+21))) (* (sin b) r) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -38000000.0) || !(b <= 2.9e+21)) {
tmp = sin(b) * r;
} else {
tmp = r * (b / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-38000000.0d0)) .or. (.not. (b <= 2.9d+21))) then
tmp = sin(b) * r
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -38000000.0) || !(b <= 2.9e+21)) {
tmp = Math.sin(b) * r;
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -38000000.0) or not (b <= 2.9e+21): tmp = math.sin(b) * r else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -38000000.0) || !(b <= 2.9e+21)) tmp = Float64(sin(b) * r); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -38000000.0) || ~((b <= 2.9e+21))) tmp = sin(b) * r; else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -38000000.0], N[Not[LessEqual[b, 2.9e+21]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -38000000 \lor \neg \left(b \leq 2.9 \cdot 10^{+21}\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -3.8e7 or 2.9e21 < b Initial program 49.8%
associate-/l*49.8%
remove-double-neg49.8%
sin-neg49.8%
neg-mul-149.8%
associate-/r*49.8%
associate-/l*49.8%
*-commutative49.8%
associate-*l/49.8%
associate-/l*49.8%
sin-neg49.8%
distribute-lft-neg-in49.8%
distribute-rgt-neg-in49.8%
associate-/l*49.8%
metadata-eval49.8%
/-rgt-identity49.8%
+-commutative49.8%
Simplified49.8%
Taylor expanded in a around 0 49.2%
associate-/l*49.2%
associate-/r/49.2%
Simplified49.2%
Taylor expanded in b around 0 11.0%
if -3.8e7 < b < 2.9e21Initial program 94.6%
associate-/l*94.4%
remove-double-neg94.4%
sin-neg94.4%
neg-mul-194.4%
associate-/r*94.4%
associate-/l*94.6%
*-commutative94.6%
associate-*l/94.5%
associate-/l*94.5%
sin-neg94.5%
distribute-lft-neg-in94.5%
distribute-rgt-neg-in94.5%
associate-/l*94.5%
metadata-eval94.5%
/-rgt-identity94.5%
+-commutative94.5%
Simplified94.5%
Taylor expanded in b around 0 92.7%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -38000000.0) (not (<= b 6.4e+21))) (* (sin b) r) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -38000000.0) || !(b <= 6.4e+21)) {
tmp = sin(b) * r;
} else {
tmp = b * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-38000000.0d0)) .or. (.not. (b <= 6.4d+21))) then
tmp = sin(b) * r
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -38000000.0) || !(b <= 6.4e+21)) {
tmp = Math.sin(b) * r;
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -38000000.0) or not (b <= 6.4e+21): tmp = math.sin(b) * r else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -38000000.0) || !(b <= 6.4e+21)) tmp = Float64(sin(b) * r); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -38000000.0) || ~((b <= 6.4e+21))) tmp = sin(b) * r; else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -38000000.0], N[Not[LessEqual[b, 6.4e+21]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -38000000 \lor \neg \left(b \leq 6.4 \cdot 10^{+21}\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -3.8e7 or 6.4e21 < b Initial program 49.8%
associate-/l*49.8%
remove-double-neg49.8%
sin-neg49.8%
neg-mul-149.8%
associate-/r*49.8%
associate-/l*49.8%
*-commutative49.8%
associate-*l/49.8%
associate-/l*49.8%
sin-neg49.8%
distribute-lft-neg-in49.8%
distribute-rgt-neg-in49.8%
associate-/l*49.8%
metadata-eval49.8%
/-rgt-identity49.8%
+-commutative49.8%
Simplified49.8%
Taylor expanded in a around 0 49.2%
associate-/l*49.2%
associate-/r/49.2%
Simplified49.2%
Taylor expanded in b around 0 11.0%
if -3.8e7 < b < 6.4e21Initial program 94.6%
associate-/l*94.4%
remove-double-neg94.4%
sin-neg94.4%
neg-mul-194.4%
associate-/r*94.4%
associate-/l*94.6%
*-commutative94.6%
associate-*l/94.5%
associate-/l*94.5%
sin-neg94.5%
distribute-lft-neg-in94.5%
distribute-rgt-neg-in94.5%
associate-/l*94.5%
metadata-eval94.5%
/-rgt-identity94.5%
+-commutative94.5%
Simplified94.5%
Taylor expanded in b around 0 92.7%
*-commutative92.7%
clear-num92.5%
un-div-inv92.5%
Applied egg-rr92.5%
associate-/r/92.7%
Simplified92.7%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -36000000.0) (not (<= b 1.35e+22))) (* (sin b) r) (/ (* b r) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -36000000.0) || !(b <= 1.35e+22)) {
tmp = sin(b) * r;
} else {
tmp = (b * r) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-36000000.0d0)) .or. (.not. (b <= 1.35d+22))) then
tmp = sin(b) * r
else
tmp = (b * r) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -36000000.0) || !(b <= 1.35e+22)) {
tmp = Math.sin(b) * r;
} else {
tmp = (b * r) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -36000000.0) or not (b <= 1.35e+22): tmp = math.sin(b) * r else: tmp = (b * r) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -36000000.0) || !(b <= 1.35e+22)) tmp = Float64(sin(b) * r); else tmp = Float64(Float64(b * r) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -36000000.0) || ~((b <= 1.35e+22))) tmp = sin(b) * r; else tmp = (b * r) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -36000000.0], N[Not[LessEqual[b, 1.35e+22]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision], N[(N[(b * r), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -36000000 \lor \neg \left(b \leq 1.35 \cdot 10^{+22}\right):\\
\;\;\;\;\sin b \cdot r\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot r}{\cos a}\\
\end{array}
\end{array}
if b < -3.6e7 or 1.3500000000000001e22 < b Initial program 49.8%
associate-/l*49.8%
remove-double-neg49.8%
sin-neg49.8%
neg-mul-149.8%
associate-/r*49.8%
associate-/l*49.8%
*-commutative49.8%
associate-*l/49.8%
associate-/l*49.8%
sin-neg49.8%
distribute-lft-neg-in49.8%
distribute-rgt-neg-in49.8%
associate-/l*49.8%
metadata-eval49.8%
/-rgt-identity49.8%
+-commutative49.8%
Simplified49.8%
Taylor expanded in a around 0 49.2%
associate-/l*49.2%
associate-/r/49.2%
Simplified49.2%
Taylor expanded in b around 0 11.0%
if -3.6e7 < b < 1.3500000000000001e22Initial program 94.6%
associate-/l*94.4%
remove-double-neg94.4%
sin-neg94.4%
neg-mul-194.4%
associate-/r*94.4%
associate-/l*94.6%
*-commutative94.6%
associate-*l/94.5%
associate-/l*94.5%
sin-neg94.5%
distribute-lft-neg-in94.5%
distribute-rgt-neg-in94.5%
associate-/l*94.5%
metadata-eval94.5%
/-rgt-identity94.5%
+-commutative94.5%
Simplified94.5%
Taylor expanded in b around 0 92.7%
Final simplification52.2%
(FPCore (r a b) :precision binary64 (* (sin b) r))
double code(double r, double a, double b) {
return sin(b) * r;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * r
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * r;
}
def code(r, a, b): return math.sin(b) * r
function code(r, a, b) return Float64(sin(b) * r) end
function tmp = code(r, a, b) tmp = sin(b) * r; end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot r
\end{array}
Initial program 72.4%
associate-/l*72.3%
remove-double-neg72.3%
sin-neg72.3%
neg-mul-172.3%
associate-/r*72.3%
associate-/l*72.4%
*-commutative72.4%
associate-*l/72.4%
associate-/l*72.4%
sin-neg72.4%
distribute-lft-neg-in72.4%
distribute-rgt-neg-in72.4%
associate-/l*72.4%
metadata-eval72.4%
/-rgt-identity72.4%
+-commutative72.4%
Simplified72.4%
Taylor expanded in a around 0 56.6%
associate-/l*56.5%
associate-/r/56.6%
Simplified56.6%
Taylor expanded in b around 0 36.7%
Final simplification36.7%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b * r
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 72.4%
associate-/l*72.3%
remove-double-neg72.3%
sin-neg72.3%
neg-mul-172.3%
associate-/r*72.3%
associate-/l*72.4%
*-commutative72.4%
associate-*l/72.4%
associate-/l*72.4%
sin-neg72.4%
distribute-lft-neg-in72.4%
distribute-rgt-neg-in72.4%
associate-/l*72.4%
metadata-eval72.4%
/-rgt-identity72.4%
+-commutative72.4%
Simplified72.4%
Taylor expanded in b around 0 48.3%
Taylor expanded in a around 0 32.7%
Final simplification32.7%
herbie shell --seed 2024021
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))