
(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 (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(Float64(-sin(b)) * 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, \left(-\sin b\right) \cdot \sin a\right)}
\end{array}
Initial program 77.0%
associate-*r/77.1%
+-commutative77.1%
Simplified77.1%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 77.0%
associate-*r/77.1%
+-commutative77.1%
Simplified77.1%
cos-sum99.5%
Applied egg-rr99.5%
(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 77.0%
+-commutative77.0%
Simplified77.0%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (/ 1.0 (- (* (cos b) (/ (cos a) (* r (sin b)))) (/ (sin a) r))))
double code(double r, double a, double b) {
return 1.0 / ((cos(b) * (cos(a) / (r * sin(b)))) - (sin(a) / r));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / ((cos(b) * (cos(a) / (r * sin(b)))) - (sin(a) / r))
end function
public static double code(double r, double a, double b) {
return 1.0 / ((Math.cos(b) * (Math.cos(a) / (r * Math.sin(b)))) - (Math.sin(a) / r));
}
def code(r, a, b): return 1.0 / ((math.cos(b) * (math.cos(a) / (r * math.sin(b)))) - (math.sin(a) / r))
function code(r, a, b) return Float64(1.0 / Float64(Float64(cos(b) * Float64(cos(a) / Float64(r * sin(b)))) - Float64(sin(a) / r))) end
function tmp = code(r, a, b) tmp = 1.0 / ((cos(b) * (cos(a) / (r * sin(b)))) - (sin(a) / r)); end
code[r_, a_, b_] := N[(1.0 / N[(N[(N[Cos[b], $MachinePrecision] * N[(N[Cos[a], $MachinePrecision] / N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\cos b \cdot \frac{\cos a}{r \cdot \sin b} - \frac{\sin a}{r}}
\end{array}
Initial program 77.0%
+-commutative77.0%
Simplified77.0%
associate-*r/77.1%
clear-num76.5%
*-commutative76.5%
Applied egg-rr76.5%
cos-sum99.0%
div-sub91.1%
Applied egg-rr91.1%
associate-/l*91.2%
remove-double-neg91.2%
neg-mul-191.2%
*-commutative91.2%
distribute-rgt-neg-in91.2%
distribute-frac-neg91.2%
associate-*r*91.2%
*-commutative91.2%
neg-mul-191.2%
distribute-neg-frac91.2%
times-frac99.0%
*-inverses99.0%
distribute-lft-neg-in99.0%
metadata-eval99.0%
associate-*r/99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00072) (not (<= b 48000000000000.0))) (* r (tan b)) (* (sin b) (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00072) || !(b <= 48000000000000.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 ((b <= (-0.00072d0)) .or. (.not. (b <= 48000000000000.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 ((b <= -0.00072) || !(b <= 48000000000000.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 (b <= -0.00072) or not (b <= 48000000000000.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 ((b <= -0.00072) || !(b <= 48000000000000.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 ((b <= -0.00072) || ~((b <= 48000000000000.0))) tmp = r * tan(b); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00072], N[Not[LessEqual[b, 48000000000000.0]], $MachinePrecision]], 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}\;b \leq -0.00072 \lor \neg \left(b \leq 48000000000000\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -7.20000000000000045e-4 or 4.8e13 < b Initial program 52.7%
associate-*r/52.7%
+-commutative52.7%
Simplified52.7%
Taylor expanded in a around 0 52.8%
associate-/l*52.7%
quot-tan52.8%
Applied egg-rr52.8%
if -7.20000000000000045e-4 < b < 4.8e13Initial program 97.5%
+-commutative97.5%
Simplified97.5%
associate-*r/97.5%
clear-num96.6%
*-commutative96.6%
Applied egg-rr96.6%
Taylor expanded in b around 0 96.6%
clear-num97.5%
associate-/l*97.5%
Applied egg-rr97.5%
Final simplification77.1%
(FPCore (r a b)
:precision binary64
(if (<= b -0.00072)
(* r (tan b))
(if (<= b 48000000000000.0)
(* (sin b) (/ r (cos a)))
(/ (* r (sin b)) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.00072) {
tmp = r * tan(b);
} else if (b <= 48000000000000.0) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = (r * sin(b)) / cos(b);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-0.00072d0)) then
tmp = r * tan(b)
else if (b <= 48000000000000.0d0) then
tmp = sin(b) * (r / cos(a))
else
tmp = (r * sin(b)) / cos(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -0.00072) {
tmp = r * Math.tan(b);
} else if (b <= 48000000000000.0) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = (r * Math.sin(b)) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.00072: tmp = r * math.tan(b) elif b <= 48000000000000.0: tmp = math.sin(b) * (r / math.cos(a)) else: tmp = (r * math.sin(b)) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.00072) tmp = Float64(r * tan(b)); elseif (b <= 48000000000000.0) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(Float64(r * sin(b)) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.00072) tmp = r * tan(b); elseif (b <= 48000000000000.0) tmp = sin(b) * (r / cos(a)); else tmp = (r * sin(b)) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.00072], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 48000000000000.0], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00072:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 48000000000000:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\end{array}
\end{array}
if b < -7.20000000000000045e-4Initial program 60.2%
associate-*r/60.4%
+-commutative60.4%
Simplified60.4%
Taylor expanded in a around 0 60.6%
associate-/l*60.5%
quot-tan60.6%
Applied egg-rr60.6%
if -7.20000000000000045e-4 < b < 4.8e13Initial program 97.5%
+-commutative97.5%
Simplified97.5%
associate-*r/97.5%
clear-num96.6%
*-commutative96.6%
Applied egg-rr96.6%
Taylor expanded in b around 0 96.6%
clear-num97.5%
associate-/l*97.5%
Applied egg-rr97.5%
if 4.8e13 < b Initial program 46.2%
associate-*r/46.2%
+-commutative46.2%
Simplified46.2%
Taylor expanded in a around 0 46.1%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 77.0%
associate-*r/77.1%
+-commutative77.1%
Simplified77.1%
(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.0%
associate-*r/77.1%
+-commutative77.1%
Simplified77.1%
*-commutative77.1%
associate-/l*77.0%
Applied egg-rr77.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 77.0%
Final simplification77.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00092) (not (<= b 200.0))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00092) || !(b <= 200.0)) {
tmp = r * tan(b);
} else {
tmp = 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 ((b <= (-0.00092d0)) .or. (.not. (b <= 200.0d0))) then
tmp = r * tan(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00092) || !(b <= 200.0)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00092) or not (b <= 200.0): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00092) || !(b <= 200.0)) tmp = Float64(r * tan(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -0.00092) || ~((b <= 200.0))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00092], N[Not[LessEqual[b, 200.0]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.00092 \lor \neg \left(b \leq 200\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -9.2000000000000003e-4 or 200 < b Initial program 52.4%
associate-*r/52.4%
+-commutative52.4%
Simplified52.4%
Taylor expanded in a around 0 52.4%
associate-/l*52.3%
quot-tan52.4%
Applied egg-rr52.4%
if -9.2000000000000003e-4 < b < 200Initial program 98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in b around 0 98.1%
clear-num98.1%
un-div-inv98.0%
Applied egg-rr98.0%
associate-/r/98.2%
Simplified98.2%
Final simplification77.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00076) (not (<= b 200.0))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00076) || !(b <= 200.0)) {
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 <= (-0.00076d0)) .or. (.not. (b <= 200.0d0))) 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 <= -0.00076) || !(b <= 200.0)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00076) or not (b <= 200.0): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00076) || !(b <= 200.0)) 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 <= -0.00076) || ~((b <= 200.0))) tmp = r * tan(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, 200.0]], $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 -0.00076 \lor \neg \left(b \leq 200\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -7.6000000000000004e-4 or 200 < b Initial program 52.4%
associate-*r/52.4%
+-commutative52.4%
Simplified52.4%
Taylor expanded in a around 0 52.4%
associate-/l*52.3%
quot-tan52.4%
Applied egg-rr52.4%
if -7.6000000000000004e-4 < b < 200Initial program 98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in b around 0 98.1%
Final simplification77.1%
(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.0%
associate-*r/77.1%
+-commutative77.1%
Simplified77.1%
Taylor expanded in a around 0 59.9%
associate-/l*59.8%
quot-tan59.9%
Applied egg-rr59.9%
(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.0%
+-commutative77.0%
Simplified77.0%
Taylor expanded in b around 0 54.6%
Taylor expanded in a around 0 37.3%
herbie shell --seed 2024123
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))