
(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 (sin b)) (fma (cos b) (cos a) (* (sin a) (- (sin b))))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (sin(a) * -sin(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(a) * Float64(-sin(b))))) 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[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)}
\end{array}
Initial program 74.9%
+-commutative74.9%
Simplified74.9%
cos-sum99.5%
fma-neg99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (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 = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 74.9%
associate-/l*74.8%
remove-double-neg74.8%
sin-neg74.8%
neg-mul-174.8%
associate-/r*74.8%
associate-/l*74.9%
*-commutative74.9%
associate-*l/74.9%
associate-/l*74.9%
sin-neg74.9%
distribute-lft-neg-in74.9%
distribute-rgt-neg-in74.9%
associate-/l*74.9%
metadata-eval74.9%
/-rgt-identity74.9%
+-commutative74.9%
Simplified74.9%
cos-sum99.4%
Applied egg-rr99.4%
Taylor expanded in b around inf 99.5%
*-commutative99.5%
*-commutative99.5%
*-commutative99.5%
*-rgt-identity99.5%
cancel-sign-sub-inv99.5%
distribute-lft-neg-in99.5%
fma-udef99.5%
*-lft-identity99.5%
times-frac99.4%
/-rgt-identity99.4%
fma-udef99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub-inv99.4%
Simplified99.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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 74.9%
associate-/l*74.8%
remove-double-neg74.8%
sin-neg74.8%
neg-mul-174.8%
associate-/r*74.8%
associate-/l*74.9%
*-commutative74.9%
associate-*l/74.9%
associate-/l*74.9%
sin-neg74.9%
distribute-lft-neg-in74.9%
distribute-rgt-neg-in74.9%
associate-/l*74.9%
metadata-eval74.9%
/-rgt-identity74.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 74.9%
+-commutative74.9%
Simplified74.9%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(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(sin(b) / Float64(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[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a}
\end{array}
Initial program 74.9%
associate-/l*74.8%
remove-double-neg74.8%
sin-neg74.8%
neg-mul-174.8%
associate-/r*74.8%
associate-/l*74.9%
*-commutative74.9%
associate-*l/74.9%
associate-/l*74.9%
sin-neg74.9%
distribute-lft-neg-in74.9%
distribute-rgt-neg-in74.9%
associate-/l*74.9%
metadata-eval74.9%
/-rgt-identity74.9%
+-commutative74.9%
Simplified74.9%
cos-sum99.4%
Applied egg-rr99.4%
sin-mult75.9%
cos-sum76.7%
fma-neg76.7%
div-sub76.7%
fma-udef76.7%
add-sqr-sqrt43.1%
sqrt-unprod76.0%
sqr-neg76.0%
sqrt-unprod45.4%
add-sqr-sqrt75.3%
cos-diff75.9%
Applied egg-rr75.9%
+-inverses75.9%
Simplified75.9%
Final simplification75.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.000112) (not (<= b 1.2e-12))) (* (sin b) (/ r (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.000112) || !(b <= 1.2e-12)) {
tmp = sin(b) * (r / 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 <= (-0.000112d0)) .or. (.not. (b <= 1.2d-12))) then
tmp = sin(b) * (r / 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 <= -0.000112) || !(b <= 1.2e-12)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.000112) or not (b <= 1.2e-12): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.000112) || !(b <= 1.2e-12)) tmp = Float64(sin(b) * Float64(r / 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 <= -0.000112) || ~((b <= 1.2e-12))) tmp = sin(b) * (r / cos(b)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.000112], N[Not[LessEqual[b, 1.2e-12]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / 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 -0.000112 \lor \neg \left(b \leq 1.2 \cdot 10^{-12}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.11999999999999998e-4 or 1.19999999999999994e-12 < b Initial program 50.0%
associate-/l*50.0%
remove-double-neg50.0%
sin-neg50.0%
neg-mul-150.0%
associate-/r*50.0%
associate-/l*50.0%
*-commutative50.0%
associate-*l/50.0%
associate-/l*50.0%
sin-neg50.0%
distribute-lft-neg-in50.0%
distribute-rgt-neg-in50.0%
associate-/l*50.0%
metadata-eval50.0%
/-rgt-identity50.0%
+-commutative50.0%
Simplified50.0%
Taylor expanded in a around 0 50.2%
associate-/l*50.2%
associate-/r/50.2%
Simplified50.2%
if -1.11999999999999998e-4 < b < 1.19999999999999994e-12Initial program 99.7%
associate-/l*99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/l*99.7%
*-commutative99.7%
associate-*l/99.8%
associate-/l*99.8%
sin-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
/-rgt-identity99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 99.8%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= b -2.5e-5) (* r (/ (sin b) (cos b))) (if (<= b 1.2e-12) (* r (/ b (cos a))) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.5e-5) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 1.2e-12) {
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-5)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 1.2d-12) 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-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 1.2e-12) {
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-5: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 1.2e-12: 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-5) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 1.2e-12) tmp = Float64(r * Float64(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-5) tmp = r * (sin(b) / cos(b)); elseif (b <= 1.2e-12) 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-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.2e-12], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-12}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -2.50000000000000012e-5Initial program 48.2%
associate-/l*48.1%
remove-double-neg48.1%
sin-neg48.1%
neg-mul-148.1%
associate-/r*48.1%
associate-/l*48.2%
*-commutative48.2%
associate-*l/48.2%
associate-/l*48.2%
sin-neg48.2%
distribute-lft-neg-in48.2%
distribute-rgt-neg-in48.2%
associate-/l*48.2%
metadata-eval48.2%
/-rgt-identity48.2%
+-commutative48.2%
Simplified48.2%
Taylor expanded in a around 0 48.5%
if -2.50000000000000012e-5 < b < 1.19999999999999994e-12Initial program 99.7%
associate-/l*99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/l*99.7%
*-commutative99.7%
associate-*l/99.8%
associate-/l*99.8%
sin-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
/-rgt-identity99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 99.8%
if 1.19999999999999994e-12 < b Initial program 51.3%
associate-/l*51.3%
remove-double-neg51.3%
sin-neg51.3%
neg-mul-151.3%
associate-/r*51.3%
associate-/l*51.3%
*-commutative51.3%
associate-*l/51.3%
associate-/l*51.3%
sin-neg51.3%
distribute-lft-neg-in51.3%
distribute-rgt-neg-in51.3%
associate-/l*51.3%
metadata-eval51.3%
/-rgt-identity51.3%
+-commutative51.3%
Simplified51.3%
Taylor expanded in a around 0 51.3%
associate-/l*51.3%
associate-/r/51.4%
Simplified51.4%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= b -4.5e-6) (/ (* r (sin b)) (cos b)) (if (<= b 1.2e-12) (* r (/ b (cos a))) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -4.5e-6) {
tmp = (r * sin(b)) / cos(b);
} else if (b <= 1.2e-12) {
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 <= (-4.5d-6)) then
tmp = (r * sin(b)) / cos(b)
else if (b <= 1.2d-12) 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 <= -4.5e-6) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else if (b <= 1.2e-12) {
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 <= -4.5e-6: tmp = (r * math.sin(b)) / math.cos(b) elif b <= 1.2e-12: 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 <= -4.5e-6) tmp = Float64(Float64(r * sin(b)) / cos(b)); elseif (b <= 1.2e-12) tmp = Float64(r * Float64(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 <= -4.5e-6) tmp = (r * sin(b)) / cos(b); elseif (b <= 1.2e-12) tmp = r * (b / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -4.5e-6], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.2e-12], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-12}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -4.50000000000000011e-6Initial program 48.2%
+-commutative48.2%
Simplified48.2%
Taylor expanded in a around 0 48.6%
if -4.50000000000000011e-6 < b < 1.19999999999999994e-12Initial program 99.7%
associate-/l*99.6%
remove-double-neg99.6%
sin-neg99.6%
neg-mul-199.6%
associate-/r*99.6%
associate-/l*99.7%
*-commutative99.7%
associate-*l/99.8%
associate-/l*99.8%
sin-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
/-rgt-identity99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in b around 0 99.8%
if 1.19999999999999994e-12 < b Initial program 51.3%
associate-/l*51.3%
remove-double-neg51.3%
sin-neg51.3%
neg-mul-151.3%
associate-/r*51.3%
associate-/l*51.3%
*-commutative51.3%
associate-*l/51.3%
associate-/l*51.3%
sin-neg51.3%
distribute-lft-neg-in51.3%
distribute-rgt-neg-in51.3%
associate-/l*51.3%
metadata-eval51.3%
/-rgt-identity51.3%
+-commutative51.3%
Simplified51.3%
Taylor expanded in a around 0 51.3%
associate-/l*51.3%
associate-/r/51.4%
Simplified51.4%
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 74.9%
associate-/l*74.8%
remove-double-neg74.8%
sin-neg74.8%
neg-mul-174.8%
associate-/r*74.8%
associate-/l*74.9%
*-commutative74.9%
associate-*l/74.9%
associate-/l*74.9%
sin-neg74.9%
distribute-lft-neg-in74.9%
distribute-rgt-neg-in74.9%
associate-/l*74.9%
metadata-eval74.9%
/-rgt-identity74.9%
+-commutative74.9%
Simplified74.9%
Final simplification74.9%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 74.9%
+-commutative74.9%
Simplified74.9%
Taylor expanded in b around 0 56.0%
associate-*l/56.0%
Applied egg-rr56.0%
Final simplification56.0%
(FPCore (r a b) :precision binary64 (if (<= b 380.0) (* r (/ b (cos (+ b a)))) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 380.0) {
tmp = r * (b / cos((b + a)));
} else {
tmp = -r / sin(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 <= 380.0d0) then
tmp = r * (b / cos((b + a)))
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 380.0) {
tmp = r * (b / Math.cos((b + a)));
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 380.0: tmp = r * (b / math.cos((b + a))) else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 380.0) tmp = Float64(r * Float64(b / cos(Float64(b + a)))); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 380.0) tmp = r * (b / cos((b + a))); else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 380.0], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 380:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 380Initial program 85.1%
associate-/l*85.0%
remove-double-neg85.0%
sin-neg85.0%
neg-mul-185.0%
associate-/r*85.0%
associate-/l*85.1%
*-commutative85.1%
associate-*l/85.1%
associate-/l*85.1%
sin-neg85.1%
distribute-lft-neg-in85.1%
distribute-rgt-neg-in85.1%
associate-/l*85.1%
metadata-eval85.1%
/-rgt-identity85.1%
+-commutative85.1%
Simplified85.1%
Taylor expanded in b around 0 72.0%
if 380 < b Initial program 49.3%
associate-/l*49.4%
+-commutative49.4%
Simplified49.4%
Taylor expanded in b around 0 10.3%
+-commutative10.3%
neg-mul-110.3%
unsub-neg10.3%
Simplified10.3%
Taylor expanded in b around inf 10.2%
associate-*r/10.2%
neg-mul-110.2%
Simplified10.2%
Final simplification54.4%
(FPCore (r a b) :precision binary64 (if (<= b 3.1) (* r (/ b (cos (+ b a)))) (/ r (- (/ 1.0 b) (sin a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= 3.1) {
tmp = r * (b / cos((b + a)));
} else {
tmp = r / ((1.0 / b) - sin(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 <= 3.1d0) then
tmp = r * (b / cos((b + a)))
else
tmp = r / ((1.0d0 / b) - sin(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 3.1) {
tmp = r * (b / Math.cos((b + a)));
} else {
tmp = r / ((1.0 / b) - Math.sin(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 3.1: tmp = r * (b / math.cos((b + a))) else: tmp = r / ((1.0 / b) - math.sin(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 3.1) tmp = Float64(r * Float64(b / cos(Float64(b + a)))); else tmp = Float64(r / Float64(Float64(1.0 / b) - sin(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 3.1) tmp = r * (b / cos((b + a))); else tmp = r / ((1.0 / b) - sin(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 3.1], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[(1.0 / b), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\
\end{array}
\end{array}
if b < 3.10000000000000009Initial program 85.0%
associate-/l*84.9%
remove-double-neg84.9%
sin-neg84.9%
neg-mul-184.9%
associate-/r*84.9%
associate-/l*85.0%
*-commutative85.0%
associate-*l/85.1%
associate-/l*85.1%
sin-neg85.1%
distribute-lft-neg-in85.1%
distribute-rgt-neg-in85.1%
associate-/l*85.1%
metadata-eval85.1%
/-rgt-identity85.1%
+-commutative85.1%
Simplified85.1%
Taylor expanded in b around 0 72.3%
if 3.10000000000000009 < b Initial program 50.0%
associate-/l*50.1%
+-commutative50.1%
Simplified50.1%
Taylor expanded in b around 0 10.4%
+-commutative10.4%
neg-mul-110.4%
unsub-neg10.4%
Simplified10.4%
Taylor expanded in a around 0 10.4%
Final simplification54.4%
(FPCore (r a b) :precision binary64 (if (<= b 375.0) (* r (/ b (cos a))) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 375.0) {
tmp = r * (b / cos(a));
} else {
tmp = -r / sin(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 <= 375.0d0) then
tmp = r * (b / cos(a))
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 375.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 375.0: tmp = r * (b / math.cos(a)) else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 375.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 375.0) tmp = r * (b / cos(a)); else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 375.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 375:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 375Initial program 85.1%
associate-/l*85.0%
remove-double-neg85.0%
sin-neg85.0%
neg-mul-185.0%
associate-/r*85.0%
associate-/l*85.1%
*-commutative85.1%
associate-*l/85.1%
associate-/l*85.1%
sin-neg85.1%
distribute-lft-neg-in85.1%
distribute-rgt-neg-in85.1%
associate-/l*85.1%
metadata-eval85.1%
/-rgt-identity85.1%
+-commutative85.1%
Simplified85.1%
Taylor expanded in b around 0 71.9%
if 375 < b Initial program 49.3%
associate-/l*49.4%
+-commutative49.4%
Simplified49.4%
Taylor expanded in b around 0 10.3%
+-commutative10.3%
neg-mul-110.3%
unsub-neg10.3%
Simplified10.3%
Taylor expanded in b around inf 10.2%
associate-*r/10.2%
neg-mul-110.2%
Simplified10.2%
Final simplification54.3%
(FPCore (r a b) :precision binary64 (if (<= b 440.0) (* r b) (/ (- r) (sin a))))
double code(double r, double a, double b) {
double tmp;
if (b <= 440.0) {
tmp = r * b;
} else {
tmp = -r / sin(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 <= 440.0d0) then
tmp = r * b
else
tmp = -r / sin(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= 440.0) {
tmp = r * b;
} else {
tmp = -r / Math.sin(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= 440.0: tmp = r * b else: tmp = -r / math.sin(a) return tmp
function code(r, a, b) tmp = 0.0 if (b <= 440.0) tmp = Float64(r * b); else tmp = Float64(Float64(-r) / sin(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= 440.0) tmp = r * b; else tmp = -r / sin(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, 440.0], N[(r * b), $MachinePrecision], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 440:\\
\;\;\;\;r \cdot b\\
\mathbf{else}:\\
\;\;\;\;\frac{-r}{\sin a}\\
\end{array}
\end{array}
if b < 440Initial program 85.1%
associate-/l*85.0%
remove-double-neg85.0%
sin-neg85.0%
neg-mul-185.0%
associate-/r*85.0%
associate-/l*85.1%
*-commutative85.1%
associate-*l/85.1%
associate-/l*85.1%
sin-neg85.1%
distribute-lft-neg-in85.1%
distribute-rgt-neg-in85.1%
associate-/l*85.1%
metadata-eval85.1%
/-rgt-identity85.1%
+-commutative85.1%
Simplified85.1%
Taylor expanded in b around 0 71.9%
Taylor expanded in a around 0 47.4%
if 440 < b Initial program 49.3%
associate-/l*49.4%
+-commutative49.4%
Simplified49.4%
Taylor expanded in b around 0 10.3%
+-commutative10.3%
neg-mul-110.3%
unsub-neg10.3%
Simplified10.3%
Taylor expanded in b around inf 10.2%
associate-*r/10.2%
neg-mul-110.2%
Simplified10.2%
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 74.9%
associate-/l*74.8%
remove-double-neg74.8%
sin-neg74.8%
neg-mul-174.8%
associate-/r*74.8%
associate-/l*74.9%
*-commutative74.9%
associate-*l/74.9%
associate-/l*74.9%
sin-neg74.9%
distribute-lft-neg-in74.9%
distribute-rgt-neg-in74.9%
associate-/l*74.9%
metadata-eval74.9%
/-rgt-identity74.9%
+-commutative74.9%
Simplified74.9%
Taylor expanded in b around 0 52.4%
Taylor expanded in a around 0 34.8%
Final simplification34.8%
herbie shell --seed 2023333
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))