
(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 18 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(-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, -\sin b \cdot \sin a\right)}
\end{array}
Initial program 81.9%
+-commutative81.9%
Simplified81.9%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
Final simplification99.5%
(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(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(-Float64(sin(b) * sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / 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}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, -\sin b \cdot \sin a\right)}
\end{array}
Initial program 81.9%
associate-*r/81.9%
*-commutative81.9%
+-commutative81.9%
Simplified81.9%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.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 81.9%
associate-*r/81.9%
*-commutative81.9%
+-commutative81.9%
Simplified81.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 81.9%
+-commutative81.9%
Simplified81.9%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (/ (* (cos (+ b a)) -2.0) -2.0) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / (((cos((b + a)) * -2.0) / -2.0) - (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 + a)) * (-2.0d0)) / (-2.0d0)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / (((Math.cos((b + a)) * -2.0) / -2.0) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / (((math.cos((b + a)) * -2.0) / -2.0) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(Float64(cos(Float64(b + a)) * -2.0) / -2.0) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / (((cos((b + a)) * -2.0) / -2.0) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision] / -2.0), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\frac{\cos \left(b + a\right) \cdot -2}{-2} - \sin b \cdot \sin a}
\end{array}
Initial program 81.9%
+-commutative81.9%
Simplified81.9%
cos-sum99.5%
Applied egg-rr99.5%
cos-mult83.5%
frac-2neg83.5%
cos-diff82.8%
add-sqr-sqrt42.9%
sqrt-unprod83.0%
sqr-neg83.0%
sqrt-unprod40.1%
add-sqr-sqrt83.7%
cancel-sign-sub-inv83.7%
cos-sum83.5%
metadata-eval83.5%
Applied egg-rr83.5%
neg-mul-183.5%
distribute-lft-in83.5%
distribute-rgt-out83.5%
metadata-eval83.5%
Simplified83.5%
Final simplification83.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(r * Float64(sin(b) / fma(cos(b), cos(a), 0.0))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 81.9%
associate-*r/81.9%
*-commutative81.9%
+-commutative81.9%
Simplified81.9%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
add-sqr-sqrt46.2%
sqrt-unprod88.3%
sqr-neg88.3%
sqrt-unprod42.1%
add-sqr-sqrt81.5%
sin-mult82.6%
div-sub82.6%
Applied egg-rr82.6%
+-inverses82.6%
Simplified82.6%
Final simplification82.6%
(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 81.9%
+-commutative81.9%
Simplified81.9%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
add-sqr-sqrt46.2%
sqrt-unprod88.3%
sqr-neg88.3%
sqrt-unprod42.1%
add-sqr-sqrt81.5%
sin-mult82.6%
div-sub82.6%
Applied egg-rr82.6%
+-inverses82.6%
Simplified82.6%
Final simplification82.6%
(FPCore (r a b) :precision binary64 (if (<= b -1.26e-5) (* r (tan b)) (if (<= b 400000.0) (* b (/ r (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.26e-5) {
tmp = r * tan(b);
} else if (b <= 400000.0) {
tmp = b * (r / 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 (b <= (-1.26d-5)) then
tmp = r * tan(b)
else if (b <= 400000.0d0) then
tmp = b * (r / 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 (b <= -1.26e-5) {
tmp = r * Math.tan(b);
} else if (b <= 400000.0) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.26e-5: tmp = r * math.tan(b) elif b <= 400000.0: tmp = b * (r / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.26e-5) tmp = Float64(r * tan(b)); elseif (b <= 400000.0) tmp = Float64(b * Float64(r / 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 (b <= -1.26e-5) tmp = r * tan(b); elseif (b <= 400000.0) tmp = b * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.26e-5], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 400000.0], N[(b * N[(r / 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}\;b \leq -1.26 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 400000:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -1.25999999999999996e-5Initial program 68.2%
associate-*r/68.1%
*-commutative68.1%
+-commutative68.1%
Simplified68.1%
Taylor expanded in a around 0 68.8%
expm1-log1p-u58.0%
expm1-udef57.3%
quot-tan57.4%
Applied egg-rr57.4%
expm1-def58.1%
expm1-log1p68.9%
Simplified68.9%
if -1.25999999999999996e-5 < b < 4e5Initial program 99.0%
+-commutative99.0%
Simplified99.0%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 99.1%
*-commutative99.1%
associate-/l*98.9%
associate-/r/99.1%
Simplified99.1%
if 4e5 < b Initial program 56.9%
associate-*r/57.0%
*-commutative57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in a around 0 56.7%
Final simplification82.1%
(FPCore (r a b) :precision binary64 (if (<= b -6.2e-6) (/ (sin b) (/ (cos b) r)) (if (<= b 400000.0) (* b (/ r (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -6.2e-6) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 400000.0) {
tmp = b * (r / 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 (b <= (-6.2d-6)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 400000.0d0) then
tmp = b * (r / 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 (b <= -6.2e-6) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 400000.0) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -6.2e-6: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 400000.0: tmp = b * (r / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -6.2e-6) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 400000.0) tmp = Float64(b * Float64(r / 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 (b <= -6.2e-6) tmp = sin(b) / (cos(b) / r); elseif (b <= 400000.0) tmp = b * (r / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -6.2e-6], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 400000.0], N[(b * N[(r / 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}\;b \leq -6.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 400000:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -6.1999999999999999e-6Initial program 68.2%
+-commutative68.2%
Simplified68.2%
cos-sum99.3%
cancel-sign-sub-inv99.3%
fma-def99.3%
Applied egg-rr99.3%
Taylor expanded in a around 0 68.9%
associate-/l*68.9%
Simplified68.9%
if -6.1999999999999999e-6 < b < 4e5Initial program 99.0%
+-commutative99.0%
Simplified99.0%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 99.1%
*-commutative99.1%
associate-/l*98.9%
associate-/r/99.1%
Simplified99.1%
if 4e5 < b Initial program 56.9%
associate-*r/57.0%
*-commutative57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in a around 0 56.7%
Final simplification82.1%
(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 81.9%
associate-/l*81.7%
+-commutative81.7%
Simplified81.7%
associate-/r/81.9%
Applied egg-rr81.9%
Final simplification81.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 81.9%
associate-*r/81.9%
*-commutative81.9%
+-commutative81.9%
Simplified81.9%
Final simplification81.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(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 81.9%
Final simplification81.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(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 81.9%
+-commutative81.9%
Simplified81.9%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
add-sqr-sqrt46.2%
sqrt-unprod88.4%
sqr-neg88.4%
sqrt-unprod42.1%
add-sqr-sqrt81.5%
fma-def81.5%
cos-diff82.0%
Applied egg-rr82.0%
Final simplification82.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.26e-5) (not (<= b 400000.0))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.26e-5) || !(b <= 400000.0)) {
tmp = r * tan(b);
} else {
tmp = r * (b / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-1.26d-5)) .or. (.not. (b <= 400000.0d0))) then
tmp = r * tan(b)
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -1.26e-5) || !(b <= 400000.0)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.26e-5) or not (b <= 400000.0): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.26e-5) || !(b <= 400000.0)) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1.26e-5) || ~((b <= 400000.0))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.26e-5], N[Not[LessEqual[b, 400000.0]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.26 \cdot 10^{-5} \lor \neg \left(b \leq 400000\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.25999999999999996e-5 or 4e5 < b Initial program 62.2%
associate-*r/62.2%
*-commutative62.2%
+-commutative62.2%
Simplified62.2%
Taylor expanded in a around 0 62.4%
expm1-log1p-u51.1%
expm1-udef50.7%
quot-tan50.7%
Applied egg-rr50.7%
expm1-def51.1%
expm1-log1p62.4%
Simplified62.4%
if -1.25999999999999996e-5 < b < 4e5Initial program 99.0%
associate-*r/99.0%
*-commutative99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 99.1%
Final simplification82.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -3.6e-6) (not (<= b 400000.0))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -3.6e-6) || !(b <= 400000.0)) {
tmp = r * tan(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 <= (-3.6d-6)) .or. (.not. (b <= 400000.0d0))) then
tmp = r * tan(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 <= -3.6e-6) || !(b <= 400000.0)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -3.6e-6) or not (b <= 400000.0): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -3.6e-6) || !(b <= 400000.0)) tmp = Float64(r * tan(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 <= -3.6e-6) || ~((b <= 400000.0))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -3.6e-6], N[Not[LessEqual[b, 400000.0]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-6} \lor \neg \left(b \leq 400000\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -3.59999999999999984e-6 or 4e5 < b Initial program 62.2%
associate-*r/62.2%
*-commutative62.2%
+-commutative62.2%
Simplified62.2%
Taylor expanded in a around 0 62.4%
expm1-log1p-u51.1%
expm1-udef50.7%
quot-tan50.7%
Applied egg-rr50.7%
expm1-def51.1%
expm1-log1p62.4%
Simplified62.4%
if -3.59999999999999984e-6 < b < 4e5Initial program 99.0%
+-commutative99.0%
Simplified99.0%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 99.1%
*-commutative99.1%
associate-/l*98.9%
associate-/r/99.1%
Simplified99.1%
Final simplification82.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 81.9%
+-commutative81.9%
Simplified81.9%
Taylor expanded in b around 0 56.4%
mul-1-neg56.4%
unsub-neg56.4%
Simplified56.4%
Taylor expanded in a around 0 44.8%
Final simplification44.8%
(FPCore (r a b) :precision binary64 (* r (tan b)))
double code(double r, double a, double b) {
return r * tan(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 * tan(b)
end function
public static double code(double r, double a, double b) {
return r * Math.tan(b);
}
def code(r, a, b): return r * math.tan(b)
function code(r, a, b) return Float64(r * tan(b)) end
function tmp = code(r, a, b) tmp = r * tan(b); end
code[r_, a_, b_] := N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \tan b
\end{array}
Initial program 81.9%
associate-*r/81.9%
*-commutative81.9%
+-commutative81.9%
Simplified81.9%
Taylor expanded in a around 0 67.3%
expm1-log1p-u62.1%
expm1-udef36.9%
quot-tan36.9%
Applied egg-rr36.9%
expm1-def62.1%
expm1-log1p67.3%
Simplified67.3%
Final simplification67.3%
(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 81.9%
associate-*r/81.9%
*-commutative81.9%
+-commutative81.9%
Simplified81.9%
Taylor expanded in b around 0 55.2%
Taylor expanded in a around 0 40.6%
Final simplification40.6%
herbie shell --seed 2023238
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))