
(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 13 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)))) (fma (- (sin b)) (sin 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))) + fma(-sin(b), sin(a), (sin(b) * sin(a))));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))) + fma(Float64(-sin(b)), sin(a), Float64(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] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] + N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right) + \mathsf{fma}\left(-\sin b, \sin a, \sin b \cdot \sin a\right)}
\end{array}
Initial program 75.3%
+-commutative75.3%
Simplified75.3%
cos-sum99.5%
*-un-lft-identity99.5%
prod-diff99.5%
Applied egg-rr99.5%
fma-undefine99.5%
distribute-lft-neg-in99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
*-rgt-identity99.5%
*-commutative99.5%
fma-undefine99.5%
*-rgt-identity99.5%
distribute-lft-neg-in99.5%
*-rgt-identity99.5%
fma-undefine99.5%
*-commutative99.5%
Simplified99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
fma-define99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* (sin b) (sin a))))
(/
(* r (sin b))
(+ (fma (- (sin b)) (sin a) t_0) (- (* (cos b) (cos a)) t_0)))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (r * sin(b)) / (fma(-sin(b), sin(a), t_0) + ((cos(b) * cos(a)) - t_0));
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(r * sin(b)) / Float64(fma(Float64(-sin(b)), sin(a), t_0) + Float64(Float64(cos(b) * cos(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[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $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}{\mathsf{fma}\left(-\sin b, \sin a, t\_0\right) + \left(\cos b \cdot \cos a - t\_0\right)}
\end{array}
\end{array}
Initial program 75.3%
+-commutative75.3%
Simplified75.3%
cos-sum99.5%
*-un-lft-identity99.5%
prod-diff99.5%
Applied egg-rr99.5%
fma-undefine99.5%
distribute-lft-neg-in99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
*-rgt-identity99.5%
*-commutative99.5%
fma-undefine99.5%
*-rgt-identity99.5%
distribute-lft-neg-in99.5%
*-rgt-identity99.5%
fma-undefine99.5%
*-commutative99.5%
Simplified99.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(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a))))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 75.3%
+-commutative75.3%
Simplified75.3%
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.3%
associate-/l*75.3%
remove-double-neg75.3%
remove-double-neg75.3%
+-commutative75.3%
Simplified75.3%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 75.3%
+-commutative75.3%
Simplified75.3%
cos-sum99.4%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00034) (not (<= a 8.6e-19))) (* r (/ (sin b) (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00034) || !(a <= 8.6e-19)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * tan(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.00034d0)) .or. (.not. (a <= 8.6d-19))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00034) || !(a <= 8.6e-19)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.00034) or not (a <= 8.6e-19): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.00034) || !(a <= 8.6e-19)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.00034) || ~((a <= 8.6e-19))) tmp = r * (sin(b) / cos(a)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.00034], N[Not[LessEqual[a, 8.6e-19]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00034 \lor \neg \left(a \leq 8.6 \cdot 10^{-19}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -3.4e-4 or 8.6e-19 < a Initial program 55.6%
associate-/l*55.6%
remove-double-neg55.6%
remove-double-neg55.6%
+-commutative55.6%
Simplified55.6%
Taylor expanded in b around 0 55.8%
if -3.4e-4 < a < 8.6e-19Initial program 99.1%
associate-/l*99.0%
remove-double-neg99.0%
remove-double-neg99.0%
+-commutative99.0%
Simplified99.0%
add-cube-cbrt98.1%
pow398.2%
Applied egg-rr98.2%
Taylor expanded in a around 0 98.2%
rem-cube-cbrt99.0%
*-un-lft-identity99.0%
quot-tan99.2%
Applied egg-rr99.2%
*-lft-identity99.2%
Simplified99.2%
Final simplification75.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00015) (not (<= a 8.6e-19))) (/ r (/ (cos a) (sin b))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00015) || !(a <= 8.6e-19)) {
tmp = r / (cos(a) / sin(b));
} else {
tmp = r * tan(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.00015d0)) .or. (.not. (a <= 8.6d-19))) then
tmp = r / (cos(a) / sin(b))
else
tmp = r * tan(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00015) || !(a <= 8.6e-19)) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.00015) or not (a <= 8.6e-19): tmp = r / (math.cos(a) / math.sin(b)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.00015) || !(a <= 8.6e-19)) tmp = Float64(r / Float64(cos(a) / sin(b))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.00015) || ~((a <= 8.6e-19))) tmp = r / (cos(a) / sin(b)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.00015], N[Not[LessEqual[a, 8.6e-19]], $MachinePrecision]], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00015 \lor \neg \left(a \leq 8.6 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -1.49999999999999987e-4 or 8.6e-19 < a Initial program 55.6%
associate-/l*55.6%
remove-double-neg55.6%
remove-double-neg55.6%
+-commutative55.6%
Simplified55.6%
clear-num55.6%
un-div-inv55.6%
Applied egg-rr55.6%
Taylor expanded in b around 0 55.8%
if -1.49999999999999987e-4 < a < 8.6e-19Initial program 99.1%
associate-/l*99.0%
remove-double-neg99.0%
remove-double-neg99.0%
+-commutative99.0%
Simplified99.0%
add-cube-cbrt98.1%
pow398.2%
Applied egg-rr98.2%
Taylor expanded in a around 0 98.2%
rem-cube-cbrt99.0%
*-un-lft-identity99.0%
quot-tan99.2%
Applied egg-rr99.2%
*-lft-identity99.2%
Simplified99.2%
Final simplification75.5%
(FPCore (r a b) :precision binary64 (if (<= a -0.00045) (/ (* r (sin b)) (cos a)) (if (<= a 8.6e-19) (* r (tan b)) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00045) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 8.6e-19) {
tmp = r * tan(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.00045d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 8.6d-19) then
tmp = r * tan(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.00045) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 8.6e-19) {
tmp = r * Math.tan(b);
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.00045: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 8.6e-19: tmp = r * math.tan(b) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.00045) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 8.6e-19) tmp = Float64(r * tan(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.00045) tmp = (r * sin(b)) / cos(a); elseif (a <= 8.6e-19) tmp = r * tan(b); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00045], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 8.6e-19], N[(r * N[Tan[b], $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.00045:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 8.6 \cdot 10^{-19}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -4.4999999999999999e-4Initial program 52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in b around 0 52.6%
if -4.4999999999999999e-4 < a < 8.6e-19Initial program 99.1%
associate-/l*99.0%
remove-double-neg99.0%
remove-double-neg99.0%
+-commutative99.0%
Simplified99.0%
add-cube-cbrt98.1%
pow398.2%
Applied egg-rr98.2%
Taylor expanded in a around 0 98.2%
rem-cube-cbrt99.0%
*-un-lft-identity99.0%
quot-tan99.2%
Applied egg-rr99.2%
*-lft-identity99.2%
Simplified99.2%
if 8.6e-19 < a Initial program 57.9%
associate-/l*57.9%
remove-double-neg57.9%
remove-double-neg57.9%
+-commutative57.9%
Simplified57.9%
clear-num57.9%
un-div-inv57.9%
Applied egg-rr57.9%
Taylor expanded in b around 0 58.6%
Final simplification75.5%
(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.3%
associate-/l*75.3%
remove-double-neg75.3%
remove-double-neg75.3%
+-commutative75.3%
Simplified75.3%
Final simplification75.3%
(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.3%
+-commutative75.3%
Simplified75.3%
*-commutative75.3%
associate-/l*75.3%
Applied egg-rr75.3%
Final simplification75.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.85e-5) (not (<= b 1.5e-7))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.85e-5) || !(b <= 1.5e-7)) {
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 <= (-2.85d-5)) .or. (.not. (b <= 1.5d-7))) 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 <= -2.85e-5) || !(b <= 1.5e-7)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.85e-5) or not (b <= 1.5e-7): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.85e-5) || !(b <= 1.5e-7)) 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 <= -2.85e-5) || ~((b <= 1.5e-7))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.85e-5], N[Not[LessEqual[b, 1.5e-7]], $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 -2.85 \cdot 10^{-5} \lor \neg \left(b \leq 1.5 \cdot 10^{-7}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -2.8500000000000002e-5 or 1.4999999999999999e-7 < b Initial program 54.2%
associate-/l*54.1%
remove-double-neg54.1%
remove-double-neg54.1%
+-commutative54.1%
Simplified54.1%
add-cube-cbrt53.3%
pow353.3%
Applied egg-rr53.3%
Taylor expanded in a around 0 52.5%
rem-cube-cbrt53.3%
*-un-lft-identity53.3%
quot-tan53.4%
Applied egg-rr53.4%
*-lft-identity53.4%
Simplified53.4%
if -2.8500000000000002e-5 < b < 1.4999999999999999e-7Initial program 99.7%
+-commutative99.7%
Simplified99.7%
cos-sum99.7%
*-un-lft-identity99.7%
prod-diff99.7%
Applied egg-rr99.7%
fma-undefine99.7%
distribute-lft-neg-in99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-rgt-identity99.7%
*-commutative99.7%
fma-undefine99.7%
*-rgt-identity99.7%
distribute-lft-neg-in99.7%
*-rgt-identity99.7%
fma-undefine99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in b around 0 99.7%
associate-/l*99.7%
Simplified99.7%
Final simplification74.9%
(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 75.3%
associate-/l*75.3%
remove-double-neg75.3%
remove-double-neg75.3%
+-commutative75.3%
Simplified75.3%
add-cube-cbrt74.6%
pow374.6%
Applied egg-rr74.6%
Taylor expanded in a around 0 56.6%
rem-cube-cbrt57.0%
*-un-lft-identity57.0%
quot-tan57.1%
Applied egg-rr57.1%
*-lft-identity57.1%
Simplified57.1%
Final simplification57.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.3%
associate-/l*75.3%
remove-double-neg75.3%
remove-double-neg75.3%
+-commutative75.3%
Simplified75.3%
Taylor expanded in b around 0 49.4%
Taylor expanded in a around 0 31.4%
Final simplification31.4%
herbie shell --seed 2024068
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))