
(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 21 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 1.0 (* (cos a) (cos b)) (* (sin b) (- (sin a)))) (fma (- (sin b)) (sin a) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return (r * sin(b)) / (fma(1.0, (cos(a) * cos(b)), (sin(b) * -sin(a))) + fma(-sin(b), sin(a), (sin(b) * sin(a))));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(fma(1.0, Float64(cos(a) * cos(b)), Float64(sin(b) * Float64(-sin(a)))) + fma(Float64(-sin(b)), sin(a), Float64(sin(b) * sin(a))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 * N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(1, \cos a \cdot \cos b, \sin b \cdot \left(-\sin a\right)\right) + \mathsf{fma}\left(-\sin b, \sin a, \sin b \cdot \sin a\right)}
\end{array}
Initial program 73.9%
associate-*r/73.9%
+-commutative73.9%
Simplified73.9%
cos-sum99.5%
*-un-lft-identity99.5%
*-un-lft-identity99.5%
prod-diff99.5%
Applied egg-rr99.5%
*-rgt-identity99.5%
*-commutative99.5%
distribute-lft-neg-in99.5%
*-commutative99.5%
fma-udef99.5%
*-rgt-identity99.5%
distribute-lft-neg-in99.5%
*-rgt-identity99.5%
fma-udef99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(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 73.9%
associate-*r/73.9%
+-commutative73.9%
Simplified73.9%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 73.9%
+-commutative73.9%
Simplified73.9%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (- (* (cos a) (cos b)) (* (sin b) (sin a))) r)))
double code(double r, double a, double b) {
return sin(b) / (((cos(a) * cos(b)) - (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 = sin(b) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r)
end function
public static double code(double r, double a, double b) {
return Math.sin(b) / (((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))) / r);
}
def code(r, a, b): return math.sin(b) / (((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))) / r)
function code(r, a, b) return Float64(sin(b) / Float64(Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))) / r)) end
function tmp = code(r, a, b) tmp = sin(b) / (((cos(a) * cos(b)) - (sin(b) * sin(a))) / r); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\cos a \cdot \cos b - \sin b \cdot \sin a}{r}}
\end{array}
Initial program 73.9%
*-commutative73.9%
associate-/r/73.9%
+-commutative73.9%
Simplified73.9%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(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 73.9%
associate-*r/73.9%
+-commutative73.9%
Simplified73.9%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -1.45e-5) (not (<= a 16500000000.0))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -1.45e-5) || !(a <= 16500000000.0)) {
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 <= (-1.45d-5)) .or. (.not. (a <= 16500000000.0d0))) 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 <= -1.45e-5) || !(a <= 16500000000.0)) {
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 <= -1.45e-5) or not (a <= 16500000000.0): 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 <= -1.45e-5) || !(a <= 16500000000.0)) 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 <= -1.45e-5) || ~((a <= 16500000000.0))) 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, -1.45e-5], N[Not[LessEqual[a, 16500000000.0]], $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 -1.45 \cdot 10^{-5} \lor \neg \left(a \leq 16500000000\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -1.45e-5 or 1.65e10 < a Initial program 49.1%
+-commutative49.1%
Simplified49.1%
Taylor expanded in b around 0 49.0%
if -1.45e-5 < a < 1.65e10Initial program 99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 98.9%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (or (<= a -1.9e-6) (not (<= a 16500000000.0))) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -1.9e-6) || !(a <= 16500000000.0)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = sin(b) * (r / 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 <= (-1.9d-6)) .or. (.not. (a <= 16500000000.0d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -1.9e-6) || !(a <= 16500000000.0)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -1.9e-6) or not (a <= 16500000000.0): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -1.9e-6) || !(a <= 16500000000.0)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -1.9e-6) || ~((a <= 16500000000.0))) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -1.9e-6], N[Not[LessEqual[a, 16500000000.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.9 \cdot 10^{-6} \lor \neg \left(a \leq 16500000000\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -1.9e-6 or 1.65e10 < a Initial program 49.1%
+-commutative49.1%
Simplified49.1%
Taylor expanded in b around 0 49.0%
if -1.9e-6 < a < 1.65e10Initial program 99.1%
*-commutative99.1%
associate-/r/99.0%
+-commutative99.0%
Simplified99.0%
clear-num98.9%
associate-/r/98.9%
Applied egg-rr98.9%
div-inv99.0%
associate-*l/99.0%
*-un-lft-identity99.0%
Applied egg-rr99.0%
Taylor expanded in a around 0 99.0%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (or (<= a -1.2e-5) (not (<= a 16500000000.0))) (/ r (/ (cos a) (sin b))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -1.2e-5) || !(a <= 16500000000.0)) {
tmp = r / (cos(a) / sin(b));
} else {
tmp = sin(b) * (r / 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 <= (-1.2d-5)) .or. (.not. (a <= 16500000000.0d0))) then
tmp = r / (cos(a) / sin(b))
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -1.2e-5) || !(a <= 16500000000.0)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -1.2e-5) or not (a <= 16500000000.0): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -1.2e-5) || !(a <= 16500000000.0)) tmp = Float64(r / Float64(cos(a) / sin(b))); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -1.2e-5) || ~((a <= 16500000000.0))) tmp = r / (cos(a) / sin(b)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -1.2e-5], N[Not[LessEqual[a, 16500000000.0]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.2 \cdot 10^{-5} \lor \neg \left(a \leq 16500000000\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -1.2e-5 or 1.65e10 < a Initial program 49.1%
+-commutative49.1%
Simplified49.1%
expm1-log1p-u47.1%
Applied egg-rr47.1%
Taylor expanded in b around 0 47.5%
expm1-log1p-u49.0%
clear-num49.0%
un-div-inv49.0%
Applied egg-rr49.0%
if -1.2e-5 < a < 1.65e10Initial program 99.1%
*-commutative99.1%
associate-/r/99.0%
+-commutative99.0%
Simplified99.0%
clear-num98.9%
associate-/r/98.9%
Applied egg-rr98.9%
div-inv99.0%
associate-*l/99.0%
*-un-lft-identity99.0%
Applied egg-rr99.0%
Taylor expanded in a around 0 99.0%
Final simplification73.8%
(FPCore (r a b)
:precision binary64
(if (<= a -1.45e-5)
(/ r (/ (cos a) (sin b)))
(if (<= a 16500000000.0)
(* (sin b) (/ r (cos b)))
(/ (sin b) (/ (cos a) r)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -1.45e-5) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 16500000000.0) {
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 <= (-1.45d-5)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 16500000000.0d0) 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 <= -1.45e-5) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 16500000000.0) {
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 <= -1.45e-5: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 16500000000.0: 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 <= -1.45e-5) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 16500000000.0) 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 <= -1.45e-5) tmp = r / (cos(a) / sin(b)); elseif (a <= 16500000000.0) 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, -1.45e-5], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 16500000000.0], 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 -1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 16500000000:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if a < -1.45e-5Initial program 46.3%
+-commutative46.3%
Simplified46.3%
expm1-log1p-u43.3%
Applied egg-rr43.3%
Taylor expanded in b around 0 44.1%
expm1-log1p-u45.6%
clear-num45.6%
un-div-inv45.6%
Applied egg-rr45.6%
if -1.45e-5 < a < 1.65e10Initial program 99.1%
*-commutative99.1%
associate-/r/99.0%
+-commutative99.0%
Simplified99.0%
clear-num98.9%
associate-/r/98.9%
Applied egg-rr98.9%
div-inv99.0%
associate-*l/99.0%
*-un-lft-identity99.0%
Applied egg-rr99.0%
Taylor expanded in a around 0 99.0%
if 1.65e10 < a Initial program 51.2%
*-commutative51.2%
associate-/r/51.3%
+-commutative51.3%
Simplified51.3%
Taylor expanded in b around 0 51.8%
Final simplification73.8%
(FPCore (r a b)
:precision binary64
(if (<= a -1.42e-5)
(/ r (/ (cos a) (sin b)))
(if (<= a 16500000000.0)
(/ (* r (sin b)) (cos b))
(/ (sin b) (/ (cos a) r)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -1.42e-5) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 16500000000.0) {
tmp = (r * sin(b)) / 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 <= (-1.42d-5)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 16500000000.0d0) then
tmp = (r * sin(b)) / 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 <= -1.42e-5) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 16500000000.0) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else {
tmp = Math.sin(b) / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -1.42e-5: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 16500000000.0: tmp = (r * math.sin(b)) / math.cos(b) else: tmp = math.sin(b) / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -1.42e-5) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 16500000000.0) tmp = Float64(Float64(r * sin(b)) / 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 <= -1.42e-5) tmp = r / (cos(a) / sin(b)); elseif (a <= 16500000000.0) tmp = (r * sin(b)) / cos(b); else tmp = sin(b) / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -1.42e-5], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 16500000000.0], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $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 -1.42 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 16500000000:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if a < -1.42e-5Initial program 46.3%
+-commutative46.3%
Simplified46.3%
expm1-log1p-u43.3%
Applied egg-rr43.3%
Taylor expanded in b around 0 44.1%
expm1-log1p-u45.6%
clear-num45.6%
un-div-inv45.6%
Applied egg-rr45.6%
if -1.42e-5 < a < 1.65e10Initial program 99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.0%
if 1.65e10 < a Initial program 51.2%
*-commutative51.2%
associate-/r/51.3%
+-commutative51.3%
Simplified51.3%
Taylor expanded in b around 0 51.8%
Final simplification73.9%
(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.9%
Final simplification73.9%
(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 73.9%
*-commutative73.9%
associate-/r/73.9%
+-commutative73.9%
Simplified73.9%
div-inv73.8%
clear-num73.9%
*-commutative73.9%
Applied egg-rr73.9%
Final simplification73.9%
(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 73.9%
associate-*r/73.9%
+-commutative73.9%
Simplified73.9%
Final simplification73.9%
(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 73.9%
+-commutative73.9%
Simplified73.9%
Taylor expanded in b around 0 50.1%
Final simplification50.1%
(FPCore (r a b) :precision binary64 (if (<= b -105000000.0) (* r (sin b)) (if (<= b 9.2) (/ b (/ (cos (+ b a)) r)) (/ (sin b) (/ 1.0 r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -105000000.0) {
tmp = r * sin(b);
} else if (b <= 9.2) {
tmp = b / (cos((b + a)) / r);
} else {
tmp = sin(b) / (1.0 / 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 (b <= (-105000000.0d0)) then
tmp = r * sin(b)
else if (b <= 9.2d0) then
tmp = b / (cos((b + a)) / r)
else
tmp = sin(b) / (1.0d0 / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -105000000.0) {
tmp = r * Math.sin(b);
} else if (b <= 9.2) {
tmp = b / (Math.cos((b + a)) / r);
} else {
tmp = Math.sin(b) / (1.0 / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -105000000.0: tmp = r * math.sin(b) elif b <= 9.2: tmp = b / (math.cos((b + a)) / r) else: tmp = math.sin(b) / (1.0 / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -105000000.0) tmp = Float64(r * sin(b)); elseif (b <= 9.2) tmp = Float64(b / Float64(cos(Float64(b + a)) / r)); else tmp = Float64(sin(b) / Float64(1.0 / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -105000000.0) tmp = r * sin(b); elseif (b <= 9.2) tmp = b / (cos((b + a)) / r); else tmp = sin(b) / (1.0 / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -105000000.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.2], N[(b / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -105000000:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 9.2:\\
\;\;\;\;\frac{b}{\frac{\cos \left(b + a\right)}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\end{array}
\end{array}
if b < -1.05e8Initial program 52.5%
+-commutative52.5%
Simplified52.5%
expm1-log1p-u33.1%
Applied egg-rr33.1%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 11.3%
if -1.05e8 < b < 9.1999999999999993Initial program 97.7%
+-commutative97.7%
Simplified97.7%
expm1-log1p-u97.5%
Applied egg-rr97.5%
add-sqr-sqrt77.8%
sqrt-unprod82.5%
pow282.5%
Applied egg-rr82.5%
unpow282.5%
rem-sqrt-square82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in b around 0 81.9%
associate-/l*81.8%
+-commutative81.8%
rem-square-sqrt77.0%
fabs-sqr77.0%
rem-square-sqrt96.0%
Simplified96.0%
if 9.1999999999999993 < b Initial program 55.1%
*-commutative55.1%
associate-/r/55.2%
+-commutative55.2%
Simplified55.2%
clear-num55.1%
associate-/r/55.1%
Applied egg-rr55.1%
Taylor expanded in a around 0 55.1%
Taylor expanded in b around 0 11.8%
Final simplification50.2%
(FPCore (r a b) :precision binary64 (if (<= b -106000000.0) (* r (sin b)) (if (<= b 15.6) (/ (* r b) (cos (+ b a))) (/ (sin b) (/ 1.0 r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -106000000.0) {
tmp = r * sin(b);
} else if (b <= 15.6) {
tmp = (r * b) / cos((b + a));
} else {
tmp = sin(b) / (1.0 / 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 (b <= (-106000000.0d0)) then
tmp = r * sin(b)
else if (b <= 15.6d0) then
tmp = (r * b) / cos((b + a))
else
tmp = sin(b) / (1.0d0 / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -106000000.0) {
tmp = r * Math.sin(b);
} else if (b <= 15.6) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = Math.sin(b) / (1.0 / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -106000000.0: tmp = r * math.sin(b) elif b <= 15.6: tmp = (r * b) / math.cos((b + a)) else: tmp = math.sin(b) / (1.0 / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -106000000.0) tmp = Float64(r * sin(b)); elseif (b <= 15.6) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(sin(b) / Float64(1.0 / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -106000000.0) tmp = r * sin(b); elseif (b <= 15.6) tmp = (r * b) / cos((b + a)); else tmp = sin(b) / (1.0 / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -106000000.0], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 15.6], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -106000000:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 15.6:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\end{array}
\end{array}
if b < -1.06e8Initial program 52.5%
+-commutative52.5%
Simplified52.5%
expm1-log1p-u33.1%
Applied egg-rr33.1%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 11.3%
if -1.06e8 < b < 15.5999999999999996Initial program 97.7%
associate-*r/97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in b around 0 96.1%
if 15.5999999999999996 < b Initial program 55.1%
*-commutative55.1%
associate-/r/55.2%
+-commutative55.2%
Simplified55.2%
clear-num55.1%
associate-/r/55.1%
Applied egg-rr55.1%
Taylor expanded in a around 0 55.1%
Taylor expanded in b around 0 11.8%
Final simplification50.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.55) (not (<= b 30.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.55) || !(b <= 30.0)) {
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 <= (-0.55d0)) .or. (.not. (b <= 30.0d0))) 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 <= -0.55) || !(b <= 30.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.55) or not (b <= 30.0): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.55) || !(b <= 30.0)) 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 <= -0.55) || ~((b <= 30.0))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.55], N[Not[LessEqual[b, 30.0]], $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 -0.55 \lor \neg \left(b \leq 30\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -0.55000000000000004 or 30 < b Initial program 53.9%
+-commutative53.9%
Simplified53.9%
expm1-log1p-u35.8%
Applied egg-rr35.8%
Taylor expanded in b around 0 10.0%
Taylor expanded in a around 0 11.4%
if -0.55000000000000004 < b < 30Initial program 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 97.6%
Final simplification50.1%
(FPCore (r a b) :precision binary64 (if (<= b -1.16) (* r (sin b)) (if (<= b 24.0) (* r (/ b (cos a))) (/ (sin b) (/ 1.0 r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.16) {
tmp = r * sin(b);
} else if (b <= 24.0) {
tmp = r * (b / cos(a));
} else {
tmp = sin(b) / (1.0 / 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 (b <= (-1.16d0)) then
tmp = r * sin(b)
else if (b <= 24.0d0) then
tmp = r * (b / cos(a))
else
tmp = sin(b) / (1.0d0 / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -1.16) {
tmp = r * Math.sin(b);
} else if (b <= 24.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = Math.sin(b) / (1.0 / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.16: tmp = r * math.sin(b) elif b <= 24.0: tmp = r * (b / math.cos(a)) else: tmp = math.sin(b) / (1.0 / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.16) tmp = Float64(r * sin(b)); elseif (b <= 24.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(sin(b) / Float64(1.0 / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -1.16) tmp = r * sin(b); elseif (b <= 24.0) tmp = r * (b / cos(a)); else tmp = sin(b) / (1.0 / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.16], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 24.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.16:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 24:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\end{array}
\end{array}
if b < -1.15999999999999992Initial program 52.6%
+-commutative52.6%
Simplified52.6%
expm1-log1p-u33.5%
Applied egg-rr33.5%
Taylor expanded in b around 0 11.1%
Taylor expanded in a around 0 11.0%
if -1.15999999999999992 < b < 24Initial program 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 97.6%
if 24 < b Initial program 55.1%
*-commutative55.1%
associate-/r/55.2%
+-commutative55.2%
Simplified55.2%
clear-num55.1%
associate-/r/55.1%
Applied egg-rr55.1%
Taylor expanded in a around 0 55.1%
Taylor expanded in b around 0 11.8%
Final simplification50.1%
(FPCore (r a b) :precision binary64 (if (<= b -1.02) (* r (sin b)) (if (<= b 30.0) (/ (* r b) (cos a)) (/ (sin b) (/ 1.0 r)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.02) {
tmp = r * sin(b);
} else if (b <= 30.0) {
tmp = (r * b) / cos(a);
} else {
tmp = sin(b) / (1.0 / 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 (b <= (-1.02d0)) then
tmp = r * sin(b)
else if (b <= 30.0d0) then
tmp = (r * b) / cos(a)
else
tmp = sin(b) / (1.0d0 / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -1.02) {
tmp = r * Math.sin(b);
} else if (b <= 30.0) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = Math.sin(b) / (1.0 / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.02: tmp = r * math.sin(b) elif b <= 30.0: tmp = (r * b) / math.cos(a) else: tmp = math.sin(b) / (1.0 / r) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.02) tmp = Float64(r * sin(b)); elseif (b <= 30.0) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(sin(b) / Float64(1.0 / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -1.02) tmp = r * sin(b); elseif (b <= 30.0) tmp = (r * b) / cos(a); else tmp = sin(b) / (1.0 / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.02], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 30.0], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.02:\\
\;\;\;\;r \cdot \sin b\\
\mathbf{elif}\;b \leq 30:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\end{array}
\end{array}
if b < -1.02Initial program 52.6%
+-commutative52.6%
Simplified52.6%
expm1-log1p-u33.5%
Applied egg-rr33.5%
Taylor expanded in b around 0 11.1%
Taylor expanded in a around 0 11.0%
if -1.02 < b < 30Initial program 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 97.6%
if 30 < b Initial program 55.1%
*-commutative55.1%
associate-/r/55.2%
+-commutative55.2%
Simplified55.2%
clear-num55.1%
associate-/r/55.1%
Applied egg-rr55.1%
Taylor expanded in a around 0 55.1%
Taylor expanded in b around 0 11.8%
Final simplification50.2%
(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.9%
+-commutative73.9%
Simplified73.9%
expm1-log1p-u63.9%
Applied egg-rr63.9%
Taylor expanded in b around 0 49.4%
Taylor expanded in a around 0 36.2%
Final simplification36.2%
(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.9%
+-commutative73.9%
Simplified73.9%
Taylor expanded in b around 0 45.8%
Taylor expanded in a around 0 31.9%
Final simplification31.9%
herbie shell --seed 2023194
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))