
(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 15 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 (/ r (- (/ (* (cos a) (cos b)) (sin b)) (sin a))))
double code(double r, double a, double b) {
return 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 = r / (((cos(a) * cos(b)) / sin(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(a) * Math.cos(b)) / Math.sin(b)) - Math.sin(a));
}
def code(r, a, b): return r / (((math.cos(a) * math.cos(b)) / math.sin(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(a) * cos(b)) / sin(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / (((cos(a) * cos(b)) / sin(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a \cdot \cos b}{\sin b} - \sin a}
\end{array}
Initial program 77.8%
remove-double-neg77.8%
associate-/l*77.8%
distribute-frac-neg77.8%
associate-/r/77.8%
distribute-rgt-neg-in77.8%
sin-neg77.8%
neg-mul-177.8%
*-commutative77.8%
associate-/l*77.8%
associate-/r/77.8%
associate-/l/77.8%
sin-neg77.8%
distribute-lft-neg-in77.8%
distribute-rgt-neg-in77.8%
associate-/l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
+-commutative77.8%
cos-sum99.5%
div-sub99.5%
*-commutative99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (* (cos a) (/ (cos b) (sin b))) (sin a))))
double code(double r, double a, double b) {
return 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 = r / ((cos(a) * (cos(b) / sin(b))) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) * (Math.cos(b) / Math.sin(b))) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) * (math.cos(b) / math.sin(b))) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) * Float64(cos(b) / sin(b))) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) * (cos(b) / sin(b))) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] * N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos a \cdot \frac{\cos b}{\sin b} - \sin a}
\end{array}
Initial program 77.8%
remove-double-neg77.8%
associate-/l*77.8%
distribute-frac-neg77.8%
associate-/r/77.8%
distribute-rgt-neg-in77.8%
sin-neg77.8%
neg-mul-177.8%
*-commutative77.8%
associate-/l*77.8%
associate-/r/77.8%
associate-/l/77.8%
sin-neg77.8%
distribute-lft-neg-in77.8%
distribute-rgt-neg-in77.8%
associate-/l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
+-commutative77.8%
cos-sum99.5%
div-sub99.5%
*-commutative99.5%
Applied egg-rr99.5%
Taylor expanded in r around 0 99.5%
associate-*r/99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (* 0.5 (* 2.0 (cos (+ a b)))) (sin b)) (sin a))))
double code(double r, double a, double b) {
return r / (((0.5 * (2.0 * cos((a + 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 / (((0.5d0 * (2.0d0 * cos((a + b)))) / sin(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / (((0.5 * (2.0 * Math.cos((a + b)))) / Math.sin(b)) - Math.sin(a));
}
def code(r, a, b): return r / (((0.5 * (2.0 * math.cos((a + b)))) / math.sin(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(0.5 * Float64(2.0 * cos(Float64(a + b)))) / sin(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / (((0.5 * (2.0 * cos((a + b)))) / sin(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(0.5 * N[(2.0 * N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{0.5 \cdot \left(2 \cdot \cos \left(a + b\right)\right)}{\sin b} - \sin a}
\end{array}
Initial program 77.8%
remove-double-neg77.8%
associate-/l*77.8%
distribute-frac-neg77.8%
associate-/r/77.8%
distribute-rgt-neg-in77.8%
sin-neg77.8%
neg-mul-177.8%
*-commutative77.8%
associate-/l*77.8%
associate-/r/77.8%
associate-/l/77.8%
sin-neg77.8%
distribute-lft-neg-in77.8%
distribute-rgt-neg-in77.8%
associate-/l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
+-commutative77.8%
cos-sum99.5%
div-sub99.5%
*-commutative99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
cos-mult79.0%
clear-num79.0%
+-commutative79.0%
cos-diff78.8%
*-commutative78.8%
add-sqr-sqrt44.5%
sqrt-unprod79.0%
sqr-neg79.0%
sqrt-unprod45.4%
add-sqr-sqrt78.9%
sub-neg78.9%
*-commutative78.9%
cos-sum78.8%
Applied egg-rr78.8%
associate-/r/78.8%
metadata-eval78.8%
count-278.8%
Simplified78.8%
Final simplification78.8%
(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 77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-*l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.5%
*-commutative99.5%
fma-neg99.5%
*-commutative99.5%
Applied egg-rr99.5%
fma-udef99.5%
*-commutative99.5%
+-commutative99.5%
Applied egg-rr78.8%
associate--r-78.8%
+-inverses78.8%
+-lft-identity78.8%
*-commutative78.8%
Simplified78.8%
Final simplification78.8%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.88) (not (<= a 26000000.0))) (* (sin b) (/ r (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
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.88d0)) .or. (.not. (a <= 26000000.0d0))) 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.88) || !(a <= 26000000.0)) {
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.88) or not (a <= 26000000.0): 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.88) || !(a <= 26000000.0)) 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.88) || ~((a <= 26000000.0))) 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.88], N[Not[LessEqual[a, 26000000.0]], $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.88 \lor \neg \left(a \leq 26000000\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -0.880000000000000004 or 2.6e7 < a Initial program 58.5%
/-rgt-identity58.5%
metadata-eval58.5%
associate-*l/58.5%
metadata-eval58.5%
/-rgt-identity58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 58.5%
if -0.880000000000000004 < a < 2.6e7Initial program 97.0%
/-rgt-identity97.0%
metadata-eval97.0%
associate-*l/97.0%
metadata-eval97.0%
/-rgt-identity97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in a around 0 96.8%
Final simplification77.6%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.88) (not (<= a 26000000.0))) (* (sin b) (/ r (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = r * (sin(b) / 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.88d0)) .or. (.not. (a <= 26000000.0d0))) then
tmp = sin(b) * (r / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.88) or not (a <= 26000000.0): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.88) || !(a <= 26000000.0)) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.88) || ~((a <= 26000000.0))) tmp = sin(b) * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.88], N[Not[LessEqual[a, 26000000.0]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.88 \lor \neg \left(a \leq 26000000\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -0.880000000000000004 or 2.6e7 < a Initial program 58.5%
/-rgt-identity58.5%
metadata-eval58.5%
associate-*l/58.5%
metadata-eval58.5%
/-rgt-identity58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 58.5%
if -0.880000000000000004 < a < 2.6e7Initial program 97.0%
remove-double-neg97.0%
associate-/l*97.0%
distribute-frac-neg97.0%
associate-/r/97.0%
distribute-rgt-neg-in97.0%
sin-neg97.0%
neg-mul-197.0%
*-commutative97.0%
associate-/l*97.0%
associate-/r/97.0%
associate-/l/97.0%
sin-neg97.0%
distribute-lft-neg-in97.0%
distribute-rgt-neg-in97.0%
associate-/l/97.0%
metadata-eval97.0%
/-rgt-identity97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in a around 0 96.8%
div-inv96.8%
*-commutative96.8%
clear-num96.9%
Applied egg-rr96.9%
Final simplification77.7%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.88) (not (<= a 26000000.0))) (/ r (/ (cos a) (sin b))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = r / (cos(a) / sin(b));
} else {
tmp = r * (sin(b) / 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.88d0)) .or. (.not. (a <= 26000000.0d0))) then
tmp = r / (cos(a) / sin(b))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.88) || !(a <= 26000000.0)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.88) or not (a <= 26000000.0): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.88) || !(a <= 26000000.0)) tmp = Float64(r / Float64(cos(a) / sin(b))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.88) || ~((a <= 26000000.0))) tmp = r / (cos(a) / sin(b)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.88], N[Not[LessEqual[a, 26000000.0]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.88 \lor \neg \left(a \leq 26000000\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -0.880000000000000004 or 2.6e7 < a Initial program 58.5%
remove-double-neg58.5%
associate-/l*58.6%
distribute-frac-neg58.6%
associate-/r/58.5%
distribute-rgt-neg-in58.5%
sin-neg58.5%
neg-mul-158.5%
*-commutative58.5%
associate-/l*58.5%
associate-/r/58.6%
associate-/l/58.6%
sin-neg58.6%
distribute-lft-neg-in58.6%
distribute-rgt-neg-in58.6%
associate-/l/58.6%
metadata-eval58.6%
/-rgt-identity58.6%
+-commutative58.6%
Simplified58.6%
Taylor expanded in b around 0 58.5%
if -0.880000000000000004 < a < 2.6e7Initial program 97.0%
remove-double-neg97.0%
associate-/l*97.0%
distribute-frac-neg97.0%
associate-/r/97.0%
distribute-rgt-neg-in97.0%
sin-neg97.0%
neg-mul-197.0%
*-commutative97.0%
associate-/l*97.0%
associate-/r/97.0%
associate-/l/97.0%
sin-neg97.0%
distribute-lft-neg-in97.0%
distribute-rgt-neg-in97.0%
associate-/l/97.0%
metadata-eval97.0%
/-rgt-identity97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in a around 0 96.8%
div-inv96.8%
*-commutative96.8%
clear-num96.9%
Applied egg-rr96.9%
Final simplification77.7%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ a b)))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((a + b)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((a + b)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((a + b))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(a + b\right)}
\end{array}
Initial program 77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-*l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
Final simplification77.8%
(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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(a + b\right)}
\end{array}
Initial program 77.8%
remove-double-neg77.8%
associate-/l*77.8%
distribute-frac-neg77.8%
associate-/r/77.8%
distribute-rgt-neg-in77.8%
sin-neg77.8%
neg-mul-177.8%
*-commutative77.8%
associate-/l*77.8%
associate-/r/77.8%
associate-/l/77.8%
sin-neg77.8%
distribute-lft-neg-in77.8%
distribute-rgt-neg-in77.8%
associate-/l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
div-inv77.7%
*-commutative77.7%
clear-num77.8%
Applied egg-rr77.8%
Final simplification77.8%
(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 77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-*l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 55.1%
Final simplification55.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -32000000.0) (not (<= b 4000000000.0))) (* r (sin b)) (* b (/ r (cos (+ a b))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -32000000.0) || !(b <= 4000000000.0)) {
tmp = r * sin(b);
} else {
tmp = b * (r / cos((a + 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 <= (-32000000.0d0)) .or. (.not. (b <= 4000000000.0d0))) then
tmp = r * sin(b)
else
tmp = b * (r / cos((a + b)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -32000000.0) || !(b <= 4000000000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos((a + b)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -32000000.0) or not (b <= 4000000000.0): tmp = r * math.sin(b) else: tmp = b * (r / math.cos((a + b))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -32000000.0) || !(b <= 4000000000.0)) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(Float64(a + b)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -32000000.0) || ~((b <= 4000000000.0))) tmp = r * sin(b); else tmp = b * (r / cos((a + b))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -32000000.0], N[Not[LessEqual[b, 4000000000.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -32000000 \lor \neg \left(b \leq 4000000000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -3.2e7 or 4e9 < b Initial program 55.7%
/-rgt-identity55.7%
metadata-eval55.7%
associate-*l/55.7%
metadata-eval55.7%
/-rgt-identity55.7%
+-commutative55.7%
Simplified55.7%
*-commutative55.7%
associate-*r/55.7%
associate-/l*55.7%
Applied egg-rr55.7%
Taylor expanded in b around 0 5.5%
associate-*r*5.5%
mul-1-neg5.5%
Simplified5.5%
Taylor expanded in a around 0 11.5%
if -3.2e7 < b < 4e9Initial program 97.5%
/-rgt-identity97.5%
metadata-eval97.5%
associate-*l/97.6%
metadata-eval97.6%
/-rgt-identity97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in b around 0 95.0%
Final simplification55.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.5) (not (<= b 1550000000.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.5) || !(b <= 1550000000.0)) {
tmp = r * sin(b);
} 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 <= (-1.5d0)) .or. (.not. (b <= 1550000000.0d0))) then
tmp = r * sin(b)
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 <= -1.5) || !(b <= 1550000000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.5) or not (b <= 1550000000.0): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.5) || !(b <= 1550000000.0)) tmp = Float64(r * sin(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.5) || ~((b <= 1550000000.0))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.5], N[Not[LessEqual[b, 1550000000.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \lor \neg \left(b \leq 1550000000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.5 or 1.55e9 < b Initial program 56.1%
/-rgt-identity56.1%
metadata-eval56.1%
associate-*l/56.0%
metadata-eval56.0%
/-rgt-identity56.0%
+-commutative56.0%
Simplified56.0%
*-commutative56.0%
associate-*r/56.1%
associate-/l*56.0%
Applied egg-rr56.0%
Taylor expanded in b around 0 5.4%
associate-*r*5.4%
mul-1-neg5.4%
Simplified5.4%
Taylor expanded in a around 0 11.5%
if -1.5 < b < 1.55e9Initial program 97.5%
/-rgt-identity97.5%
metadata-eval97.5%
associate-*l/97.6%
metadata-eval97.6%
/-rgt-identity97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in b around 0 95.5%
associate-/l*95.4%
Simplified95.4%
associate-/r/95.5%
Applied egg-rr95.5%
Final simplification55.4%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * sin(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)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-*l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
*-commutative77.8%
associate-*r/77.8%
associate-/l*77.7%
Applied egg-rr77.7%
Taylor expanded in b around 0 52.8%
associate-*r*52.8%
mul-1-neg52.8%
Simplified52.8%
Taylor expanded in a around 0 36.4%
Final simplification36.4%
(FPCore (r a b) :precision binary64 (/ r (+ (* b -0.3333333333333333) (/ 1.0 b))))
double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / 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 / ((b * (-0.3333333333333333d0)) + (1.0d0 / b))
end function
public static double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / b));
}
def code(r, a, b): return r / ((b * -0.3333333333333333) + (1.0 / b))
function code(r, a, b) return Float64(r / Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b))) end
function tmp = code(r, a, b) tmp = r / ((b * -0.3333333333333333) + (1.0 / b)); end
code[r_, a_, b_] := N[(r / N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Initial program 77.8%
remove-double-neg77.8%
associate-/l*77.8%
distribute-frac-neg77.8%
associate-/r/77.8%
distribute-rgt-neg-in77.8%
sin-neg77.8%
neg-mul-177.8%
*-commutative77.8%
associate-/l*77.8%
associate-/r/77.8%
associate-/l/77.8%
sin-neg77.8%
distribute-lft-neg-in77.8%
distribute-rgt-neg-in77.8%
associate-/l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in a around 0 58.7%
Taylor expanded in b around 0 33.5%
Final simplification33.5%
(FPCore (r a b) :precision binary64 (* r b))
double code(double r, double a, double b) {
return r * 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 * b
end function
public static double code(double r, double a, double b) {
return r * b;
}
def code(r, a, b): return r * b
function code(r, a, b) return Float64(r * b) end
function tmp = code(r, a, b) tmp = r * b; end
code[r_, a_, b_] := N[(r * b), $MachinePrecision]
\begin{array}{l}
\\
r \cdot b
\end{array}
Initial program 77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-*l/77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 51.6%
associate-/l*51.5%
Simplified51.5%
Taylor expanded in a around 0 32.5%
*-commutative32.5%
Simplified32.5%
Final simplification32.5%
herbie shell --seed 2023301
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))