
(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 12 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 (/ (sin b) (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(b) * cos(a)) - (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(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 73.7%
associate-/l*73.8%
+-commutative73.8%
Simplified73.8%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ r (fma (cos a) (/ (cos b) (sin b)) (- (sin a)))))
double code(double r, double a, double b) {
return r / fma(cos(a), (cos(b) / sin(b)), -sin(a));
}
function code(r, a, b) return Float64(r / fma(cos(a), Float64(cos(b) / sin(b)), Float64(-sin(a)))) end
code[r_, a_, b_] := N[(r / N[(N[Cos[a], $MachinePrecision] * N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] + (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\mathsf{fma}\left(\cos a, \frac{\cos b}{\sin b}, -\sin a\right)}
\end{array}
Initial program 73.7%
associate-/l*73.8%
+-commutative73.8%
Simplified73.8%
clear-num73.7%
un-div-inv73.7%
Applied egg-rr73.7%
cos-sum99.3%
div-sub99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.3%
associate-/l*99.4%
fma-neg99.4%
Simplified99.4%
Final simplification99.4%
(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 73.7%
associate-/l*73.8%
+-commutative73.8%
Simplified73.8%
clear-num73.7%
un-div-inv73.7%
Applied egg-rr73.7%
cos-sum99.3%
div-sub99.4%
Applied egg-rr99.4%
Taylor expanded in r around 0 99.3%
associate-/l*99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0008) (not (<= a 7.6e-11))) (* r (/ (sin b) (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0008) || !(a <= 7.6e-11)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * tan(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.0008d0)) .or. (.not. (a <= 7.6d-11))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0008) || !(a <= 7.6e-11)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0008) or not (a <= 7.6e-11): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0008) || !(a <= 7.6e-11)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.0008) || ~((a <= 7.6e-11))) tmp = r * (sin(b) / cos(a)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0008], N[Not[LessEqual[a, 7.6e-11]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0008 \lor \neg \left(a \leq 7.6 \cdot 10^{-11}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -8.00000000000000038e-4 or 7.5999999999999996e-11 < a Initial program 49.5%
associate-/l*49.5%
+-commutative49.5%
Simplified49.5%
Taylor expanded in b around 0 49.9%
if -8.00000000000000038e-4 < a < 7.5999999999999996e-11Initial program 99.6%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
add-sqr-sqrt49.6%
sqrt-unprod50.0%
pow250.0%
Applied egg-rr50.0%
Taylor expanded in a around 0 49.8%
*-un-lft-identity49.8%
sqrt-pow199.5%
metadata-eval99.5%
pow199.5%
quot-tan99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
Final simplification74.0%
(FPCore (r a b) :precision binary64 (if (<= a -0.0078) (* r (/ (sin b) (cos a))) (if (<= a 7.6e-11) (* r (tan b)) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.0078) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 7.6e-11) {
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 <= (-0.0078d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 7.6d-11) 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 <= -0.0078) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 7.6e-11) {
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 <= -0.0078: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 7.6e-11: 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 <= -0.0078) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 7.6e-11) 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 <= -0.0078) tmp = r * (sin(b) / cos(a)); elseif (a <= 7.6e-11) tmp = r * tan(b); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.0078], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7.6e-11], 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 -0.0078:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 7.6 \cdot 10^{-11}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -0.0077999999999999996Initial program 50.4%
associate-/l*50.5%
+-commutative50.5%
Simplified50.5%
Taylor expanded in b around 0 51.0%
if -0.0077999999999999996 < a < 7.5999999999999996e-11Initial program 99.6%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
add-sqr-sqrt49.6%
sqrt-unprod50.0%
pow250.0%
Applied egg-rr50.0%
Taylor expanded in a around 0 49.8%
*-un-lft-identity49.8%
sqrt-pow199.5%
metadata-eval99.5%
pow199.5%
quot-tan99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
if 7.5999999999999996e-11 < a Initial program 48.1%
+-commutative48.1%
Simplified48.1%
associate-*r/48.0%
add-cube-cbrt47.5%
associate-*l*47.6%
pow247.6%
Applied egg-rr47.6%
Taylor expanded in b around 0 48.0%
Taylor expanded in r around 0 35.5%
associate-*r*35.6%
cbrt-prod26.7%
unpow226.7%
add-cbrt-cube48.4%
clear-num48.3%
un-div-inv48.3%
Applied egg-rr48.3%
associate-/r/48.4%
Simplified48.4%
Final simplification74.0%
(FPCore (r a b) :precision binary64 (if (<= a -0.0015) (* r (/ (sin b) (cos a))) (if (<= a 7.6e-11) (* r (tan b)) (/ (* r (sin b)) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.0015) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 7.6e-11) {
tmp = r * tan(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.0015d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 7.6d-11) then
tmp = r * tan(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.0015) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 7.6e-11) {
tmp = r * Math.tan(b);
} else {
tmp = (r * Math.sin(b)) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.0015: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 7.6e-11: tmp = r * math.tan(b) else: tmp = (r * math.sin(b)) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.0015) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 7.6e-11) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(r * sin(b)) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.0015) tmp = r * (sin(b) / cos(a)); elseif (a <= 7.6e-11) tmp = r * tan(b); else tmp = (r * sin(b)) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.0015], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7.6e-11], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0015:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 7.6 \cdot 10^{-11}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\end{array}
\end{array}
if a < -0.0015Initial program 50.4%
associate-/l*50.5%
+-commutative50.5%
Simplified50.5%
Taylor expanded in b around 0 51.0%
if -0.0015 < a < 7.5999999999999996e-11Initial program 99.6%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
add-sqr-sqrt49.6%
sqrt-unprod50.0%
pow250.0%
Applied egg-rr50.0%
Taylor expanded in a around 0 49.8%
*-un-lft-identity49.8%
sqrt-pow199.5%
metadata-eval99.5%
pow199.5%
quot-tan99.7%
Applied egg-rr99.7%
*-lft-identity99.7%
Simplified99.7%
if 7.5999999999999996e-11 < a Initial program 48.1%
+-commutative48.1%
Simplified48.1%
Taylor expanded in b around 0 48.4%
Final simplification74.0%
(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 73.7%
associate-/l*73.8%
+-commutative73.8%
Simplified73.8%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -5.8e-5) (not (<= b 1.4e-5))) (* r (tan b)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.8e-5) || !(b <= 1.4e-5)) {
tmp = r * tan(b);
} else {
tmp = (r * b) / cos((b + a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-5.8d-5)) .or. (.not. (b <= 1.4d-5))) then
tmp = r * tan(b)
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -5.8e-5) || !(b <= 1.4e-5)) {
tmp = r * Math.tan(b);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5.8e-5) or not (b <= 1.4e-5): tmp = r * math.tan(b) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -5.8e-5) || !(b <= 1.4e-5)) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -5.8e-5) || ~((b <= 1.4e-5))) tmp = r * tan(b); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5.8e-5], N[Not[LessEqual[b, 1.4e-5]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.8 \cdot 10^{-5} \lor \neg \left(b \leq 1.4 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -5.8e-5 or 1.39999999999999998e-5 < b Initial program 52.0%
associate-/l*52.1%
+-commutative52.1%
Simplified52.1%
add-sqr-sqrt26.3%
sqrt-unprod29.4%
pow229.4%
Applied egg-rr29.4%
Taylor expanded in a around 0 29.4%
*-un-lft-identity29.4%
sqrt-pow152.1%
metadata-eval52.1%
pow152.1%
quot-tan52.3%
Applied egg-rr52.3%
*-lft-identity52.3%
Simplified52.3%
if -5.8e-5 < b < 1.39999999999999998e-5Initial program 98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in b around 0 98.7%
Final simplification73.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -5.6e-5) (not (<= b 5e-5))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.6e-5) || !(b <= 5e-5)) {
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 <= (-5.6d-5)) .or. (.not. (b <= 5d-5))) 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 <= -5.6e-5) || !(b <= 5e-5)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5.6e-5) or not (b <= 5e-5): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -5.6e-5) || !(b <= 5e-5)) 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 <= -5.6e-5) || ~((b <= 5e-5))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5.6e-5], N[Not[LessEqual[b, 5e-5]], $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 -5.6 \cdot 10^{-5} \lor \neg \left(b \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -5.59999999999999992e-5 or 5.00000000000000024e-5 < b Initial program 52.0%
associate-/l*52.1%
+-commutative52.1%
Simplified52.1%
add-sqr-sqrt26.3%
sqrt-unprod29.4%
pow229.4%
Applied egg-rr29.4%
Taylor expanded in a around 0 29.4%
*-un-lft-identity29.4%
sqrt-pow152.1%
metadata-eval52.1%
pow152.1%
quot-tan52.3%
Applied egg-rr52.3%
*-lft-identity52.3%
Simplified52.3%
if -5.59999999999999992e-5 < b < 5.00000000000000024e-5Initial program 98.7%
associate-/l*98.8%
+-commutative98.8%
Simplified98.8%
Taylor expanded in b around 0 98.6%
Final simplification73.9%
(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 73.7%
+-commutative73.7%
Simplified73.7%
associate-*r/73.8%
add-cube-cbrt72.6%
associate-*l*72.6%
pow272.6%
Applied egg-rr72.6%
Taylor expanded in b around 0 51.3%
Taylor expanded in r around 0 37.1%
Taylor expanded in a around 0 37.7%
Final simplification37.7%
(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 73.7%
associate-/l*73.8%
+-commutative73.8%
Simplified73.8%
add-sqr-sqrt38.4%
sqrt-unprod38.5%
pow238.5%
Applied egg-rr38.5%
Taylor expanded in a around 0 34.1%
*-un-lft-identity34.1%
sqrt-pow159.7%
metadata-eval59.7%
pow159.7%
quot-tan59.8%
Applied egg-rr59.8%
*-lft-identity59.8%
Simplified59.8%
Final simplification59.8%
(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 73.7%
associate-/l*73.8%
+-commutative73.8%
Simplified73.8%
Taylor expanded in b around 0 47.7%
Taylor expanded in a around 0 33.6%
Final simplification33.6%
herbie shell --seed 2024060
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))