
(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 14 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 70.8%
associate-/l*70.8%
remove-double-neg70.8%
sin-neg70.8%
neg-mul-170.8%
associate-/r*70.8%
associate-/l*70.8%
*-commutative70.8%
associate-*l/70.8%
associate-/l*70.8%
sin-neg70.8%
distribute-lft-neg-in70.8%
distribute-rgt-neg-in70.8%
associate-/l*70.8%
metadata-eval70.8%
/-rgt-identity70.8%
+-commutative70.8%
Simplified70.8%
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 70.8%
associate-/l*70.8%
+-commutative70.8%
Simplified70.8%
associate-/r/70.4%
Applied egg-rr70.4%
cos-sum99.4%
Applied egg-rr99.1%
Final simplification99.1%
(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 70.8%
associate-/l*70.8%
remove-double-neg70.8%
sin-neg70.8%
neg-mul-170.8%
associate-/r*70.8%
associate-/l*70.8%
*-commutative70.8%
associate-*l/70.8%
associate-/l*70.8%
sin-neg70.8%
distribute-lft-neg-in70.8%
distribute-rgt-neg-in70.8%
associate-/l*70.8%
metadata-eval70.8%
/-rgt-identity70.8%
+-commutative70.8%
Simplified70.8%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (cos a)) (/ r (cos b))))
double code(double r, double a, double b) {
return (sin(b) / cos(a)) * (r / 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) / cos(a)) * (r / cos(b))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) / Math.cos(a)) * (r / Math.cos(b));
}
def code(r, a, b): return (math.sin(b) / math.cos(a)) * (r / math.cos(b))
function code(r, a, b) return Float64(Float64(sin(b) / cos(a)) * Float64(r / cos(b))) end
function tmp = code(r, a, b) tmp = (sin(b) / cos(a)) * (r / cos(b)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\cos a} \cdot \frac{r}{\cos b}
\end{array}
Initial program 70.8%
+-commutative70.8%
Simplified70.8%
cos-sum99.4%
Applied egg-rr99.4%
sin-mult72.1%
div-sub72.1%
cos-sum72.9%
sub-neg72.9%
distribute-lft-neg-in72.9%
add-sqr-sqrt38.4%
sqrt-unprod72.1%
sqr-neg72.1%
sqrt-unprod33.8%
add-sqr-sqrt70.9%
cos-diff71.7%
Applied egg-rr71.7%
+-inverses71.7%
Simplified71.7%
*-commutative71.7%
--rgt-identity71.7%
*-commutative71.7%
times-frac71.8%
Applied egg-rr71.8%
Final simplification71.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00076) (not (<= b 7.1e-7))) (* (sin b) (/ r (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00076) || !(b <= 7.1e-7)) {
tmp = sin(b) * (r / cos(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 <= (-0.00076d0)) .or. (.not. (b <= 7.1d-7))) then
tmp = sin(b) * (r / cos(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 <= -0.00076) || !(b <= 7.1e-7)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00076) or not (b <= 7.1e-7): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00076) || !(b <= 7.1e-7)) tmp = Float64(sin(b) * Float64(r / cos(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 <= -0.00076) || ~((b <= 7.1e-7))) tmp = sin(b) * (r / cos(b)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00076], N[Not[LessEqual[b, 7.1e-7]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00076 \lor \neg \left(b \leq 7.1 \cdot 10^{-7}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -7.6000000000000004e-4 or 7.0999999999999998e-7 < b Initial program 46.9%
associate-/l*46.9%
+-commutative46.9%
Simplified46.9%
associate-/r/46.9%
Applied egg-rr46.9%
Taylor expanded in a around 0 46.4%
if -7.6000000000000004e-4 < b < 7.0999999999999998e-7Initial program 98.8%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.8%
*-commutative98.8%
associate-*l/98.9%
associate-/l*98.9%
sin-neg98.9%
distribute-lft-neg-in98.9%
distribute-rgt-neg-in98.9%
associate-/l*98.9%
metadata-eval98.9%
/-rgt-identity98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.9%
Final simplification70.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -8.6e-5) (not (<= b 7.1e-7))) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -8.6e-5) || !(b <= 7.1e-7)) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = r * (sin(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 <= (-8.6d-5)) .or. (.not. (b <= 7.1d-7))) then
tmp = sin(b) * (r / cos(b))
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -8.6e-5) || !(b <= 7.1e-7)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -8.6e-5) or not (b <= 7.1e-7): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -8.6e-5) || !(b <= 7.1e-7)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -8.6e-5) || ~((b <= 7.1e-7))) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -8.6e-5], N[Not[LessEqual[b, 7.1e-7]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.6 \cdot 10^{-5} \lor \neg \left(b \leq 7.1 \cdot 10^{-7}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if b < -8.6000000000000003e-5 or 7.0999999999999998e-7 < b Initial program 46.9%
associate-/l*46.9%
+-commutative46.9%
Simplified46.9%
associate-/r/46.9%
Applied egg-rr46.9%
Taylor expanded in a around 0 46.4%
if -8.6000000000000003e-5 < b < 7.0999999999999998e-7Initial program 98.8%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.8%
*-commutative98.8%
associate-*l/98.9%
associate-/l*98.9%
sin-neg98.9%
distribute-lft-neg-in98.9%
distribute-rgt-neg-in98.9%
associate-/l*98.9%
metadata-eval98.9%
/-rgt-identity98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.9%
Final simplification70.6%
(FPCore (r a b) :precision binary64 (if (<= b -0.00024) (/ r (/ (cos b) (sin b))) (if (<= b 7.1e-7) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.00024) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 7.1e-7) {
tmp = r * (sin(b) / 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 (b <= (-0.00024d0)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 7.1d-7) then
tmp = r * (sin(b) / 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 (b <= -0.00024) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 7.1e-7) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.00024: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 7.1e-7: tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.00024) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 7.1e-7) tmp = Float64(r * Float64(sin(b) / 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 (b <= -0.00024) tmp = r / (cos(b) / sin(b)); elseif (b <= 7.1e-7) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.00024], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.1e-7], N[(r * N[(N[Sin[b], $MachinePrecision] / 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}\;b \leq -0.00024:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 7.1 \cdot 10^{-7}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -2.40000000000000006e-4Initial program 52.6%
associate-/l*52.7%
+-commutative52.7%
Simplified52.7%
Taylor expanded in a around 0 51.6%
if -2.40000000000000006e-4 < b < 7.0999999999999998e-7Initial program 98.8%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.8%
*-commutative98.8%
associate-*l/98.9%
associate-/l*98.9%
sin-neg98.9%
distribute-lft-neg-in98.9%
distribute-rgt-neg-in98.9%
associate-/l*98.9%
metadata-eval98.9%
/-rgt-identity98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.9%
if 7.0999999999999998e-7 < b Initial program 41.4%
associate-/l*41.4%
+-commutative41.4%
Simplified41.4%
associate-/r/41.4%
Applied egg-rr41.4%
Taylor expanded in a around 0 41.6%
Final simplification70.6%
(FPCore (r a b) :precision binary64 (if (<= b -0.00019) (* (* (sin b) r) (/ 1.0 (cos b))) (if (<= b 7.1e-7) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.00019) {
tmp = (sin(b) * r) * (1.0 / cos(b));
} else if (b <= 7.1e-7) {
tmp = r * (sin(b) / 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 (b <= (-0.00019d0)) then
tmp = (sin(b) * r) * (1.0d0 / cos(b))
else if (b <= 7.1d-7) then
tmp = r * (sin(b) / 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 (b <= -0.00019) {
tmp = (Math.sin(b) * r) * (1.0 / Math.cos(b));
} else if (b <= 7.1e-7) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.00019: tmp = (math.sin(b) * r) * (1.0 / math.cos(b)) elif b <= 7.1e-7: tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.00019) tmp = Float64(Float64(sin(b) * r) * Float64(1.0 / cos(b))); elseif (b <= 7.1e-7) tmp = Float64(r * Float64(sin(b) / 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 (b <= -0.00019) tmp = (sin(b) * r) * (1.0 / cos(b)); elseif (b <= 7.1e-7) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.00019], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] * N[(1.0 / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.1e-7], N[(r * N[(N[Sin[b], $MachinePrecision] / 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}\;b \leq -0.00019:\\
\;\;\;\;\left(\sin b \cdot r\right) \cdot \frac{1}{\cos b}\\
\mathbf{elif}\;b \leq 7.1 \cdot 10^{-7}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -1.9000000000000001e-4Initial program 52.6%
associate-/l*52.7%
remove-double-neg52.7%
sin-neg52.7%
neg-mul-152.7%
associate-/r*52.7%
associate-/l*52.6%
*-commutative52.6%
associate-*l/52.6%
associate-/l*52.6%
sin-neg52.6%
distribute-lft-neg-in52.6%
distribute-rgt-neg-in52.6%
associate-/l*52.6%
metadata-eval52.6%
/-rgt-identity52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in a around 0 51.5%
*-commutative51.5%
Simplified51.5%
div-inv51.6%
Applied egg-rr51.6%
if -1.9000000000000001e-4 < b < 7.0999999999999998e-7Initial program 98.8%
associate-/l*98.7%
remove-double-neg98.7%
sin-neg98.7%
neg-mul-198.7%
associate-/r*98.7%
associate-/l*98.8%
*-commutative98.8%
associate-*l/98.9%
associate-/l*98.9%
sin-neg98.9%
distribute-lft-neg-in98.9%
distribute-rgt-neg-in98.9%
associate-/l*98.9%
metadata-eval98.9%
/-rgt-identity98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 98.9%
if 7.0999999999999998e-7 < b Initial program 41.4%
associate-/l*41.4%
+-commutative41.4%
Simplified41.4%
associate-/r/41.4%
Applied egg-rr41.4%
Taylor expanded in a around 0 41.6%
Final simplification70.6%
(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 70.8%
associate-/l*70.8%
+-commutative70.8%
Simplified70.8%
associate-/r/70.4%
Applied egg-rr70.4%
Final simplification70.4%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (sin(b) / 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 = r * (sin(b) / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((b + a)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 70.8%
associate-/l*70.8%
remove-double-neg70.8%
sin-neg70.8%
neg-mul-170.8%
associate-/r*70.8%
associate-/l*70.8%
*-commutative70.8%
associate-*l/70.8%
associate-/l*70.8%
sin-neg70.8%
distribute-lft-neg-in70.8%
distribute-rgt-neg-in70.8%
associate-/l*70.8%
metadata-eval70.8%
/-rgt-identity70.8%
+-commutative70.8%
Simplified70.8%
Final simplification70.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 70.8%
associate-/l*70.8%
+-commutative70.8%
Simplified70.8%
associate-/r/70.4%
Applied egg-rr70.4%
Taylor expanded in b around 0 51.7%
Final simplification51.7%
(FPCore (r a b) :precision binary64 (/ (* b r) (cos (+ b a))))
double code(double r, double a, double b) {
return (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 = (b * r) / cos((b + a))
end function
public static double code(double r, double a, double b) {
return (b * r) / Math.cos((b + a));
}
def code(r, a, b): return (b * r) / math.cos((b + a))
function code(r, a, b) return Float64(Float64(b * r) / cos(Float64(b + a))) end
function tmp = code(r, a, b) tmp = (b * r) / cos((b + a)); end
code[r_, a_, b_] := N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot r}{\cos \left(b + a\right)}
\end{array}
Initial program 70.8%
+-commutative70.8%
Simplified70.8%
Taylor expanded in b around 0 48.2%
Final simplification48.2%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (b / 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 = r * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 70.8%
associate-/l*70.8%
remove-double-neg70.8%
sin-neg70.8%
neg-mul-170.8%
associate-/r*70.8%
associate-/l*70.8%
*-commutative70.8%
associate-*l/70.8%
associate-/l*70.8%
sin-neg70.8%
distribute-lft-neg-in70.8%
distribute-rgt-neg-in70.8%
associate-/l*70.8%
metadata-eval70.8%
/-rgt-identity70.8%
+-commutative70.8%
Simplified70.8%
Taylor expanded in b around 0 48.1%
Final simplification48.1%
(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 70.8%
associate-/l*70.8%
remove-double-neg70.8%
sin-neg70.8%
neg-mul-170.8%
associate-/r*70.8%
associate-/l*70.8%
*-commutative70.8%
associate-*l/70.8%
associate-/l*70.8%
sin-neg70.8%
distribute-lft-neg-in70.8%
distribute-rgt-neg-in70.8%
associate-/l*70.8%
metadata-eval70.8%
/-rgt-identity70.8%
+-commutative70.8%
Simplified70.8%
Taylor expanded in b around 0 48.1%
Taylor expanded in a around 0 29.4%
Final simplification29.4%
herbie shell --seed 2024031
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))