
(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 15 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 a)) (sin b)))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(b)) - ((sin(b) * sin(a)) / 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 / ((cos(a) / tan(b)) - ((sin(b) * sin(a)) / sin(b)))
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(a)) / Math.sin(b)));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - ((math.sin(b) * math.sin(a)) / math.sin(b)))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - Float64(Float64(sin(b) * sin(a)) / sin(b)))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - ((sin(b) * sin(a)) / sin(b))); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \frac{\sin b \cdot \sin a}{\sin b}}
\end{array}
Initial program 76.0%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.4%
div-sub99.5%
Applied egg-rr99.5%
expm1-log1p-u60.7%
expm1-udef60.5%
*-commutative60.5%
*-un-lft-identity60.5%
times-frac60.5%
clear-num60.5%
quot-tan60.6%
Applied egg-rr60.6%
expm1-def60.7%
expm1-log1p99.5%
/-rgt-identity99.5%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.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 76.0%
associate-/l*76.0%
remove-double-neg76.0%
sin-neg76.0%
neg-mul-176.0%
associate-/r*76.0%
associate-/l*76.0%
*-commutative76.0%
associate-*l/76.1%
associate-/l*76.1%
sin-neg76.1%
distribute-lft-neg-in76.1%
distribute-rgt-neg-in76.1%
associate-/l*76.1%
metadata-eval76.1%
/-rgt-identity76.1%
+-commutative76.1%
Simplified76.1%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (* (cos b) (/ (cos a) (sin b))) (sin a))))
double code(double r, double a, double b) {
return r / ((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 / ((cos(b) * (cos(a) / sin(b))) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(b) * (Math.cos(a) / Math.sin(b))) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(b) * (math.cos(a) / math.sin(b))) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(b) * Float64(cos(a) / sin(b))) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(b) * (cos(a) / sin(b))) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[b], $MachinePrecision] * N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos b \cdot \frac{\cos a}{\sin b} - \sin a}
\end{array}
Initial program 76.0%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.4%
div-sub99.5%
Applied egg-rr99.5%
Taylor expanded in r around 0 99.5%
*-commutative99.5%
associate-*r/99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ r (- (/ (* (cos a) (cos b)) (sin b)) (sin a))))
double code(double r, double a, double b) {
return r / (((cos(a) * cos(b)) / sin(b)) - sin(a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r / (((cos(a) * cos(b)) / sin(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(a) * Math.cos(b)) / Math.sin(b)) - Math.sin(a));
}
def code(r, a, b): return r / (((math.cos(a) * math.cos(b)) / math.sin(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(a) * cos(b)) / sin(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / (((cos(a) * cos(b)) / sin(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a \cdot \cos b}{\sin b} - \sin a}
\end{array}
Initial program 76.0%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.4%
div-sub99.5%
Applied egg-rr99.5%
Taylor expanded in b around 0 99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0105) (not (<= a 1.5e-21))) (* (sin b) (/ r (cos a))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0105) || !(a <= 1.5e-21)) {
tmp = sin(b) * (r / cos(a));
} else {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-0.0105d0)) .or. (.not. (a <= 1.5d-21))) then
tmp = sin(b) * (r / cos(a))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0105) || !(a <= 1.5e-21)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0105) or not (a <= 1.5e-21): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0105) || !(a <= 1.5e-21)) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.0105) || ~((a <= 1.5e-21))) tmp = sin(b) * (r / cos(a)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0105], N[Not[LessEqual[a, 1.5e-21]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0105 \lor \neg \left(a \leq 1.5 \cdot 10^{-21}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.0105000000000000007 or 1.49999999999999996e-21 < a Initial program 55.6%
associate-/l*55.7%
+-commutative55.7%
Simplified55.7%
associate-/r/55.7%
Applied egg-rr55.7%
Taylor expanded in b around 0 55.5%
if -0.0105000000000000007 < a < 1.49999999999999996e-21Initial program 99.1%
associate-/l*99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.3%
clear-num99.4%
quot-tan99.4%
Applied egg-rr99.4%
Final simplification76.1%
(FPCore (r a b)
:precision binary64
(if (<= a -0.09)
(* (sin b) (/ r (cos a)))
(if (<= a 1.5e-21)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.09) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 1.5e-21) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} else {
tmp = r * (sin(b) / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.09d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 1.5d-21) then
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.09) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 1.5e-21) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.09: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 1.5e-21: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.09) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 1.5e-21) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.09) tmp = sin(b) * (r / cos(a)); elseif (a <= 1.5e-21) tmp = r * (1.0 / ((1.0 / tan(b)) - a)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.09], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.5e-21], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.09:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 1.5 \cdot 10^{-21}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -0.089999999999999997Initial program 53.2%
associate-/l*53.4%
+-commutative53.4%
Simplified53.4%
associate-/r/53.4%
Applied egg-rr53.4%
Taylor expanded in b around 0 53.8%
if -0.089999999999999997 < a < 1.49999999999999996e-21Initial program 99.1%
associate-/l*99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.3%
clear-num99.4%
quot-tan99.4%
Applied egg-rr99.4%
if 1.49999999999999996e-21 < a Initial program 57.6%
associate-/l*57.6%
remove-double-neg57.6%
sin-neg57.6%
neg-mul-157.6%
associate-/r*57.6%
associate-/l*57.6%
*-commutative57.6%
associate-*l/57.6%
associate-/l*57.6%
sin-neg57.6%
distribute-lft-neg-in57.6%
distribute-rgt-neg-in57.6%
associate-/l*57.6%
metadata-eval57.6%
/-rgt-identity57.6%
+-commutative57.6%
Simplified57.6%
Taylor expanded in b around 0 56.9%
Final simplification76.1%
(FPCore (r a b)
:precision binary64
(if (<= a -0.03)
(* (sin b) (/ r (cos a)))
(if (<= a 8.6e-19)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.03) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 8.6e-19) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} else {
tmp = r / (cos(a) / 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 (a <= (-0.03d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 8.6d-19) then
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.03) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 8.6e-19) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.03: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 8.6e-19: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.03) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 8.6e-19) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.03) tmp = sin(b) * (r / cos(a)); elseif (a <= 8.6e-19) tmp = r * (1.0 / ((1.0 / tan(b)) - a)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.03], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 8.6e-19], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.03:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 8.6 \cdot 10^{-19}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -0.029999999999999999Initial program 53.2%
associate-/l*53.4%
+-commutative53.4%
Simplified53.4%
associate-/r/53.4%
Applied egg-rr53.4%
Taylor expanded in b around 0 53.8%
if -0.029999999999999999 < a < 8.6e-19Initial program 99.1%
associate-/l*99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.4%
clear-num99.4%
quot-tan99.4%
Applied egg-rr99.4%
if 8.6e-19 < a Initial program 56.4%
associate-/l*56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in b around 0 55.8%
Final simplification76.1%
(FPCore (r a b)
:precision binary64
(if (<= a -0.015)
(* (sin b) (/ r (cos a)))
(if (<= a 1.5e-21)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(/ (* r (sin b)) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.015) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 1.5e-21) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} else {
tmp = (r * sin(b)) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.015d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 1.5d-21) then
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
else
tmp = (r * sin(b)) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.015) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 1.5e-21) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = (r * Math.sin(b)) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.015: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 1.5e-21: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = (r * math.sin(b)) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.015) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 1.5e-21) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); else tmp = Float64(Float64(r * sin(b)) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.015) tmp = sin(b) * (r / cos(a)); elseif (a <= 1.5e-21) tmp = r * (1.0 / ((1.0 / tan(b)) - a)); else tmp = (r * sin(b)) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.015], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.5e-21], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.015:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 1.5 \cdot 10^{-21}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\end{array}
\end{array}
if a < -0.014999999999999999Initial program 53.2%
associate-/l*53.4%
+-commutative53.4%
Simplified53.4%
associate-/r/53.4%
Applied egg-rr53.4%
Taylor expanded in b around 0 53.8%
if -0.014999999999999999 < a < 1.49999999999999996e-21Initial program 99.1%
associate-/l*99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in a around 0 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
div-inv99.3%
clear-num99.4%
quot-tan99.4%
Applied egg-rr99.4%
if 1.49999999999999996e-21 < a Initial program 57.6%
+-commutative57.6%
Simplified57.6%
Taylor expanded in b around 0 57.0%
Final simplification76.1%
(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 76.0%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
associate-/r/76.0%
Applied egg-rr76.0%
Final simplification76.0%
(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 76.0%
associate-/l*76.0%
remove-double-neg76.0%
sin-neg76.0%
neg-mul-176.0%
associate-/r*76.0%
associate-/l*76.0%
*-commutative76.0%
associate-*l/76.1%
associate-/l*76.1%
sin-neg76.1%
distribute-lft-neg-in76.1%
distribute-rgt-neg-in76.1%
associate-/l*76.1%
metadata-eval76.1%
/-rgt-identity76.1%
+-commutative76.1%
Simplified76.1%
Final simplification76.1%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (- (/ 1.0 (tan b)) a)))
(if (<= b -8.8e-5)
(/ r t_0)
(if (<= b 5.8e-6) (* r (/ b (cos a))) (* r (/ 1.0 t_0))))))
double code(double r, double a, double b) {
double t_0 = (1.0 / tan(b)) - a;
double tmp;
if (b <= -8.8e-5) {
tmp = r / t_0;
} else if (b <= 5.8e-6) {
tmp = r * (b / cos(a));
} else {
tmp = r * (1.0 / 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 <= (-8.8d-5)) then
tmp = r / t_0
else if (b <= 5.8d-6) then
tmp = r * (b / cos(a))
else
tmp = r * (1.0d0 / 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 <= -8.8e-5) {
tmp = r / t_0;
} else if (b <= 5.8e-6) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (1.0 / t_0);
}
return tmp;
}
def code(r, a, b): t_0 = (1.0 / math.tan(b)) - a tmp = 0 if b <= -8.8e-5: tmp = r / t_0 elif b <= 5.8e-6: tmp = r * (b / math.cos(a)) else: tmp = r * (1.0 / t_0) return tmp
function code(r, a, b) t_0 = Float64(Float64(1.0 / tan(b)) - a) tmp = 0.0 if (b <= -8.8e-5) tmp = Float64(r / t_0); elseif (b <= 5.8e-6) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r * Float64(1.0 / 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 <= -8.8e-5) tmp = r / t_0; elseif (b <= 5.8e-6) tmp = r * (b / cos(a)); else tmp = r * (1.0 / 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, -8.8e-5], N[(r / t$95$0), $MachinePrecision], If[LessEqual[b, 5.8e-6], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\tan b} - a\\
\mathbf{if}\;b \leq -8.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{r}{t_0}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{t_0}\\
\end{array}
\end{array}
if b < -8.7999999999999998e-5Initial program 56.3%
associate-/l*56.3%
+-commutative56.3%
Simplified56.3%
Taylor expanded in a around 0 52.7%
+-commutative52.7%
mul-1-neg52.7%
unsub-neg52.7%
Simplified52.7%
expm1-log1p-u43.2%
expm1-udef43.0%
clear-num43.0%
quot-tan43.1%
Applied egg-rr43.1%
expm1-def43.3%
expm1-log1p52.8%
Simplified52.8%
if -8.7999999999999998e-5 < b < 5.8000000000000004e-6Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.7%
associate-/l*98.7%
sin-neg98.7%
distribute-lft-neg-in98.7%
distribute-rgt-neg-in98.7%
associate-/l*98.7%
metadata-eval98.7%
/-rgt-identity98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in b around 0 98.7%
associate-/l*98.6%
associate-/r/98.7%
Simplified98.7%
if 5.8000000000000004e-6 < b Initial program 58.9%
associate-/l*58.8%
+-commutative58.8%
Simplified58.8%
Taylor expanded in a around 0 55.6%
+-commutative55.6%
mul-1-neg55.6%
unsub-neg55.6%
Simplified55.6%
div-inv55.7%
clear-num55.7%
quot-tan55.7%
Applied egg-rr55.7%
Final simplification74.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -8.8e-5) (not (<= b 5e-5))) (/ r (- (/ 1.0 (tan b)) a)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -8.8e-5) || !(b <= 5e-5)) {
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.8d-5)) .or. (.not. (b <= 5d-5))) 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.8e-5) || !(b <= 5e-5)) {
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.8e-5) or not (b <= 5e-5): 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.8e-5) || !(b <= 5e-5)) 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.8e-5) || ~((b <= 5e-5))) 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.8e-5], N[Not[LessEqual[b, 5e-5]], $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.8 \cdot 10^{-5} \lor \neg \left(b \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -8.7999999999999998e-5 or 5.00000000000000024e-5 < b Initial program 57.5%
associate-/l*57.6%
+-commutative57.6%
Simplified57.6%
Taylor expanded in a around 0 54.1%
+-commutative54.1%
mul-1-neg54.1%
unsub-neg54.1%
Simplified54.1%
expm1-log1p-u40.6%
expm1-udef40.5%
clear-num40.5%
quot-tan40.6%
Applied egg-rr40.6%
expm1-def40.7%
expm1-log1p54.2%
Simplified54.2%
if -8.7999999999999998e-5 < b < 5.00000000000000024e-5Initial program 98.7%
associate-/l*98.6%
remove-double-neg98.6%
sin-neg98.6%
neg-mul-198.6%
associate-/r*98.6%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.7%
associate-/l*98.7%
sin-neg98.7%
distribute-lft-neg-in98.7%
distribute-rgt-neg-in98.7%
associate-/l*98.7%
metadata-eval98.7%
/-rgt-identity98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in b around 0 98.7%
associate-/l*98.6%
associate-/r/98.7%
Simplified98.7%
Final simplification74.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.35e+27) (not (<= b 4.6))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.35e+27) || !(b <= 4.6)) {
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 <= (-1.35d+27)) .or. (.not. (b <= 4.6d0))) 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 <= -1.35e+27) || !(b <= 4.6)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.35e+27) or not (b <= 4.6): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.35e+27) || !(b <= 4.6)) 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 <= -1.35e+27) || ~((b <= 4.6))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.35e+27], N[Not[LessEqual[b, 4.6]], $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 -1.35 \cdot 10^{+27} \lor \neg \left(b \leq 4.6\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.3499999999999999e27 or 4.5999999999999996 < b Initial program 58.2%
associate-/l*58.2%
remove-double-neg58.2%
sin-neg58.2%
neg-mul-158.2%
associate-/r*58.2%
associate-/l*58.2%
*-commutative58.2%
associate-*l/58.2%
associate-/l*58.2%
sin-neg58.2%
distribute-lft-neg-in58.2%
distribute-rgt-neg-in58.2%
associate-/l*58.2%
metadata-eval58.2%
/-rgt-identity58.2%
+-commutative58.2%
Simplified58.2%
add-log-exp58.0%
Applied egg-rr58.0%
Taylor expanded in b around 0 11.9%
Taylor expanded in a around 0 12.0%
if -1.3499999999999999e27 < b < 4.5999999999999996Initial program 95.9%
associate-/l*95.9%
remove-double-neg95.9%
sin-neg95.9%
neg-mul-195.9%
associate-/r*95.9%
associate-/l*95.9%
*-commutative95.9%
associate-*l/96.0%
associate-/l*96.0%
sin-neg96.0%
distribute-lft-neg-in96.0%
distribute-rgt-neg-in96.0%
associate-/l*96.0%
metadata-eval96.0%
/-rgt-identity96.0%
+-commutative96.0%
Simplified96.0%
Taylor expanded in b around 0 94.4%
associate-/l*94.4%
associate-/r/94.5%
Simplified94.5%
Final simplification51.0%
(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 76.0%
associate-/l*76.0%
remove-double-neg76.0%
sin-neg76.0%
neg-mul-176.0%
associate-/r*76.0%
associate-/l*76.0%
*-commutative76.0%
associate-*l/76.1%
associate-/l*76.1%
sin-neg76.1%
distribute-lft-neg-in76.1%
distribute-rgt-neg-in76.1%
associate-/l*76.1%
metadata-eval76.1%
/-rgt-identity76.1%
+-commutative76.1%
Simplified76.1%
add-log-exp45.7%
Applied egg-rr45.7%
Taylor expanded in b around 0 20.8%
Taylor expanded in a around 0 35.7%
Final simplification35.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 76.0%
associate-/l*76.0%
remove-double-neg76.0%
sin-neg76.0%
neg-mul-176.0%
associate-/r*76.0%
associate-/l*76.0%
*-commutative76.0%
associate-*l/76.1%
associate-/l*76.1%
sin-neg76.1%
distribute-lft-neg-in76.1%
distribute-rgt-neg-in76.1%
associate-/l*76.1%
metadata-eval76.1%
/-rgt-identity76.1%
+-commutative76.1%
Simplified76.1%
Taylor expanded in b around 0 46.4%
associate-/l*46.4%
associate-/r/46.4%
Simplified46.4%
Taylor expanded in a around 0 31.1%
Final simplification31.1%
herbie shell --seed 2024014
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))