
(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 11 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 (* (/ (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(Float64(sin(b) / 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[(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] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a} \cdot r
\end{array}
Initial program 74.7%
+-commutative74.7%
Simplified74.7%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in r around 0 99.4%
+-commutative99.4%
mul-1-neg99.4%
*-commutative99.4%
sub-neg99.4%
Simplified99.4%
log1p-expm1-u99.5%
Applied egg-rr99.5%
Taylor expanded in b around inf 99.4%
associate-/l*99.4%
associate-/r/99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (* (cos a) (cos b))))
double code(double r, double a, double b) {
return (sin(b) * r) / (cos(a) * cos(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) * cos(b))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / (Math.cos(a) * Math.cos(b));
}
def code(r, a, b): return (math.sin(b) * r) / (math.cos(a) * math.cos(b))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(cos(a) * cos(b))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / (cos(a) * cos(b)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos a \cdot \cos b}
\end{array}
Initial program 74.7%
+-commutative74.7%
Simplified74.7%
cos-sum99.4%
cancel-sign-sub-inv99.4%
fma-def99.5%
Applied egg-rr99.5%
Taylor expanded in r around 0 99.4%
+-commutative99.4%
mul-1-neg99.4%
*-commutative99.4%
sub-neg99.4%
Simplified99.4%
sin-mult76.0%
div-sub76.0%
cos-diff75.8%
*-commutative75.8%
add-sqr-sqrt35.4%
sqrt-unprod74.9%
sqr-neg74.9%
sqrt-unprod39.5%
add-sqr-sqrt74.3%
cancel-sign-sub-inv74.3%
*-commutative74.3%
cos-sum76.0%
Applied egg-rr76.0%
+-inverses76.0%
Simplified76.0%
Final simplification76.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -350000000.0) (not (<= b 8.8e-6))) (* r (/ (sin b) (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -350000000.0) || !(b <= 8.8e-6)) {
tmp = r * (sin(b) / 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 <= (-350000000.0d0)) .or. (.not. (b <= 8.8d-6))) then
tmp = r * (sin(b) / 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 <= -350000000.0) || !(b <= 8.8e-6)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -350000000.0) or not (b <= 8.8e-6): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -350000000.0) || !(b <= 8.8e-6)) tmp = Float64(r * Float64(sin(b) / 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 <= -350000000.0) || ~((b <= 8.8e-6))) tmp = r * (sin(b) / cos(b)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -350000000.0], N[Not[LessEqual[b, 8.8e-6]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 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 -350000000 \lor \neg \left(b \leq 8.8 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -3.5e8 or 8.8000000000000004e-6 < b Initial program 56.9%
*-commutative56.9%
associate-/l*56.9%
+-commutative56.9%
Simplified56.9%
Taylor expanded in a around 0 56.7%
associate-/l*56.7%
associate-/r/56.7%
Simplified56.7%
if -3.5e8 < b < 8.8000000000000004e-6Initial program 97.6%
+-commutative97.6%
Simplified97.6%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
*-commutative99.8%
sub-neg99.8%
Simplified99.8%
log1p-expm1-u99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 97.6%
associate-/l*97.5%
associate-/r/97.7%
Simplified97.7%
Final simplification74.6%
(FPCore (r a b) :precision binary64 (if (<= b -350000000.0) (/ r (/ (cos b) (sin b))) (if (<= b 0.000136) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -350000000.0) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 0.000136) {
tmp = r * (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 (b <= (-350000000.0d0)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 0.000136d0) then
tmp = r * (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 (b <= -350000000.0) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 0.000136) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -350000000.0: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 0.000136: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -350000000.0) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 0.000136) tmp = Float64(r * Float64(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 (b <= -350000000.0) tmp = r / (cos(b) / sin(b)); elseif (b <= 0.000136) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -350000000.0], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.000136], N[(r * N[(b / 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}\;b \leq -350000000:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 0.000136:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -3.5e8Initial program 58.2%
+-commutative58.2%
Simplified58.2%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.2%
Applied egg-rr99.2%
Taylor expanded in r around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
*-commutative99.3%
sub-neg99.3%
Simplified99.3%
log1p-expm1-u99.3%
Applied egg-rr99.3%
Taylor expanded in a around 0 57.7%
*-commutative57.7%
associate-/l*57.6%
Simplified57.6%
if -3.5e8 < b < 1.36e-4Initial program 97.6%
+-commutative97.6%
Simplified97.6%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
*-commutative99.8%
sub-neg99.8%
Simplified99.8%
log1p-expm1-u99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 97.6%
associate-/l*97.5%
associate-/r/97.7%
Simplified97.7%
if 1.36e-4 < b Initial program 55.6%
*-commutative55.6%
associate-/l*55.6%
+-commutative55.6%
Simplified55.6%
Taylor expanded in a around 0 55.7%
associate-/l*55.7%
associate-/r/55.8%
Simplified55.8%
Final simplification74.6%
(FPCore (r a b) :precision binary64 (if (<= b -350000000.0) (/ (* (sin b) r) (cos b)) (if (<= b 2e-5) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -350000000.0) {
tmp = (sin(b) * r) / cos(b);
} else if (b <= 2e-5) {
tmp = r * (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 (b <= (-350000000.0d0)) then
tmp = (sin(b) * r) / cos(b)
else if (b <= 2d-5) then
tmp = r * (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 (b <= -350000000.0) {
tmp = (Math.sin(b) * r) / Math.cos(b);
} else if (b <= 2e-5) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -350000000.0: tmp = (math.sin(b) * r) / math.cos(b) elif b <= 2e-5: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -350000000.0) tmp = Float64(Float64(sin(b) * r) / cos(b)); elseif (b <= 2e-5) tmp = Float64(r * Float64(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 (b <= -350000000.0) tmp = (sin(b) * r) / cos(b); elseif (b <= 2e-5) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -350000000.0], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-5], N[(r * N[(b / 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}\;b \leq -350000000:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -3.5e8Initial program 58.2%
*-commutative58.2%
associate-/l*58.2%
+-commutative58.2%
Simplified58.2%
Taylor expanded in a around 0 57.7%
if -3.5e8 < b < 2.00000000000000016e-5Initial program 97.6%
+-commutative97.6%
Simplified97.6%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
*-commutative99.8%
sub-neg99.8%
Simplified99.8%
log1p-expm1-u99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 97.6%
associate-/l*97.5%
associate-/r/97.7%
Simplified97.7%
if 2.00000000000000016e-5 < b Initial program 55.6%
*-commutative55.6%
associate-/l*55.6%
+-commutative55.6%
Simplified55.6%
Taylor expanded in a around 0 55.7%
associate-/l*55.7%
associate-/r/55.8%
Simplified55.8%
Final simplification74.6%
(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 74.7%
*-commutative74.7%
associate-/l*74.6%
+-commutative74.6%
Simplified74.6%
clear-num73.6%
associate-/r/74.6%
clear-num74.7%
Applied egg-rr74.7%
Final simplification74.7%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (sin(b) / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((b + a)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 74.7%
*-commutative74.7%
associate-/l*74.6%
+-commutative74.6%
Simplified74.6%
associate-/r/74.7%
Applied egg-rr74.7%
Final simplification74.7%
(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(Float64(sin(b) * 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[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos \left(b - a\right)}
\end{array}
Initial program 74.7%
+-commutative74.7%
Simplified74.7%
log1p-expm1-u74.6%
Applied egg-rr74.6%
log1p-expm1-u74.7%
cos-sum99.4%
*-commutative99.4%
cancel-sign-sub-inv99.4%
add-sqr-sqrt52.4%
sqrt-unprod87.7%
sqr-neg87.7%
sqrt-unprod35.3%
add-sqr-sqrt75.0%
*-commutative75.0%
cos-diff74.9%
Applied egg-rr74.9%
Final simplification74.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -580000000.0) (not (<= b 1.56))) (* r (- (sin b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -580000000.0) || !(b <= 1.56)) {
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 <= (-580000000.0d0)) .or. (.not. (b <= 1.56d0))) 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 <= -580000000.0) || !(b <= 1.56)) {
tmp = r * -Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -580000000.0) or not (b <= 1.56): tmp = r * -math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -580000000.0) || !(b <= 1.56)) tmp = Float64(r * Float64(-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 <= -580000000.0) || ~((b <= 1.56))) tmp = r * -sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -580000000.0], N[Not[LessEqual[b, 1.56]], $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 -580000000 \lor \neg \left(b \leq 1.56\right):\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -5.8e8 or 1.5600000000000001 < b Initial program 56.9%
*-commutative56.9%
associate-/l*56.9%
+-commutative56.9%
Simplified56.9%
frac-2neg56.9%
div-inv56.8%
distribute-neg-frac56.8%
Applied egg-rr56.8%
expm1-log1p-u42.0%
expm1-udef11.4%
add-sqr-sqrt7.4%
sqrt-unprod8.8%
sqr-neg8.8%
sqrt-unprod1.4%
add-sqr-sqrt3.6%
Applied egg-rr3.6%
Taylor expanded in a around 0 6.6%
Taylor expanded in b around 0 12.9%
if -5.8e8 < b < 1.5600000000000001Initial program 97.6%
+-commutative97.6%
Simplified97.6%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 99.8%
+-commutative99.8%
mul-1-neg99.8%
*-commutative99.8%
sub-neg99.8%
Simplified99.8%
log1p-expm1-u99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 97.6%
associate-/l*97.5%
associate-/r/97.7%
Simplified97.7%
Final simplification50.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.9e-11) (not (<= b 2200.0))) (* r (- (sin b))) (* b r)))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-11) || !(b <= 2200.0)) {
tmp = r * -sin(b);
} else {
tmp = b * 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 <= (-2.9d-11)) .or. (.not. (b <= 2200.0d0))) then
tmp = r * -sin(b)
else
tmp = b * r
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2.9e-11) || !(b <= 2200.0)) {
tmp = r * -Math.sin(b);
} else {
tmp = b * r;
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.9e-11) or not (b <= 2200.0): tmp = r * -math.sin(b) else: tmp = b * r return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.9e-11) || !(b <= 2200.0)) tmp = Float64(r * Float64(-sin(b))); else tmp = Float64(b * r); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.9e-11) || ~((b <= 2200.0))) tmp = r * -sin(b); else tmp = b * r; end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.9e-11], N[Not[LessEqual[b, 2200.0]], $MachinePrecision]], N[(r * (-N[Sin[b], $MachinePrecision])), $MachinePrecision], N[(b * r), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-11} \lor \neg \left(b \leq 2200\right):\\
\;\;\;\;r \cdot \left(-\sin b\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot r\\
\end{array}
\end{array}
if b < -2.9e-11 or 2200 < b Initial program 56.7%
*-commutative56.7%
associate-/l*56.7%
+-commutative56.7%
Simplified56.7%
frac-2neg56.7%
div-inv56.6%
distribute-neg-frac56.6%
Applied egg-rr56.6%
expm1-log1p-u42.0%
expm1-udef11.8%
add-sqr-sqrt7.7%
sqrt-unprod9.2%
sqr-neg9.2%
sqrt-unprod1.5%
add-sqr-sqrt3.5%
Applied egg-rr3.5%
Taylor expanded in a around 0 6.8%
Taylor expanded in b around 0 13.0%
if -2.9e-11 < b < 2200Initial program 98.6%
*-commutative98.6%
associate-/l*98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in b around 0 98.6%
*-commutative98.6%
associate-/l*98.4%
associate-/r/98.6%
Simplified98.6%
Taylor expanded in a around 0 69.1%
Final simplification37.1%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b * r
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 74.7%
*-commutative74.7%
associate-/l*74.6%
+-commutative74.6%
Simplified74.6%
Taylor expanded in b around 0 44.8%
*-commutative44.8%
associate-/l*44.8%
associate-/r/44.8%
Simplified44.8%
Taylor expanded in a around 0 32.2%
Final simplification32.2%
herbie shell --seed 2023264
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))