
(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 (- (/ (cos a) (tan b)) (/ (sin b) (/ (sin b) (sin a))))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(b)) - (sin(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) / tan(b)) - (sin(b) / (sin(b) / sin(a))))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / Math.tan(b)) - (Math.sin(b) / (Math.sin(b) / Math.sin(a))));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - (math.sin(b) / (math.sin(b) / math.sin(a))))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - Float64(sin(b) / Float64(sin(b) / sin(a))))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - (sin(b) / (sin(b) / sin(a)))); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] / N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \frac{\sin b}{\frac{\sin b}{\sin a}}}
\end{array}
Initial program 74.5%
associate-/l*74.5%
+-commutative74.5%
Simplified74.5%
cos-sum99.4%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.4%
div-sub99.4%
*-commutative99.4%
associate-/l*99.4%
quot-tan99.5%
associate-/l*99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (cos a) (tan b)) (sin a))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(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) / tan(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / Math.tan(b)) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \sin a}
\end{array}
Initial program 74.5%
associate-/l*74.5%
+-commutative74.5%
Simplified74.5%
cos-sum99.4%
fma-neg99.5%
Applied egg-rr99.5%
fma-neg99.4%
div-sub99.4%
*-commutative99.4%
associate-/l*99.4%
quot-tan99.5%
associate-/l*99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -5.8e-5) (not (<= b 390000.0))) (* (sin b) (/ r (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5.8e-5) || !(b <= 390000.0)) {
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 <= (-5.8d-5)) .or. (.not. (b <= 390000.0d0))) 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 <= -5.8e-5) || !(b <= 390000.0)) {
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 <= -5.8e-5) or not (b <= 390000.0): 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 <= -5.8e-5) || !(b <= 390000.0)) 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 <= -5.8e-5) || ~((b <= 390000.0))) 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, -5.8e-5], N[Not[LessEqual[b, 390000.0]], $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 -5.8 \cdot 10^{-5} \lor \neg \left(b \leq 390000\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -5.8e-5 or 3.9e5 < b Initial program 49.8%
associate-/l*49.9%
+-commutative49.9%
Simplified49.9%
Taylor expanded in a around 0 50.0%
associate-/l*50.1%
associate-/r/50.0%
Simplified50.0%
if -5.8e-5 < b < 3.9e5Initial program 98.0%
associate-/l*97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 98.1%
associate-/l*98.0%
associate-/r/98.2%
Simplified98.2%
Final simplification74.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00068) (not (<= b 390000.0))) (/ r (/ (cos b) (sin b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00068) || !(b <= 390000.0)) {
tmp = r / (cos(b) / 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 <= (-0.00068d0)) .or. (.not. (b <= 390000.0d0))) then
tmp = r / (cos(b) / 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 <= -0.00068) || !(b <= 390000.0)) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00068) or not (b <= 390000.0): tmp = r / (math.cos(b) / math.sin(b)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.00068) || !(b <= 390000.0)) tmp = Float64(r / Float64(cos(b) / 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 <= -0.00068) || ~((b <= 390000.0))) tmp = r / (cos(b) / sin(b)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00068], N[Not[LessEqual[b, 390000.0]], $MachinePrecision]], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[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.00068 \lor \neg \left(b \leq 390000\right):\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -6.8e-4 or 3.9e5 < b Initial program 49.8%
associate-/l*49.9%
+-commutative49.9%
Simplified49.9%
Taylor expanded in a around 0 50.1%
if -6.8e-4 < b < 3.9e5Initial program 98.0%
associate-/l*97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 98.1%
associate-/l*98.0%
associate-/r/98.2%
Simplified98.2%
Final simplification74.7%
(FPCore (r a b) :precision binary64 (if (<= b -5.2e-5) (/ (sin b) (/ (cos b) r)) (if (<= b 390000.0) (* r (/ b (cos a))) (/ r (/ (cos b) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -5.2e-5) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 390000.0) {
tmp = r * (b / cos(a));
} else {
tmp = r / (cos(b) / sin(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 <= (-5.2d-5)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 390000.0d0) then
tmp = r * (b / cos(a))
else
tmp = r / (cos(b) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -5.2e-5) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 390000.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r / (Math.cos(b) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -5.2e-5: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 390000.0: tmp = r * (b / math.cos(a)) else: tmp = r / (math.cos(b) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -5.2e-5) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 390000.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r / Float64(cos(b) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -5.2e-5) tmp = sin(b) / (cos(b) / r); elseif (b <= 390000.0) tmp = r * (b / cos(a)); else tmp = r / (cos(b) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -5.2e-5], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 390000.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 390000:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\end{array}
\end{array}
if b < -5.19999999999999968e-5Initial program 51.7%
associate-/l*51.8%
+-commutative51.8%
Simplified51.8%
associate-/l*51.7%
add-exp-log27.9%
div-inv27.9%
associate-*l*27.9%
div-inv27.9%
Applied egg-rr27.9%
Taylor expanded in r around 0 51.7%
*-commutative51.7%
+-commutative51.7%
associate-/l*51.8%
+-commutative51.8%
Simplified51.8%
Taylor expanded in a around 0 51.5%
if -5.19999999999999968e-5 < b < 3.9e5Initial program 98.0%
associate-/l*97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 98.1%
associate-/l*98.0%
associate-/r/98.2%
Simplified98.2%
if 3.9e5 < b Initial program 47.5%
associate-/l*47.6%
+-commutative47.6%
Simplified47.6%
Taylor expanded in a around 0 48.4%
Final simplification74.7%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ a b)))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((a + b)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((a + b)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((a + b))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(a + b\right)}
\end{array}
Initial program 74.5%
associate-/l*74.5%
+-commutative74.5%
Simplified74.5%
associate-/r/74.5%
Applied egg-rr74.5%
Final simplification74.5%
(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 74.5%
associate-/l*74.5%
+-commutative74.5%
Simplified74.5%
clear-num73.9%
associate-/r/74.5%
clear-num74.6%
Applied egg-rr74.6%
Final simplification74.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -8.5e-5) (not (<= b 390000.0))) (/ r (- (/ 1.0 (tan b)) a)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -8.5e-5) || !(b <= 390000.0)) {
tmp = r / ((1.0 / tan(b)) - a);
} 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.5d-5)) .or. (.not. (b <= 390000.0d0))) then
tmp = r / ((1.0d0 / tan(b)) - a)
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.5e-5) || !(b <= 390000.0)) {
tmp = r / ((1.0 / Math.tan(b)) - a);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -8.5e-5) or not (b <= 390000.0): tmp = r / ((1.0 / math.tan(b)) - a) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -8.5e-5) || !(b <= 390000.0)) tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); 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.5e-5) || ~((b <= 390000.0))) tmp = r / ((1.0 / tan(b)) - a); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -8.5e-5], N[Not[LessEqual[b, 390000.0]], $MachinePrecision]], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{-5} \lor \neg \left(b \leq 390000\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -8.500000000000001e-5 or 3.9e5 < b Initial program 49.8%
associate-/l*49.9%
+-commutative49.9%
Simplified49.9%
Taylor expanded in a around 0 46.2%
+-commutative46.2%
mul-1-neg46.2%
unsub-neg46.2%
Simplified46.2%
expm1-log1p-u31.3%
expm1-udef31.1%
clear-num31.1%
quot-tan31.1%
Applied egg-rr31.1%
expm1-def31.3%
expm1-log1p46.3%
Simplified46.3%
if -8.500000000000001e-5 < b < 3.9e5Initial program 98.0%
associate-/l*97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 98.1%
associate-/l*98.0%
associate-/r/98.2%
Simplified98.2%
Final simplification72.8%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ 1.0 (tan b)) a)))
(if (<= b -0.00025)
(/ 1.0 (/ t_0 r))
(if (<= b 390000.0) (* r (/ b (cos a))) (/ r t_0)))))
double code(double r, double a, double b) {
double t_0 = (1.0 / tan(b)) - a;
double tmp;
if (b <= -0.00025) {
tmp = 1.0 / (t_0 / r);
} else if (b <= 390000.0) {
tmp = r * (b / cos(a));
} else {
tmp = r / t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / tan(b)) - a
if (b <= (-0.00025d0)) then
tmp = 1.0d0 / (t_0 / r)
else if (b <= 390000.0d0) then
tmp = r * (b / cos(a))
else
tmp = r / t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (1.0 / Math.tan(b)) - a;
double tmp;
if (b <= -0.00025) {
tmp = 1.0 / (t_0 / r);
} else if (b <= 390000.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r / t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (1.0 / math.tan(b)) - a tmp = 0 if b <= -0.00025: tmp = 1.0 / (t_0 / r) elif b <= 390000.0: tmp = r * (b / math.cos(a)) else: tmp = r / t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(1.0 / tan(b)) - a) tmp = 0.0 if (b <= -0.00025) tmp = Float64(1.0 / Float64(t_0 / r)); elseif (b <= 390000.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r / t_0); end return tmp end
function tmp_2 = code(r, a, b) t_0 = (1.0 / tan(b)) - a; tmp = 0.0; if (b <= -0.00025) tmp = 1.0 / (t_0 / r); elseif (b <= 390000.0) tmp = r * (b / cos(a)); else tmp = r / t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, If[LessEqual[b, -0.00025], N[(1.0 / N[(t$95$0 / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 390000.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -0.00025:\\
\;\;\;\;\frac{1}{\frac{t_0}{r}}\\
\mathbf{elif}\;b \leq 390000:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{t_0}\\
\end{array}
\end{array}
if b < -2.5000000000000001e-4Initial program 51.7%
associate-/l*51.8%
+-commutative51.8%
Simplified51.8%
Taylor expanded in a around 0 48.5%
+-commutative48.5%
mul-1-neg48.5%
unsub-neg48.5%
Simplified48.5%
clear-num48.5%
inv-pow48.5%
clear-num48.4%
quot-tan48.6%
Applied egg-rr48.6%
unpow-148.6%
Simplified48.6%
if -2.5000000000000001e-4 < b < 3.9e5Initial program 98.0%
associate-/l*97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 98.1%
associate-/l*98.0%
associate-/r/98.2%
Simplified98.2%
if 3.9e5 < b Initial program 47.5%
associate-/l*47.6%
+-commutative47.6%
Simplified47.6%
Taylor expanded in a around 0 43.4%
+-commutative43.4%
mul-1-neg43.4%
unsub-neg43.4%
Simplified43.4%
expm1-log1p-u28.6%
expm1-udef28.4%
clear-num28.4%
quot-tan28.4%
Applied egg-rr28.4%
expm1-def28.6%
expm1-log1p43.4%
Simplified43.4%
Final simplification72.8%
(FPCore (r a b) :precision binary64 (if (<= b -1950000000.0) (/ (- r) (sin a)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1950000000.0) {
tmp = -r / sin(a);
} 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 <= (-1950000000.0d0)) then
tmp = -r / sin(a)
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 <= -1950000000.0) {
tmp = -r / Math.sin(a);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1950000000.0: tmp = -r / math.sin(a) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1950000000.0) tmp = Float64(Float64(-r) / sin(a)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -1950000000.0) tmp = -r / sin(a); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1950000000.0], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1950000000:\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.95e9Initial program 50.1%
associate-/l*50.1%
+-commutative50.1%
Simplified50.1%
Taylor expanded in b around 0 11.2%
+-commutative11.2%
neg-mul-111.2%
unsub-neg11.2%
Simplified11.2%
Taylor expanded in b around inf 10.8%
associate-*r/10.8%
neg-mul-110.8%
Simplified10.8%
if -1.95e9 < b Initial program 82.8%
associate-/l*82.7%
+-commutative82.7%
Simplified82.7%
Taylor expanded in b around 0 68.8%
associate-/l*68.7%
associate-/r/68.9%
Simplified68.9%
Final simplification54.1%
(FPCore (r a b) :precision binary64 (if (<= b -4.5) (/ (- r) (sin a)) (* r b)))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.5) {
tmp = -r / sin(a);
} else {
tmp = r * 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 <= (-4.5d0)) then
tmp = -r / sin(a)
else
tmp = r * b
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -4.5) {
tmp = -r / Math.sin(a);
} else {
tmp = r * b;
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -4.5: tmp = -r / math.sin(a) else: tmp = r * b return tmp
function code(r, a, b) tmp = 0.0 if (b <= -4.5) tmp = Float64(Float64(-r) / sin(a)); else tmp = Float64(r * b); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -4.5) tmp = -r / sin(a); else tmp = r * b; end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.5], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], N[(r * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5:\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot b\\
\end{array}
\end{array}
if b < -4.5Initial program 50.3%
associate-/l*50.4%
+-commutative50.4%
Simplified50.4%
Taylor expanded in b around 0 11.3%
+-commutative11.3%
neg-mul-111.3%
unsub-neg11.3%
Simplified11.3%
Taylor expanded in b around inf 10.7%
associate-*r/10.7%
neg-mul-110.7%
Simplified10.7%
if -4.5 < b Initial program 83.0%
associate-/l*83.0%
+-commutative83.0%
Simplified83.0%
Taylor expanded in b around 0 69.4%
associate-/l*69.3%
associate-/r/69.4%
Simplified69.4%
Taylor expanded in a around 0 43.2%
Final simplification34.7%
(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 74.5%
associate-/l*74.5%
+-commutative74.5%
Simplified74.5%
Taylor expanded in b around 0 52.1%
associate-/l*52.1%
associate-/r/52.1%
Simplified52.1%
Taylor expanded in a around 0 33.0%
Final simplification33.0%
herbie shell --seed 2023299
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))