
(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}
Sampling outcomes in binary64 precision:
Herbie found 13 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(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}
(FPCore (r a b) :precision binary64 (/ r (fma (/ (cos a) (sin b)) (cos b) (- (sin a)))))
double code(double r, double a, double b) {
return r / fma((cos(a) / sin(b)), cos(b), -sin(a));
}
function code(r, a, b) return Float64(r / fma(Float64(cos(a) / sin(b)), cos(b), Float64(-sin(a)))) end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] * N[Cos[b], $MachinePrecision] + (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\mathsf{fma}\left(\frac{\cos a}{\sin b}, \cos b, -\sin a\right)}
\end{array}
Initial program 81.4%
associate-*r/81.3%
+-commutative81.3%
Simplified81.3%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in r around 0 99.5%
associate-/l*99.5%
+-commutative99.5%
mul-1-neg99.5%
*-commutative99.5%
fma-def99.5%
fma-neg99.5%
Simplified99.5%
div-sub99.5%
sub-neg99.5%
associate-/l*99.5%
associate-/l*99.5%
Applied egg-rr99.5%
associate-/r/99.5%
fma-def99.5%
associate-/r/99.5%
*-inverses99.5%
distribute-lft-neg-in99.5%
metadata-eval99.5%
neg-mul-199.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -2.7e-6) (not (<= a 1.25e-23))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -2.7e-6) || !(a <= 1.25e-23)) {
tmp = r * (sin(b) / 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 <= (-2.7d-6)) .or. (.not. (a <= 1.25d-23))) then
tmp = r * (sin(b) / 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 <= -2.7e-6) || !(a <= 1.25e-23)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -2.7e-6) or not (a <= 1.25e-23): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -2.7e-6) || !(a <= 1.25e-23)) tmp = Float64(r * Float64(sin(b) / 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 <= -2.7e-6) || ~((a <= 1.25e-23))) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -2.7e-6], N[Not[LessEqual[a, 1.25e-23]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 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 -2.7 \cdot 10^{-6} \lor \neg \left(a \leq 1.25 \cdot 10^{-23}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -2.69999999999999998e-6 or 1.2500000000000001e-23 < a Initial program 58.8%
remove-double-neg58.8%
remove-double-neg58.8%
+-commutative58.8%
Simplified58.8%
Taylor expanded in b around 0 58.2%
if -2.69999999999999998e-6 < a < 1.2500000000000001e-23Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
Final simplification81.1%
(FPCore (r a b) :precision binary64 (if (<= a -3.8e-5) (* (sin b) (/ r (cos a))) (if (<= a 1.25e-23) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -3.8e-5) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 1.25e-23) {
tmp = r * (sin(b) / 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 (a <= (-3.8d-5)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 1.25d-23) then
tmp = r * (sin(b) / 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 (a <= -3.8e-5) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 1.25e-23) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -3.8e-5: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 1.25e-23: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -3.8e-5) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 1.25e-23) tmp = Float64(r * Float64(sin(b) / 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 (a <= -3.8e-5) tmp = sin(b) * (r / cos(a)); elseif (a <= 1.25e-23) tmp = r * (sin(b) / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -3.8e-5], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.25e-23], N[(r * N[(N[Sin[b], $MachinePrecision] / 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}\;a \leq -3.8 \cdot 10^{-5}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{-23}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -3.8000000000000002e-5Initial program 57.4%
associate-*r/57.2%
+-commutative57.2%
Simplified57.2%
associate-/l*57.5%
associate-/r/57.4%
Applied egg-rr57.4%
Taylor expanded in b around 0 57.2%
if -3.8000000000000002e-5 < a < 1.2500000000000001e-23Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
if 1.2500000000000001e-23 < a Initial program 59.8%
remove-double-neg59.8%
remove-double-neg59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in b around 0 58.9%
Final simplification81.1%
(FPCore (r a b) :precision binary64 (if (<= a -0.00215) (* (sin b) (/ r (cos a))) (if (<= a 1.25e-23) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00215) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 1.25e-23) {
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 (a <= (-0.00215d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 1.25d-23) 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 (a <= -0.00215) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 1.25e-23) {
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 a <= -0.00215: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 1.25e-23: 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 (a <= -0.00215) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 1.25e-23) 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 (a <= -0.00215) tmp = sin(b) * (r / cos(a)); elseif (a <= 1.25e-23) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00215], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.25e-23], 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}\;a \leq -0.00215:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{-23}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -0.00215Initial program 57.4%
associate-*r/57.2%
+-commutative57.2%
Simplified57.2%
associate-/l*57.5%
associate-/r/57.4%
Applied egg-rr57.4%
Taylor expanded in b around 0 57.2%
if -0.00215 < a < 1.2500000000000001e-23Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
associate-/l*99.2%
associate-/r/99.3%
Simplified99.3%
if 1.2500000000000001e-23 < a Initial program 59.8%
remove-double-neg59.8%
remove-double-neg59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in b around 0 58.9%
Final simplification81.2%
(FPCore (r a b) :precision binary64 (if (<= a -1.4e-5) (/ r (/ (cos a) (sin b))) (if (<= a 1.25e-23) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -1.4e-5) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 1.25e-23) {
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 (a <= (-1.4d-5)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 1.25d-23) 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 (a <= -1.4e-5) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 1.25e-23) {
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 a <= -1.4e-5: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 1.25e-23: 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 (a <= -1.4e-5) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 1.25e-23) 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 (a <= -1.4e-5) tmp = r / (cos(a) / sin(b)); elseif (a <= 1.25e-23) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -1.4e-5], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.25e-23], 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}\;a \leq -1.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{-23}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -1.39999999999999998e-5Initial program 57.4%
associate-*r/57.2%
+-commutative57.2%
Simplified57.2%
cos-sum99.0%
cancel-sign-sub-inv99.0%
fma-def99.1%
Applied egg-rr99.1%
Taylor expanded in r around 0 99.0%
associate-/l*99.2%
+-commutative99.2%
mul-1-neg99.2%
*-commutative99.2%
fma-def99.2%
fma-neg99.2%
Simplified99.2%
Taylor expanded in b around 0 57.2%
if -1.39999999999999998e-5 < a < 1.2500000000000001e-23Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
associate-/l*99.2%
associate-/r/99.3%
Simplified99.3%
if 1.2500000000000001e-23 < a Initial program 59.8%
remove-double-neg59.8%
remove-double-neg59.8%
+-commutative59.8%
Simplified59.8%
Taylor expanded in b around 0 58.9%
Final simplification81.2%
(FPCore (r a b) :precision binary64 (if (<= a -5.3e-5) (/ r (/ (cos a) (sin b))) (if (<= a 5.5e-11) (* (sin b) (/ r (cos b))) (/ (sin b) (/ (cos a) r)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -5.3e-5) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 5.5e-11) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = sin(b) / (cos(a) / r);
}
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 <= (-5.3d-5)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 5.5d-11) then
tmp = sin(b) * (r / cos(b))
else
tmp = sin(b) / (cos(a) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -5.3e-5) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 5.5e-11) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = Math.sin(b) / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -5.3e-5: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 5.5e-11: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = math.sin(b) / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -5.3e-5) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 5.5e-11) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(sin(b) / Float64(cos(a) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -5.3e-5) tmp = r / (cos(a) / sin(b)); elseif (a <= 5.5e-11) tmp = sin(b) * (r / cos(b)); else tmp = sin(b) / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -5.3e-5], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.5e-11], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.3 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 5.5 \cdot 10^{-11}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if a < -5.3000000000000001e-5Initial program 57.4%
associate-*r/57.2%
+-commutative57.2%
Simplified57.2%
cos-sum99.0%
cancel-sign-sub-inv99.0%
fma-def99.1%
Applied egg-rr99.1%
Taylor expanded in r around 0 99.0%
associate-/l*99.2%
+-commutative99.2%
mul-1-neg99.2%
*-commutative99.2%
fma-def99.2%
fma-neg99.2%
Simplified99.2%
Taylor expanded in b around 0 57.2%
if -5.3000000000000001e-5 < a < 5.49999999999999975e-11Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
associate-/l*99.2%
associate-/r/99.3%
Simplified99.3%
if 5.49999999999999975e-11 < a Initial program 57.8%
remove-double-neg57.8%
remove-double-neg57.8%
+-commutative57.8%
Simplified57.8%
associate-*r/57.7%
*-commutative57.7%
associate-/l*57.9%
Applied egg-rr57.9%
Taylor expanded in b around 0 57.0%
Final simplification81.2%
(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 81.4%
Final simplification81.4%
(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}
Initial program 81.4%
associate-*r/81.3%
+-commutative81.3%
Simplified81.3%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in b around inf 99.5%
mul-1-neg99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
*-commutative99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
fma-udef99.5%
+-commutative99.5%
*-commutative99.5%
add-sqr-sqrt52.8%
sqrt-unprod91.1%
sqr-neg91.1%
sqrt-unprod38.2%
add-sqr-sqrt81.2%
cos-diff81.5%
Applied egg-rr81.5%
Final simplification81.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos a))))
double code(double r, double a, double b) {
return r * (sin(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 * (sin(b) / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(a));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(a))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a}
\end{array}
Initial program 81.4%
remove-double-neg81.4%
remove-double-neg81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in b around 0 55.4%
Final simplification55.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.7) (not (<= b 1.12))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.7) || !(b <= 1.12)) {
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 <= (-4.7d0)) .or. (.not. (b <= 1.12d0))) 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 <= -4.7) || !(b <= 1.12)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.7) or not (b <= 1.12): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.7) || !(b <= 1.12)) 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 <= -4.7) || ~((b <= 1.12))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.7], N[Not[LessEqual[b, 1.12]], $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 -4.7 \lor \neg \left(b \leq 1.12\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.70000000000000018 or 1.1200000000000001 < b Initial program 62.4%
associate-*r/62.4%
+-commutative62.4%
Simplified62.4%
Taylor expanded in a around 0 60.0%
mul-1-neg60.0%
unsub-neg60.0%
Simplified60.0%
Taylor expanded in b around 0 10.5%
if -4.70000000000000018 < b < 1.1200000000000001Initial program 99.5%
remove-double-neg99.5%
remove-double-neg99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in b around 0 98.4%
Final simplification55.5%
(FPCore (r a b) :precision binary64 (if (<= b -23.0) (* r (sin b)) (/ (* r b) (cos (+ a b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -23.0) {
tmp = r * sin(b);
} else {
tmp = (r * b) / 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 <= (-23.0d0)) then
tmp = r * sin(b)
else
tmp = (r * b) / cos((a + b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -23.0) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos((a + b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -23.0: tmp = r * math.sin(b) else: tmp = (r * b) / math.cos((a + b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -23.0) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(Float64(a + b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -23.0) tmp = r * sin(b); else tmp = (r * b) / cos((a + b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -23.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -23:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(a + b\right)}\\
\end{array}
\end{array}
if b < -23Initial program 65.8%
associate-*r/65.8%
+-commutative65.8%
Simplified65.8%
Taylor expanded in a around 0 62.5%
mul-1-neg62.5%
unsub-neg62.5%
Simplified62.5%
Taylor expanded in b around 0 11.0%
if -23 < b Initial program 86.6%
associate-*r/86.5%
+-commutative86.5%
Simplified86.5%
Taylor expanded in b around 0 68.3%
Final simplification54.0%
(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 81.4%
remove-double-neg81.4%
remove-double-neg81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in b around 0 52.1%
Final simplification52.1%
(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 81.4%
remove-double-neg81.4%
remove-double-neg81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in b around 0 52.1%
Taylor expanded in a around 0 37.0%
Final simplification37.0%
herbie shell --seed 2024026
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))