
(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 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.7%
+-commutative75.7%
Simplified75.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.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.7%
+-commutative75.7%
Simplified75.7%
cos-sum99.5%
Applied egg-rr99.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.7%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
cos-sum99.5%
Applied egg-rr99.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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a}
\end{array}
Initial program 75.7%
+-commutative75.7%
Simplified75.7%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult77.2%
div-sub77.2%
cos-diff76.9%
add-sqr-sqrt41.2%
sqrt-unprod76.1%
sqr-neg76.1%
sqrt-unprod35.0%
add-sqr-sqrt75.1%
cancel-sign-sub-inv75.1%
cos-sum77.0%
Applied egg-rr77.0%
+-inverses77.0%
Simplified77.0%
Final simplification77.0%
(FPCore (r a b) :precision binary64 (if (<= b -2.05e-6) (/ r (/ (cos b) (sin b))) (if (<= b 220.0) (/ (* r (sin b)) (cos a)) (* r (tan b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.05e-6) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 220.0) {
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 (b <= (-2.05d-6)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 220.0d0) 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 (b <= -2.05e-6) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 220.0) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.05e-6: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 220.0: 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 (b <= -2.05e-6) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 220.0) tmp = Float64(Float64(r * 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 (b <= -2.05e-6) tmp = r / (cos(b) / sin(b)); elseif (b <= 220.0) tmp = (r * sin(b)) / cos(a); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.05e-6], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 220.0], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 220:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if b < -2.0499999999999999e-6Initial program 53.5%
associate-/l*53.4%
remove-double-neg53.4%
remove-double-neg53.4%
+-commutative53.4%
Simplified53.4%
clear-num53.3%
un-div-inv53.5%
Applied egg-rr53.5%
Taylor expanded in a around 0 52.8%
if -2.0499999999999999e-6 < b < 220Initial program 97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in b around 0 97.8%
if 220 < b Initial program 51.7%
associate-/l*51.7%
remove-double-neg51.7%
remove-double-neg51.7%
+-commutative51.7%
Simplified51.7%
log1p-expm1-u51.6%
Applied egg-rr51.6%
Taylor expanded in a around 0 52.8%
expm1-define53.0%
log1p-expm1-u53.0%
add-log-exp52.9%
*-un-lft-identity52.9%
log-prod52.9%
metadata-eval52.9%
add-log-exp53.0%
quot-tan53.2%
Applied egg-rr53.2%
+-lft-identity53.2%
Simplified53.2%
(FPCore (r a b) :precision binary64 (if (<= b -1.86e-6) (/ r (/ (cos b) (sin b))) (if (<= b 0.00017) (/ (* r b) (cos a)) (* r (tan b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.86e-6) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 0.00017) {
tmp = (r * 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 (b <= (-1.86d-6)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 0.00017d0) then
tmp = (r * 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 (b <= -1.86e-6) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 0.00017) {
tmp = (r * b) / Math.cos(a);
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.86e-6: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 0.00017: tmp = (r * b) / math.cos(a) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.86e-6) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 0.00017) tmp = Float64(Float64(r * b) / cos(a)); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -1.86e-6) tmp = r / (cos(b) / sin(b)); elseif (b <= 0.00017) tmp = (r * b) / cos(a); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.86e-6], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.00017], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.86 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 0.00017:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if b < -1.86e-6Initial program 53.5%
associate-/l*53.4%
remove-double-neg53.4%
remove-double-neg53.4%
+-commutative53.4%
Simplified53.4%
clear-num53.3%
un-div-inv53.5%
Applied egg-rr53.5%
Taylor expanded in a around 0 52.8%
if -1.86e-6 < b < 1.7e-4Initial program 98.4%
associate-/l*98.3%
remove-double-neg98.3%
remove-double-neg98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.4%
if 1.7e-4 < b Initial program 51.2%
associate-/l*51.2%
remove-double-neg51.2%
remove-double-neg51.2%
+-commutative51.2%
Simplified51.2%
log1p-expm1-u51.2%
Applied egg-rr51.2%
Taylor expanded in a around 0 52.3%
expm1-define52.5%
log1p-expm1-u52.5%
add-log-exp52.4%
*-un-lft-identity52.4%
log-prod52.4%
metadata-eval52.4%
add-log-exp52.5%
quot-tan52.8%
Applied egg-rr52.8%
+-lft-identity52.8%
Simplified52.8%
Final simplification75.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 75.7%
Final simplification75.7%
(FPCore (r a b) :precision binary64 (/ r (/ (cos (+ b a)) (sin b))))
double code(double r, double a, double b) {
return r / (cos((b + a)) / 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 / (cos((b + a)) / sin(b))
end function
public static double code(double r, double a, double b) {
return r / (Math.cos((b + a)) / Math.sin(b));
}
def code(r, a, b): return r / (math.cos((b + a)) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(cos(Float64(b + a)) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (cos((b + a)) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos \left(b + a\right)}{\sin b}}
\end{array}
Initial program 75.7%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
clear-num75.5%
un-div-inv75.6%
Applied egg-rr75.6%
(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.7%
+-commutative75.7%
Simplified75.7%
*-commutative75.7%
associate-/l*75.6%
Applied egg-rr75.6%
(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.7%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.4e-6) (not (<= b 0.00031))) (* r (tan b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.4e-6) || !(b <= 0.00031)) {
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 <= (-2.4d-6)) .or. (.not. (b <= 0.00031d0))) 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 <= -2.4e-6) || !(b <= 0.00031)) {
tmp = r * Math.tan(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.4e-6) or not (b <= 0.00031): tmp = r * math.tan(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.4e-6) || !(b <= 0.00031)) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.4e-6) || ~((b <= 0.00031))) tmp = r * tan(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.4e-6], N[Not[LessEqual[b, 0.00031]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-6} \lor \neg \left(b \leq 0.00031\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -2.3999999999999999e-6 or 3.1e-4 < b Initial program 52.2%
associate-/l*52.2%
remove-double-neg52.2%
remove-double-neg52.2%
+-commutative52.2%
Simplified52.2%
log1p-expm1-u51.5%
Applied egg-rr51.5%
Taylor expanded in a around 0 51.6%
expm1-define51.9%
log1p-expm1-u52.6%
add-log-exp52.3%
*-un-lft-identity52.3%
log-prod52.3%
metadata-eval52.3%
add-log-exp52.6%
quot-tan52.8%
Applied egg-rr52.8%
+-lft-identity52.8%
Simplified52.8%
if -2.3999999999999999e-6 < b < 3.1e-4Initial program 98.4%
associate-/l*98.3%
remove-double-neg98.3%
remove-double-neg98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in b around 0 98.4%
Final simplification75.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.3e-6) (not (<= b 0.000205))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.3e-6) || !(b <= 0.000205)) {
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.3d-6)) .or. (.not. (b <= 0.000205d0))) 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.3e-6) || !(b <= 0.000205)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.3e-6) or not (b <= 0.000205): 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.3e-6) || !(b <= 0.000205)) 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.3e-6) || ~((b <= 0.000205))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.3e-6], N[Not[LessEqual[b, 0.000205]], $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.3 \cdot 10^{-6} \lor \neg \left(b \leq 0.000205\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -2.3e-6 or 2.05e-4 < b Initial program 52.2%
associate-/l*52.2%
remove-double-neg52.2%
remove-double-neg52.2%
+-commutative52.2%
Simplified52.2%
log1p-expm1-u51.5%
Applied egg-rr51.5%
Taylor expanded in a around 0 51.6%
expm1-define51.9%
log1p-expm1-u52.6%
add-log-exp52.3%
*-un-lft-identity52.3%
log-prod52.3%
metadata-eval52.3%
add-log-exp52.6%
quot-tan52.8%
Applied egg-rr52.8%
+-lft-identity52.8%
Simplified52.8%
if -2.3e-6 < b < 2.05e-4Initial program 98.4%
+-commutative98.4%
Simplified98.4%
cos-sum99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 98.4%
associate-/l*98.3%
Simplified98.3%
Final simplification75.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.7%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
log1p-expm1-u75.2%
Applied egg-rr75.2%
Taylor expanded in a around 0 38.6%
expm1-define58.0%
log1p-expm1-u58.3%
add-log-exp39.0%
*-un-lft-identity39.0%
log-prod39.0%
metadata-eval39.0%
add-log-exp58.3%
quot-tan58.4%
Applied egg-rr58.4%
+-lft-identity58.4%
Simplified58.4%
(FPCore (r a b) :precision binary64 (* r (log1p b)))
double code(double r, double a, double b) {
return r * log1p(b);
}
public static double code(double r, double a, double b) {
return r * Math.log1p(b);
}
def code(r, a, b): return r * math.log1p(b)
function code(r, a, b) return Float64(r * log1p(b)) end
code[r_, a_, b_] := N[(r * N[Log[1 + b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \mathsf{log1p}\left(b\right)
\end{array}
Initial program 75.7%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
log1p-expm1-u75.2%
Applied egg-rr75.2%
Taylor expanded in a around 0 38.6%
Taylor expanded in b around 0 35.0%
(FPCore (r a b) :precision binary64 (* r b))
double code(double r, double a, double b) {
return r * b;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * b
end function
public static double code(double r, double a, double b) {
return r * b;
}
def code(r, a, b): return r * b
function code(r, a, b) return Float64(r * b) end
function tmp = code(r, a, b) tmp = r * b; end
code[r_, a_, b_] := N[(r * b), $MachinePrecision]
\begin{array}{l}
\\
r \cdot b
\end{array}
Initial program 75.7%
associate-/l*75.6%
remove-double-neg75.6%
remove-double-neg75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in b around 0 52.2%
Taylor expanded in a around 0 34.9%
herbie shell --seed 2024095
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))