
(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 20 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 (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 75.0%
+-commutative75.0%
Simplified75.0%
cos-sum99.5%
fma-neg99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (/ r (/ (- (* (cos b) (cos a)) (* (sin b) (sin a))) (sin b))))
double code(double r, double a, double b) {
return r / (((cos(b) * cos(a)) - (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(b) * cos(a)) - (sin(b) * sin(a))) / sin(b))
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))) / Math.sin(b));
}
def code(r, a, b): return r / (((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos b \cdot \cos a - \sin b \cdot \sin a}{\sin b}}
\end{array}
Initial program 75.0%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 75.0%
+-commutative75.0%
Simplified75.0%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) 0.0)))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), 0.0);
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), 0.0)) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 75.0%
+-commutative75.0%
Simplified75.0%
cos-sum99.5%
fma-neg99.6%
Applied egg-rr99.6%
sin-mult76.0%
cos-sum77.5%
fma-neg77.5%
div-sub77.5%
cos-diff99.6%
add-sqr-sqrt56.0%
sqrt-unprod88.6%
sqr-neg88.6%
sqrt-unprod42.0%
add-sqr-sqrt76.0%
sub-neg76.0%
cos-sum76.9%
Applied egg-rr76.0%
+-inverses76.0%
Simplified76.0%
Final simplification76.0%
(FPCore (r a b) :precision binary64 (* r (/ (/ (sin b) (cos b)) (cos a))))
double code(double r, double a, double b) {
return r * ((sin(b) / cos(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(b)) / cos(a))
end function
public static double code(double r, double a, double b) {
return r * ((Math.sin(b) / Math.cos(b)) / Math.cos(a));
}
def code(r, a, b): return r * ((math.sin(b) / math.cos(b)) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(Float64(sin(b) / cos(b)) / cos(a))) end
function tmp = code(r, a, b) tmp = r * ((sin(b) / cos(b)) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\frac{\sin b}{\cos b}}{\cos a}
\end{array}
Initial program 75.0%
+-commutative75.0%
Simplified75.0%
cos-sum99.5%
fma-neg99.6%
Applied egg-rr99.6%
sin-mult76.0%
cos-sum77.5%
fma-neg77.5%
div-sub77.5%
cos-diff99.6%
add-sqr-sqrt56.0%
sqrt-unprod88.6%
sqr-neg88.6%
sqrt-unprod42.0%
add-sqr-sqrt76.0%
sub-neg76.0%
cos-sum76.9%
Applied egg-rr76.0%
+-inverses76.0%
Simplified76.0%
Taylor expanded in r around 0 76.0%
*-commutative76.0%
associate-*r/76.0%
associate-/r*76.0%
Simplified76.0%
Final simplification76.0%
(FPCore (r a b) :precision binary64 (* (/ r (cos a)) (/ (sin b) (cos b))))
double code(double r, double a, double b) {
return (r / cos(a)) * (sin(b) / 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 = (r / cos(a)) * (sin(b) / cos(b))
end function
public static double code(double r, double a, double b) {
return (r / Math.cos(a)) * (Math.sin(b) / Math.cos(b));
}
def code(r, a, b): return (r / math.cos(a)) * (math.sin(b) / math.cos(b))
function code(r, a, b) return Float64(Float64(r / cos(a)) * Float64(sin(b) / cos(b))) end
function tmp = code(r, a, b) tmp = (r / cos(a)) * (sin(b) / cos(b)); end
code[r_, a_, b_] := N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos a} \cdot \frac{\sin b}{\cos b}
\end{array}
Initial program 75.0%
+-commutative75.0%
Simplified75.0%
cos-sum99.5%
fma-neg99.6%
Applied egg-rr99.6%
sin-mult76.0%
cos-sum77.5%
fma-neg77.5%
div-sub77.5%
cos-diff99.6%
add-sqr-sqrt56.0%
sqrt-unprod88.6%
sqr-neg88.6%
sqrt-unprod42.0%
add-sqr-sqrt76.0%
sub-neg76.0%
cos-sum76.9%
Applied egg-rr76.0%
+-inverses76.0%
Simplified76.0%
Taylor expanded in r around 0 76.0%
times-frac76.0%
Simplified76.0%
Final simplification76.0%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.005) (not (<= a 0.15))) (* r (/ (sin b) (cos a))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.005) || !(a <= 0.15)) {
tmp = r * (sin(b) / 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.005d0)) .or. (.not. (a <= 0.15d0))) then
tmp = r * (sin(b) / 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.005) || !(a <= 0.15)) {
tmp = r * (Math.sin(b) / 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.005) or not (a <= 0.15): tmp = r * (math.sin(b) / 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.005) || !(a <= 0.15)) tmp = Float64(r * Float64(sin(b) / 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.005) || ~((a <= 0.15))) tmp = r * (sin(b) / 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.005], N[Not[LessEqual[a, 0.15]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / 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.005 \lor \neg \left(a \leq 0.15\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.0050000000000000001 or 0.149999999999999994 < a Initial program 55.0%
associate-/l*55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in b around 0 54.7%
Taylor expanded in r around 0 54.6%
associate-*r/54.6%
Simplified54.6%
if -0.0050000000000000001 < a < 0.149999999999999994Initial program 97.7%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in a around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
clear-num97.8%
associate-/r/98.4%
clear-num98.4%
quot-tan98.5%
Applied egg-rr98.5%
Final simplification75.2%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.0152) (not (<= a 0.17))) (/ r (/ (cos a) (sin b))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.0152) || !(a <= 0.17)) {
tmp = r / (cos(a) / sin(b));
} 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.0152d0)) .or. (.not. (a <= 0.17d0))) then
tmp = r / (cos(a) / sin(b))
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.0152) || !(a <= 0.17)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.0152) or not (a <= 0.17): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.0152) || !(a <= 0.17)) tmp = Float64(r / Float64(cos(a) / sin(b))); 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.0152) || ~((a <= 0.17))) tmp = r / (cos(a) / sin(b)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.0152], N[Not[LessEqual[a, 0.17]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $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.0152 \lor \neg \left(a \leq 0.17\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.0152 or 0.170000000000000012 < a Initial program 55.0%
associate-/l*55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in b around 0 54.7%
if -0.0152 < a < 0.170000000000000012Initial program 97.7%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in a around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
clear-num97.8%
associate-/r/98.4%
clear-num98.4%
quot-tan98.5%
Applied egg-rr98.5%
Final simplification75.2%
(FPCore (r a b)
:precision binary64
(if (<= a -0.00385)
(* (sin b) (/ r (cos a)))
(if (<= a 0.15)
(* 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.00385) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 0.15) {
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.00385d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 0.15d0) 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.00385) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 0.15) {
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.00385: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 0.15: 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.00385) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 0.15) 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.00385) tmp = sin(b) * (r / cos(a)); elseif (a <= 0.15) 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.00385], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.15], 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.00385:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 0.15:\\
\;\;\;\;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.0038500000000000001Initial program 51.6%
associate-/l*51.7%
+-commutative51.7%
Simplified51.7%
Taylor expanded in b around 0 50.6%
associate-/r/50.6%
Applied egg-rr50.6%
if -0.0038500000000000001 < a < 0.149999999999999994Initial program 97.7%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in a around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
clear-num97.8%
associate-/r/98.4%
clear-num98.4%
quot-tan98.5%
Applied egg-rr98.5%
if 0.149999999999999994 < a Initial program 57.9%
associate-/l*58.0%
+-commutative58.0%
Simplified58.0%
Taylor expanded in b around 0 58.3%
Taylor expanded in r around 0 58.2%
associate-*r/58.3%
Simplified58.3%
Final simplification75.2%
(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 75.0%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
associate-/r/75.0%
Applied egg-rr75.0%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (sin(b) / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos((b + a)));
}
def code(r, a, b): return r * (math.sin(b) / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 75.0%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
clear-num74.6%
associate-/r/74.9%
clear-num75.0%
Applied egg-rr75.0%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (cos (+ b a)) r)))
double code(double r, double a, double b) {
return sin(b) / (cos((b + 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((b + a)) / r)
end function
public static double code(double r, double a, double b) {
return Math.sin(b) / (Math.cos((b + a)) / r);
}
def code(r, a, b): return math.sin(b) / (math.cos((b + a)) / r)
function code(r, a, b) return Float64(sin(b) / Float64(cos(Float64(b + a)) / r)) end
function tmp = code(r, a, b) tmp = sin(b) / (cos((b + a)) / r); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\cos \left(b + a\right)}{r}}
\end{array}
Initial program 75.0%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
associate-/l*75.0%
add-log-exp16.7%
associate-/l*16.7%
div-inv16.7%
exp-prod15.4%
clear-num15.4%
Applied egg-rr15.4%
pow-exp16.7%
rem-log-exp75.0%
div-inv74.9%
associate-*r*75.0%
cos-sum99.4%
fma-neg99.5%
div-inv99.6%
*-commutative99.6%
associate-/l*99.5%
fma-neg99.5%
cos-sum75.0%
Applied egg-rr75.0%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ b a))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((b + a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((b + a))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((b + a));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((b + a))
function code(r, a, b) return Float64(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 75.0%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (- b a))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((b - a));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((b - a))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((b - a));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((b - a))
function code(r, a, b) return Float64(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 75.0%
+-commutative75.0%
Simplified75.0%
cos-sum99.5%
fma-neg99.6%
Applied egg-rr99.6%
fma-udef99.5%
add-sqr-sqrt52.9%
sqrt-unprod86.1%
sqr-neg86.1%
sqrt-unprod42.6%
add-sqr-sqrt74.8%
cos-diff75.0%
Applied egg-rr75.0%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.047) (not (<= a 0.15))) (/ r (/ (cos a) b)) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.047) || !(a <= 0.15)) {
tmp = r / (cos(a) / b);
} 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.047d0)) .or. (.not. (a <= 0.15d0))) then
tmp = r / (cos(a) / b)
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.047) || !(a <= 0.15)) {
tmp = r / (Math.cos(a) / b);
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.047) or not (a <= 0.15): tmp = r / (math.cos(a) / b) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.047) || !(a <= 0.15)) tmp = Float64(r / Float64(cos(a) / b)); 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.047) || ~((a <= 0.15))) tmp = r / (cos(a) / b); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.047], N[Not[LessEqual[a, 0.15]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / b), $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.047 \lor \neg \left(a \leq 0.15\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.047 or 0.149999999999999994 < a Initial program 55.0%
associate-/l*55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in b around 0 50.7%
if -0.047 < a < 0.149999999999999994Initial program 97.7%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in a around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
clear-num97.8%
associate-/r/98.4%
clear-num98.4%
quot-tan98.5%
Applied egg-rr98.5%
Final simplification73.1%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.046) (not (<= a 0.216))) (/ r (/ (cos a) b)) (/ r (- (/ 1.0 (tan b)) a))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.046) || !(a <= 0.216)) {
tmp = r / (cos(a) / b);
} else {
tmp = r / ((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.046d0)) .or. (.not. (a <= 0.216d0))) then
tmp = r / (cos(a) / b)
else
tmp = r / ((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.046) || !(a <= 0.216)) {
tmp = r / (Math.cos(a) / b);
} else {
tmp = r / ((1.0 / Math.tan(b)) - a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.046) or not (a <= 0.216): tmp = r / (math.cos(a) / b) else: tmp = r / ((1.0 / math.tan(b)) - a) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.046) || !(a <= 0.216)) tmp = Float64(r / Float64(cos(a) / b)); else tmp = Float64(r / Float64(Float64(1.0 / tan(b)) - a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.046) || ~((a <= 0.216))) tmp = r / (cos(a) / b); else tmp = r / ((1.0 / tan(b)) - a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.046], N[Not[LessEqual[a, 0.216]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.046 \lor \neg \left(a \leq 0.216\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.045999999999999999 or 0.215999999999999998 < a Initial program 55.0%
associate-/l*55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in b around 0 50.7%
if -0.045999999999999999 < a < 0.215999999999999998Initial program 97.7%
associate-/l*97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in a around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
expm1-log1p-u66.4%
expm1-udef66.0%
clear-num65.9%
quot-tan66.0%
Applied egg-rr66.0%
expm1-def66.4%
expm1-log1p98.3%
Simplified98.3%
Final simplification73.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -17.0) (not (<= b 215000000000.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -17.0) || !(b <= 215000000000.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 <= (-17.0d0)) .or. (.not. (b <= 215000000000.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 <= -17.0) || !(b <= 215000000000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -17.0) or not (b <= 215000000000.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 <= -17.0) || !(b <= 215000000000.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 <= -17.0) || ~((b <= 215000000000.0))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -17.0], N[Not[LessEqual[b, 215000000000.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 -17 \lor \neg \left(b \leq 215000000000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -17 or 2.15e11 < b Initial program 52.6%
associate-/l*52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in b around 0 11.6%
Taylor expanded in a around 0 11.1%
if -17 < b < 2.15e11Initial program 97.3%
associate-/l*97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in b around 0 95.1%
associate-/l*95.0%
associate-/r/95.0%
Simplified95.0%
Final simplification53.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -17.0) (not (<= b 215000000000.0))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -17.0) || !(b <= 215000000000.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 <= (-17.0d0)) .or. (.not. (b <= 215000000000.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 <= -17.0) || !(b <= 215000000000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -17.0) or not (b <= 215000000000.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 <= -17.0) || !(b <= 215000000000.0)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -17.0) || ~((b <= 215000000000.0))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -17.0], N[Not[LessEqual[b, 215000000000.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -17 \lor \neg \left(b \leq 215000000000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -17 or 2.15e11 < b Initial program 52.6%
associate-/l*52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in b around 0 11.6%
Taylor expanded in a around 0 11.1%
if -17 < b < 2.15e11Initial program 97.3%
associate-/l*97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in b around 0 95.1%
Final simplification53.1%
(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 75.0%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
Taylor expanded in b around 0 53.3%
Taylor expanded in a around 0 36.8%
Final simplification36.8%
(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 75.0%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
Taylor expanded in b around 0 49.3%
associate-/l*49.3%
associate-/r/49.3%
Simplified49.3%
Taylor expanded in a around 0 33.1%
*-commutative33.1%
Simplified33.1%
Final simplification33.1%
herbie shell --seed 2023307
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))