
(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 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(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 (sin b)) (fma (sin b) (- (sin a)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(b), -sin(a), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 77.8%
associate-*r/77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-/l/77.8%
associate-*l/77.8%
associate-/l/77.8%
metadata-eval77.8%
metadata-eval77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.4%
*-commutative99.4%
*-commutative99.4%
fma-neg99.4%
distribute-rgt-neg-in99.4%
Applied egg-rr99.4%
Taylor expanded in b around inf 99.4%
mul-1-neg99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
*-commutative99.4%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) (* (sin b) (- (sin a))))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (sin(b) * -sin(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 77.8%
associate-*r/77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-/l/77.8%
associate-*l/77.8%
associate-/l/77.8%
metadata-eval77.8%
metadata-eval77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.4%
*-commutative99.4%
*-commutative99.4%
fma-neg99.4%
distribute-rgt-neg-in99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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 77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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 77.8%
associate-*r/77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-/l/77.8%
associate-*l/77.8%
associate-/l/77.8%
metadata-eval77.8%
metadata-eval77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 77.8%
associate-*r/77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-/l/77.8%
associate-*l/77.8%
associate-/l/77.8%
metadata-eval77.8%
metadata-eval77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) 0.0)))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), 0.0);
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), 0.0)) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 77.8%
associate-*r/77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-/l/77.8%
associate-*l/77.8%
associate-/l/77.8%
metadata-eval77.8%
metadata-eval77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.4%
*-commutative99.4%
*-commutative99.4%
fma-neg99.4%
distribute-rgt-neg-in99.4%
Applied egg-rr99.4%
*-commutative99.4%
add-sqr-sqrt53.1%
sqrt-unprod89.4%
sqr-neg89.4%
sqrt-unprod36.2%
add-sqr-sqrt77.5%
sin-mult78.5%
cos-sum77.4%
div-sub77.4%
Applied egg-rr78.6%
+-inverses78.6%
Simplified78.6%
Final simplification78.6%
(FPCore (r a b) :precision binary64 (if (<= a -2.9e-5) (* r (/ (sin b) (cos a))) (if (<= a 22.0) (* r (tan b)) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -2.9e-5) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 22.0) {
tmp = r * tan(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 <= (-2.9d-5)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 22.0d0) then
tmp = r * tan(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 <= -2.9e-5) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 22.0) {
tmp = r * Math.tan(b);
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -2.9e-5: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 22.0: tmp = r * math.tan(b) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -2.9e-5) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 22.0) tmp = Float64(r * tan(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 <= -2.9e-5) tmp = r * (sin(b) / cos(a)); elseif (a <= 22.0) tmp = r * tan(b); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -2.9e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 22.0], N[(r * N[Tan[b], $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 -2.9 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 22:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -2.9e-5Initial program 61.7%
+-commutative61.7%
Simplified61.7%
Taylor expanded in b around 0 60.1%
if -2.9e-5 < a < 22Initial program 98.3%
+-commutative98.3%
Simplified98.3%
add-log-exp72.0%
Applied egg-rr72.0%
Taylor expanded in a around 0 72.0%
rem-log-exp72.0%
*-un-lft-identity72.0%
log-prod72.0%
metadata-eval72.0%
add-log-exp72.0%
rem-log-exp98.3%
quot-tan98.4%
Applied egg-rr98.4%
+-lft-identity98.4%
Simplified98.4%
if 22 < a Initial program 52.1%
associate-*r/52.1%
/-rgt-identity52.1%
metadata-eval52.1%
associate-/l/52.1%
associate-*l/52.2%
associate-/l/52.2%
metadata-eval52.2%
metadata-eval52.2%
metadata-eval52.2%
/-rgt-identity52.2%
+-commutative52.2%
Simplified52.2%
Taylor expanded in b around 0 52.9%
Final simplification77.7%
(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 77.8%
Final simplification77.8%
(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 77.8%
associate-*r/77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-/l/77.8%
associate-*l/77.8%
associate-/l/77.8%
metadata-eval77.8%
metadata-eval77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
Final simplification77.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.000245) (not (<= b 0.0015))) (* r (tan b)) (* r (* b (/ 1.0 (cos a))))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000245) || !(b <= 0.0015)) {
tmp = r * tan(b);
} else {
tmp = r * (b * (1.0 / 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.000245d0)) .or. (.not. (b <= 0.0015d0))) then
tmp = r * tan(b)
else
tmp = r * (b * (1.0d0 / cos(a)))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000245) || !(b <= 0.0015)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b * (1.0 / Math.cos(a)));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.000245) or not (b <= 0.0015): tmp = r * math.tan(b) else: tmp = r * (b * (1.0 / math.cos(a))) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.000245) || !(b <= 0.0015)) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(b * Float64(1.0 / cos(a)))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.000245) || ~((b <= 0.0015))) tmp = r * tan(b); else tmp = r * (b * (1.0 / cos(a))); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000245], N[Not[LessEqual[b, 0.0015]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b * N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.000245 \lor \neg \left(b \leq 0.0015\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \left(b \cdot \frac{1}{\cos a}\right)\\
\end{array}
\end{array}
if b < -2.4499999999999999e-4 or 0.0015 < b Initial program 59.1%
+-commutative59.1%
Simplified59.1%
add-log-exp58.8%
Applied egg-rr58.8%
Taylor expanded in a around 0 58.4%
rem-log-exp58.4%
*-un-lft-identity58.4%
log-prod58.4%
metadata-eval58.4%
add-log-exp58.4%
rem-log-exp58.8%
quot-tan58.9%
Applied egg-rr58.9%
+-lft-identity58.9%
Simplified58.9%
if -2.4499999999999999e-4 < b < 0.0015Initial program 98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in b around 0 98.2%
clear-num98.1%
associate-/r/98.3%
Applied egg-rr98.3%
Final simplification77.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -8.6e-5) (not (<= b 0.00155))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -8.6e-5) || !(b <= 0.00155)) {
tmp = r * tan(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 <= (-8.6d-5)) .or. (.not. (b <= 0.00155d0))) then
tmp = r * tan(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 <= -8.6e-5) || !(b <= 0.00155)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -8.6e-5) or not (b <= 0.00155): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -8.6e-5) || !(b <= 0.00155)) tmp = Float64(r * tan(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 <= -8.6e-5) || ~((b <= 0.00155))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -8.6e-5], N[Not[LessEqual[b, 0.00155]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / 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 0.00155\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -8.6000000000000003e-5 or 0.00154999999999999995 < b Initial program 59.1%
+-commutative59.1%
Simplified59.1%
add-log-exp58.8%
Applied egg-rr58.8%
Taylor expanded in a around 0 58.4%
rem-log-exp58.4%
*-un-lft-identity58.4%
log-prod58.4%
metadata-eval58.4%
add-log-exp58.4%
rem-log-exp58.8%
quot-tan58.9%
Applied egg-rr58.9%
+-lft-identity58.9%
Simplified58.9%
if -8.6000000000000003e-5 < b < 0.00154999999999999995Initial program 98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in b around 0 98.2%
Final simplification77.6%
(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%
associate-*r/77.8%
/-rgt-identity77.8%
metadata-eval77.8%
associate-/l/77.8%
associate-*l/77.8%
associate-/l/77.8%
metadata-eval77.8%
metadata-eval77.8%
metadata-eval77.8%
/-rgt-identity77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in a around 0 62.3%
Taylor expanded in b around 0 37.3%
Final simplification37.3%
(FPCore (r a b) :precision binary64 (* r (tan b)))
double code(double r, double a, double b) {
return r * tan(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 * tan(b)
end function
public static double code(double r, double a, double b) {
return r * Math.tan(b);
}
def code(r, a, b): return r * math.tan(b)
function code(r, a, b) return Float64(r * tan(b)) end
function tmp = code(r, a, b) tmp = r * tan(b); end
code[r_, a_, b_] := N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \tan b
\end{array}
Initial program 77.8%
+-commutative77.8%
Simplified77.8%
add-log-exp46.8%
Applied egg-rr46.8%
Taylor expanded in a around 0 46.1%
rem-log-exp46.1%
*-un-lft-identity46.1%
log-prod46.1%
metadata-eval46.1%
add-log-exp46.1%
rem-log-exp61.3%
quot-tan61.3%
Applied egg-rr61.3%
+-lft-identity61.3%
Simplified61.3%
Final simplification61.3%
(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%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 48.9%
Taylor expanded in a around 0 32.5%
Final simplification32.5%
herbie shell --seed 2023322
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))