
(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 (/ (* 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(Float64(-sin(b)) * 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, \left(-\sin b\right) \cdot \sin a\right)}
\end{array}
Initial program 75.8%
associate-*r/75.8%
+-commutative75.8%
Simplified75.8%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (fma (cos b) (cos a) (* (- (sin b)) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / fma(cos(b), cos(a), (-sin(b) * sin(a))));
}
function code(r, a, b) return Float64(sin(b) * Float64(r / fma(cos(b), cos(a), Float64(Float64(-sin(b)) * sin(a))))) end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\mathsf{fma}\left(\cos b, \cos a, \left(-\sin b\right) \cdot \sin a\right)}
\end{array}
Initial program 75.8%
associate-*r/75.8%
+-commutative75.8%
Simplified75.8%
*-commutative75.8%
associate-/l*75.9%
Applied egg-rr75.9%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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 75.8%
+-commutative75.8%
Simplified75.8%
cos-sum99.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 75.8%
associate-*r/75.8%
+-commutative75.8%
Simplified75.8%
*-commutative75.8%
associate-/l*75.9%
Applied egg-rr75.9%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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.8%
associate-*r/75.8%
+-commutative75.8%
Simplified75.8%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ 1.0 (- (* (/ (cos b) r) (/ (cos a) (sin b))) (/ (sin a) r))))
double code(double r, double a, double b) {
return 1.0 / (((cos(b) / r) * (cos(a) / sin(b))) - (sin(a) / r));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (((cos(b) / r) * (cos(a) / sin(b))) - (sin(a) / r))
end function
public static double code(double r, double a, double b) {
return 1.0 / (((Math.cos(b) / r) * (Math.cos(a) / Math.sin(b))) - (Math.sin(a) / r));
}
def code(r, a, b): return 1.0 / (((math.cos(b) / r) * (math.cos(a) / math.sin(b))) - (math.sin(a) / r))
function code(r, a, b) return Float64(1.0 / Float64(Float64(Float64(cos(b) / r) * Float64(cos(a) / sin(b))) - Float64(sin(a) / r))) end
function tmp = code(r, a, b) tmp = 1.0 / (((cos(b) / r) * (cos(a) / sin(b))) - (sin(a) / r)); end
code[r_, a_, b_] := N[(1.0 / N[(N[(N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision] * N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{\cos b}{r} \cdot \frac{\cos a}{\sin b} - \frac{\sin a}{r}}
\end{array}
Initial program 75.8%
+-commutative75.8%
Simplified75.8%
associate-*r/75.8%
clear-num75.5%
*-commutative75.5%
Applied egg-rr75.5%
cos-sum99.1%
div-sub92.9%
Applied egg-rr92.9%
*-commutative92.9%
times-frac92.8%
remove-double-neg92.8%
neg-mul-192.8%
*-commutative92.8%
distribute-rgt-neg-in92.8%
distribute-frac-neg92.8%
associate-*r*92.8%
*-commutative92.8%
neg-mul-192.8%
distribute-neg-frac92.8%
times-frac99.0%
*-inverses99.0%
distribute-lft-neg-in99.0%
metadata-eval99.0%
associate-*r/99.0%
neg-mul-199.0%
Simplified99.0%
Final simplification99.0%
(FPCore (r a b) :precision binary64 (if (or (<= a -4.2e-8) (not (<= a 110.0))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -4.2e-8) || !(a <= 110.0)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (sin(b) / cos(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-4.2d-8)) .or. (.not. (a <= 110.0d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -4.2e-8) || !(a <= 110.0)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -4.2e-8) or not (a <= 110.0): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -4.2e-8) || !(a <= 110.0)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -4.2e-8) || ~((a <= 110.0))) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -4.2e-8], N[Not[LessEqual[a, 110.0]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{-8} \lor \neg \left(a \leq 110\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -4.19999999999999989e-8 or 110 < a Initial program 58.3%
+-commutative58.3%
Simplified58.3%
Taylor expanded in b around 0 58.9%
if -4.19999999999999989e-8 < a < 110Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.6%
Final simplification76.0%
(FPCore (r a b) :precision binary64 (if (<= a -4.2e-8) (* r (/ (sin b) (cos a))) (if (<= a 110.0) (* r (/ (sin b) (cos b))) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -4.2e-8) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 110.0) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(b) * (r / 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 <= (-4.2d-8)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 110.0d0) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(b) * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -4.2e-8) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 110.0) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -4.2e-8: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 110.0: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -4.2e-8) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 110.0) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -4.2e-8) tmp = r * (sin(b) / cos(a)); elseif (a <= 110.0) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -4.2e-8], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 110.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{-8}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 110:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -4.19999999999999989e-8Initial program 57.8%
+-commutative57.8%
Simplified57.8%
Taylor expanded in b around 0 58.4%
if -4.19999999999999989e-8 < a < 110Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.6%
if 110 < a Initial program 58.8%
associate-*r/58.8%
+-commutative58.8%
Simplified58.8%
*-commutative58.8%
associate-/l*58.9%
Applied egg-rr58.9%
Taylor expanded in b around 0 59.4%
Final simplification76.0%
(FPCore (r a b) :precision binary64 (if (<= a -4.2e-8) (* r (/ (sin b) (cos a))) (if (<= a 110.0) (* (sin b) (/ r (cos b))) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -4.2e-8) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 110.0) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = sin(b) * (r / 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 <= (-4.2d-8)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 110.0d0) then
tmp = sin(b) * (r / cos(b))
else
tmp = sin(b) * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -4.2e-8) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 110.0) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -4.2e-8: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 110.0: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -4.2e-8) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 110.0) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(sin(b) * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -4.2e-8) tmp = r * (sin(b) / cos(a)); elseif (a <= 110.0) tmp = sin(b) * (r / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -4.2e-8], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 110.0], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{-8}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 110:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -4.19999999999999989e-8Initial program 57.8%
+-commutative57.8%
Simplified57.8%
Taylor expanded in b around 0 58.4%
if -4.19999999999999989e-8 < a < 110Initial program 97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in a around 0 97.6%
*-commutative97.6%
associate-/l*97.7%
Simplified97.7%
if 110 < a Initial program 58.8%
associate-*r/58.8%
+-commutative58.8%
Simplified58.8%
*-commutative58.8%
associate-/l*58.9%
Applied egg-rr58.9%
Taylor expanded in b around 0 59.4%
Final simplification76.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.8%
Final simplification75.8%
(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.8%
associate-*r/75.8%
+-commutative75.8%
Simplified75.8%
*-commutative75.8%
associate-/l*75.9%
Applied egg-rr75.9%
Final simplification75.9%
(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 75.8%
+-commutative75.8%
Simplified75.8%
Taylor expanded in b around 0 57.7%
Final simplification57.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -11000000.0) (not (<= b 2.05e+14))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -11000000.0) || !(b <= 2.05e+14)) {
tmp = r * sin(b);
} else {
tmp = b * (r / 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 <= (-11000000.0d0)) .or. (.not. (b <= 2.05d+14))) then
tmp = r * sin(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -11000000.0) || !(b <= 2.05e+14)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -11000000.0) or not (b <= 2.05e+14): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -11000000.0) || !(b <= 2.05e+14)) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -11000000.0) || ~((b <= 2.05e+14))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -11000000.0], N[Not[LessEqual[b, 2.05e+14]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -11000000 \lor \neg \left(b \leq 2.05 \cdot 10^{+14}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -1.1e7 or 2.05e14 < b Initial program 48.4%
associate-*r/48.4%
+-commutative48.4%
Simplified48.4%
cos-sum99.1%
cancel-sign-sub-inv99.1%
fma-define99.2%
Applied egg-rr99.2%
Taylor expanded in a around 0 44.9%
mul-1-neg44.9%
unsub-neg44.9%
Simplified44.9%
Taylor expanded in b around 0 11.7%
if -1.1e7 < b < 2.05e14Initial program 98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in b around 0 96.5%
clear-num96.3%
un-div-inv96.3%
Applied egg-rr96.3%
associate-/r/96.5%
Simplified96.5%
Final simplification57.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 75.8%
+-commutative75.8%
Simplified75.8%
Taylor expanded in b around 0 54.1%
Final simplification54.1%
(FPCore (r a b) :precision binary64 (* b (/ r (cos a))))
double code(double r, double a, double b) {
return 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 = b * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return b * (r / Math.cos(a));
}
def code(r, a, b): return b * (r / math.cos(a))
function code(r, a, b) return Float64(b * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = b * (r / cos(a)); end
code[r_, a_, b_] := N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{r}{\cos a}
\end{array}
Initial program 75.8%
+-commutative75.8%
Simplified75.8%
Taylor expanded in b around 0 54.1%
clear-num54.0%
un-div-inv54.0%
Applied egg-rr54.0%
associate-/r/54.1%
Simplified54.1%
Final simplification54.1%
(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.8%
+-commutative75.8%
Simplified75.8%
Taylor expanded in b around 0 54.1%
Taylor expanded in a around 0 35.0%
Final simplification35.0%
herbie shell --seed 2024067
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))