
(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 16 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
(let* ((t_0 (* (sin b) (sin a))))
(/
(* r (sin b))
(+
(- (* (cos a) (cos b)) t_0)
(fma (- (sin b)) (sin a) (expm1 (log1p t_0)))))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (r * sin(b)) / (((cos(a) * cos(b)) - t_0) + fma(-sin(b), sin(a), expm1(log1p(t_0))));
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(r * sin(b)) / Float64(Float64(Float64(cos(a) * cos(b)) - t_0) + fma(Float64(-sin(b)), sin(a), expm1(log1p(t_0))))) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{r \cdot \sin b}{\left(\cos a \cdot \cos b - t_0\right) + \mathsf{fma}\left(-\sin b, \sin a, \mathsf{expm1}\left(\mathsf{log1p}\left(t_0\right)\right)\right)}
\end{array}
\end{array}
Initial program 77.3%
associate-*r/77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
*-un-lft-identity99.4%
prod-diff99.4%
Applied egg-rr99.4%
fma-udef99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub-inv99.4%
*-commutative99.4%
*-rgt-identity99.4%
*-commutative99.4%
fma-udef99.4%
*-rgt-identity99.4%
distribute-lft-neg-in99.4%
*-rgt-identity99.4%
fma-udef99.4%
*-commutative99.4%
Simplified99.4%
*-commutative99.4%
expm1-log1p-u99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* (sin b) (sin a))))
(/
(* r (sin b))
(+ (- (* (cos a) (cos b)) t_0) (fma (- (sin b)) (sin a) t_0)))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (r * sin(b)) / (((cos(a) * cos(b)) - t_0) + fma(-sin(b), sin(a), t_0));
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(r * sin(b)) / Float64(Float64(Float64(cos(a) * cos(b)) - t_0) + fma(Float64(-sin(b)), sin(a), t_0))) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{r \cdot \sin b}{\left(\cos a \cdot \cos b - t_0\right) + \mathsf{fma}\left(-\sin b, \sin a, t_0\right)}
\end{array}
\end{array}
Initial program 77.3%
associate-*r/77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
*-un-lft-identity99.4%
prod-diff99.4%
Applied egg-rr99.4%
fma-udef99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub-inv99.4%
*-commutative99.4%
*-rgt-identity99.4%
*-commutative99.4%
fma-udef99.4%
*-rgt-identity99.4%
distribute-lft-neg-in99.4%
*-rgt-identity99.4%
fma-udef99.4%
*-commutative99.4%
Simplified99.4%
Final simplification99.4%
(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 77.3%
remove-double-neg77.3%
remove-double-neg77.3%
+-commutative77.3%
Simplified77.3%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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 77.3%
associate-*r/77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -6.5e-6) (not (<= b 4e-6))) (* r (/ (sin b) (cos b))) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -6.5e-6) || !(b <= 4e-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 <= (-6.5d-6)) .or. (.not. (b <= 4d-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 <= -6.5e-6) || !(b <= 4e-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 <= -6.5e-6) or not (b <= 4e-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 <= -6.5e-6) || !(b <= 4e-6)) tmp = Float64(r * Float64(sin(b) / cos(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 <= -6.5e-6) || ~((b <= 4e-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, -6.5e-6], N[Not[LessEqual[b, 4e-6]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-6} \lor \neg \left(b \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -6.4999999999999996e-6 or 3.99999999999999982e-6 < b Initial program 56.2%
remove-double-neg56.2%
remove-double-neg56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in a around 0 55.1%
if -6.4999999999999996e-6 < b < 3.99999999999999982e-6Initial program 98.5%
remove-double-neg98.5%
remove-double-neg98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.6%
Final simplification76.8%
(FPCore (r a b) :precision binary64 (if (<= b -2.5e-6) (* r (/ (sin b) (cos b))) (if (<= b 3.8e-6) (/ (* r b) (cos a)) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.5e-6) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 3.8e-6) {
tmp = (r * 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 (b <= (-2.5d-6)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 3.8d-6) then
tmp = (r * 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 (b <= -2.5e-6) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 3.8e-6) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.5e-6: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 3.8e-6: tmp = (r * b) / math.cos(a) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.5e-6) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 3.8e-6) tmp = Float64(Float64(r * 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 (b <= -2.5e-6) tmp = r * (sin(b) / cos(b)); elseif (b <= 3.8e-6) tmp = (r * b) / cos(a); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.5e-6], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e-6], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -2.5000000000000002e-6Initial program 54.9%
remove-double-neg54.9%
remove-double-neg54.9%
+-commutative54.9%
Simplified54.9%
Taylor expanded in a around 0 52.3%
if -2.5000000000000002e-6 < b < 3.8e-6Initial program 98.5%
remove-double-neg98.5%
remove-double-neg98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in b around 0 98.6%
if 3.8e-6 < b Initial program 57.1%
remove-double-neg57.1%
remove-double-neg57.1%
+-commutative57.1%
Simplified57.1%
Taylor expanded in a around 0 57.3%
associate-/l*57.2%
associate-/r/57.3%
Simplified57.3%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (if (<= a -0.000152) (* r (/ (sin b) (cos a))) (if (<= a 0.00052) (* r (/ (sin b) (cos b))) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000152) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 0.00052) {
tmp = r * (sin(b) / cos(b));
} 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.000152d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 0.00052d0) then
tmp = r * (sin(b) / cos(b))
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.000152) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 0.00052) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000152: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 0.00052: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000152) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 0.00052) tmp = Float64(r * Float64(sin(b) / cos(b))); 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.000152) tmp = r * (sin(b) / cos(a)); elseif (a <= 0.00052) tmp = r * (sin(b) / cos(b)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000152], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.00052], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $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.000152:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 0.00052:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -1.5200000000000001e-4Initial program 47.6%
remove-double-neg47.6%
remove-double-neg47.6%
+-commutative47.6%
Simplified47.6%
Taylor expanded in b around 0 46.4%
if -1.5200000000000001e-4 < a < 5.19999999999999954e-4Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
if 5.19999999999999954e-4 < a Initial program 62.3%
remove-double-neg62.3%
remove-double-neg62.3%
+-commutative62.3%
Simplified62.3%
associate-*r/62.5%
associate-/l*62.6%
Applied egg-rr62.6%
Taylor expanded in b around 0 61.7%
Final simplification76.9%
(FPCore (r a b) :precision binary64 (if (<= a -8.8e-6) (/ (* r (sin b)) (cos a)) (if (<= a 2.65e-5) (* r (/ (sin b) (cos b))) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -8.8e-6) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 2.65e-5) {
tmp = r * (sin(b) / cos(b));
} 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 <= (-8.8d-6)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 2.65d-5) then
tmp = r * (sin(b) / cos(b))
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 <= -8.8e-6) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 2.65e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -8.8e-6: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 2.65e-5: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -8.8e-6) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 2.65e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); 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 <= -8.8e-6) tmp = (r * sin(b)) / cos(a); elseif (a <= 2.65e-5) tmp = r * (sin(b) / cos(b)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -8.8e-6], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.65e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $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 -8.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 2.65 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -8.8000000000000004e-6Initial program 47.6%
associate-*r/47.7%
+-commutative47.7%
Simplified47.7%
Taylor expanded in b around 0 46.5%
if -8.8000000000000004e-6 < a < 2.65e-5Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
if 2.65e-5 < a Initial program 62.3%
remove-double-neg62.3%
remove-double-neg62.3%
+-commutative62.3%
Simplified62.3%
associate-*r/62.5%
associate-/l*62.6%
Applied egg-rr62.6%
Taylor expanded in b around 0 61.7%
Final simplification76.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 77.3%
Final simplification77.3%
(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 77.3%
associate-*r/77.4%
+-commutative77.4%
Simplified77.4%
Final simplification77.4%
(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 77.3%
remove-double-neg77.3%
remove-double-neg77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 55.7%
Final simplification55.7%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (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 * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 77.3%
remove-double-neg77.3%
remove-double-neg77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.0%
Final simplification52.0%
(FPCore (r a b) :precision binary64 (/ r (/ (cos a) b)))
double code(double r, double a, double b) {
return 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 = r / (cos(a) / b)
end function
public static double code(double r, double a, double b) {
return r / (Math.cos(a) / b);
}
def code(r, a, b): return r / (math.cos(a) / b)
function code(r, a, b) return Float64(r / Float64(cos(a) / b)) end
function tmp = code(r, a, b) tmp = r / (cos(a) / b); end
code[r_, a_, b_] := N[(r / N[(N[Cos[a], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{b}}
\end{array}
Initial program 77.3%
remove-double-neg77.3%
remove-double-neg77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.0%
clear-num52.0%
un-div-inv52.0%
Applied egg-rr52.0%
Final simplification52.0%
(FPCore (r a b) :precision binary64 (/ (* r b) (cos a)))
double code(double r, double a, double b) {
return (r * 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 * b) / cos(a)
end function
public static double code(double r, double a, double b) {
return (r * b) / Math.cos(a);
}
def code(r, a, b): return (r * b) / math.cos(a)
function code(r, a, b) return Float64(Float64(r * b) / cos(a)) end
function tmp = code(r, a, b) tmp = (r * b) / cos(a); end
code[r_, a_, b_] := N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot b}{\cos a}
\end{array}
Initial program 77.3%
remove-double-neg77.3%
remove-double-neg77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.1%
Final simplification52.1%
(FPCore (r a b) :precision binary64 (/ r (+ (* b -0.3333333333333333) (/ 1.0 b))))
double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / 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 * (-0.3333333333333333d0)) + (1.0d0 / b))
end function
public static double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / b));
}
def code(r, a, b): return r / ((b * -0.3333333333333333) + (1.0 / b))
function code(r, a, b) return Float64(r / Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b))) end
function tmp = code(r, a, b) tmp = r / ((b * -0.3333333333333333) + (1.0 / b)); end
code[r_, a_, b_] := N[(r / N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Initial program 77.3%
remove-double-neg77.3%
remove-double-neg77.3%
+-commutative77.3%
Simplified77.3%
associate-*r/77.4%
associate-/l*77.3%
Applied egg-rr77.3%
Taylor expanded in b around 0 53.6%
Taylor expanded in a around 0 36.0%
Final simplification36.0%
(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 77.3%
remove-double-neg77.3%
remove-double-neg77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in b around 0 52.0%
Taylor expanded in a around 0 35.4%
Final simplification35.4%
herbie shell --seed 2024011
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))