
(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 11 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 (- (/ (cos a) (tan b)) (sin a))))
double code(double r, double a, double b) {
return r / ((cos(a) / tan(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 / ((cos(a) / tan(b)) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / Math.tan(b)) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) / math.tan(b)) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / tan(b)) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / tan(b)) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[Tan[b], $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\tan b} - \sin a}
\end{array}
Initial program 73.8%
associate-/l*73.7%
+-commutative73.7%
Simplified73.7%
cos-sum99.4%
Applied egg-rr99.4%
div-sub99.4%
sub-neg99.4%
*-commutative99.4%
*-un-lft-identity99.4%
times-frac99.4%
clear-num99.3%
quot-tan99.4%
Applied egg-rr99.4%
sub-neg99.4%
/-rgt-identity99.4%
associate-*r/99.5%
*-rgt-identity99.5%
*-lft-identity99.5%
times-frac99.5%
/-rgt-identity99.5%
Simplified99.5%
Taylor expanded in b around 0 99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.000205) (not (<= a 1.6e+36))) (* r (/ (sin b) (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.000205) || !(a <= 1.6e+36)) {
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.000205d0)) .or. (.not. (a <= 1.6d+36))) 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.000205) || !(a <= 1.6e+36)) {
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.000205) or not (a <= 1.6e+36): 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.000205) || !(a <= 1.6e+36)) 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.000205) || ~((a <= 1.6e+36))) 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.000205], N[Not[LessEqual[a, 1.6e+36]], $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.000205 \lor \neg \left(a \leq 1.6 \cdot 10^{+36}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -2.05e-4 or 1.5999999999999999e36 < a Initial program 54.2%
associate-/l*54.3%
remove-double-neg54.3%
sin-neg54.3%
neg-mul-154.3%
associate-/r*54.3%
associate-/l*54.2%
*-commutative54.2%
associate-*l/54.2%
associate-/l*54.2%
sin-neg54.2%
distribute-lft-neg-in54.2%
distribute-rgt-neg-in54.2%
associate-/l*54.2%
metadata-eval54.2%
/-rgt-identity54.2%
+-commutative54.2%
Simplified54.2%
Taylor expanded in b around 0 54.1%
if -2.05e-4 < a < 1.5999999999999999e36Initial program 94.9%
associate-/l*94.8%
remove-double-neg94.8%
sin-neg94.8%
neg-mul-194.8%
associate-/r*94.8%
associate-/l*94.9%
*-commutative94.9%
associate-*l/94.9%
associate-/l*94.9%
sin-neg94.9%
distribute-lft-neg-in94.9%
distribute-rgt-neg-in94.9%
associate-/l*94.9%
metadata-eval94.9%
/-rgt-identity94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 94.9%
tan-quot95.1%
expm1-log1p-u81.1%
expm1-udef51.0%
Applied egg-rr51.0%
expm1-def81.1%
expm1-log1p95.1%
Simplified95.1%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.000165) (not (<= a 1.6e+36))) (/ r (/ (cos a) (sin b))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.000165) || !(a <= 1.6e+36)) {
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.000165d0)) .or. (.not. (a <= 1.6d+36))) 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.000165) || !(a <= 1.6e+36)) {
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.000165) or not (a <= 1.6e+36): 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.000165) || !(a <= 1.6e+36)) 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.000165) || ~((a <= 1.6e+36))) 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.000165], N[Not[LessEqual[a, 1.6e+36]], $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.000165 \lor \neg \left(a \leq 1.6 \cdot 10^{+36}\right):\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -1.65e-4 or 1.5999999999999999e36 < a Initial program 54.2%
associate-/l*54.3%
+-commutative54.3%
Simplified54.3%
Taylor expanded in b around 0 54.2%
if -1.65e-4 < a < 1.5999999999999999e36Initial program 94.9%
associate-/l*94.8%
remove-double-neg94.8%
sin-neg94.8%
neg-mul-194.8%
associate-/r*94.8%
associate-/l*94.9%
*-commutative94.9%
associate-*l/94.9%
associate-/l*94.9%
sin-neg94.9%
distribute-lft-neg-in94.9%
distribute-rgt-neg-in94.9%
associate-/l*94.9%
metadata-eval94.9%
/-rgt-identity94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 94.9%
tan-quot95.1%
expm1-log1p-u81.1%
expm1-udef51.0%
Applied egg-rr51.0%
expm1-def81.1%
expm1-log1p95.1%
Simplified95.1%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (<= a -7.5e-5) (/ (* r (sin b)) (cos a)) (if (<= a 1.6e+36) (* r (tan b)) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -7.5e-5) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 1.6e+36) {
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 <= (-7.5d-5)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 1.6d+36) 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 <= -7.5e-5) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 1.6e+36) {
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 <= -7.5e-5: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 1.6e+36: 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 <= -7.5e-5) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 1.6e+36) 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 <= -7.5e-5) tmp = (r * sin(b)) / cos(a); elseif (a <= 1.6e+36) tmp = r * tan(b); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -7.5e-5], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.6e+36], 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 -7.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{+36}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -7.49999999999999934e-5Initial program 49.9%
+-commutative49.9%
Simplified49.9%
Taylor expanded in b around 0 48.7%
if -7.49999999999999934e-5 < a < 1.5999999999999999e36Initial program 94.9%
associate-/l*94.8%
remove-double-neg94.8%
sin-neg94.8%
neg-mul-194.8%
associate-/r*94.8%
associate-/l*94.9%
*-commutative94.9%
associate-*l/94.9%
associate-/l*94.9%
sin-neg94.9%
distribute-lft-neg-in94.9%
distribute-rgt-neg-in94.9%
associate-/l*94.9%
metadata-eval94.9%
/-rgt-identity94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 94.9%
tan-quot95.1%
expm1-log1p-u81.1%
expm1-udef51.0%
Applied egg-rr51.0%
expm1-def81.1%
expm1-log1p95.1%
Simplified95.1%
if 1.5999999999999999e36 < a Initial program 59.2%
associate-/l*59.3%
+-commutative59.3%
Simplified59.3%
Taylor expanded in b around 0 60.4%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ a b)))))
double code(double r, double a, double b) {
return sin(b) * (r / 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 = sin(b) * (r / cos((a + b)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((a + b)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((a + b)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(a + b)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((a + b))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(a + b\right)}
\end{array}
Initial program 73.8%
associate-/l*73.7%
+-commutative73.7%
Simplified73.7%
associate-/r/73.7%
Applied egg-rr73.7%
Final simplification73.7%
(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}
Initial program 73.8%
associate-/l*73.7%
remove-double-neg73.7%
sin-neg73.7%
neg-mul-173.7%
associate-/r*73.7%
associate-/l*73.8%
*-commutative73.8%
associate-*l/73.8%
associate-/l*73.8%
sin-neg73.8%
distribute-lft-neg-in73.8%
distribute-rgt-neg-in73.8%
associate-/l*73.8%
metadata-eval73.8%
/-rgt-identity73.8%
+-commutative73.8%
Simplified73.8%
Final simplification73.8%
(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}
Initial program 73.8%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.1) (not (<= b 3.8e-8))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.1) || !(b <= 3.8e-8)) {
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 <= (-0.1d0)) .or. (.not. (b <= 3.8d-8))) 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 <= -0.1) || !(b <= 3.8e-8)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.1) or not (b <= 3.8e-8): tmp = r * math.tan(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.1) || !(b <= 3.8e-8)) 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 <= -0.1) || ~((b <= 3.8e-8))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.1], N[Not[LessEqual[b, 3.8e-8]], $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 -0.1 \lor \neg \left(b \leq 3.8 \cdot 10^{-8}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -0.10000000000000001 or 3.80000000000000028e-8 < b Initial program 52.9%
associate-/l*52.8%
remove-double-neg52.8%
sin-neg52.8%
neg-mul-152.8%
associate-/r*52.8%
associate-/l*52.9%
*-commutative52.9%
associate-*l/52.9%
associate-/l*52.9%
sin-neg52.9%
distribute-lft-neg-in52.9%
distribute-rgt-neg-in52.9%
associate-/l*52.9%
metadata-eval52.9%
/-rgt-identity52.9%
+-commutative52.9%
Simplified52.9%
Taylor expanded in a around 0 52.7%
tan-quot52.9%
expm1-log1p-u38.7%
expm1-udef37.8%
Applied egg-rr37.8%
expm1-def38.7%
expm1-log1p52.9%
Simplified52.9%
if -0.10000000000000001 < b < 3.80000000000000028e-8Initial program 97.5%
associate-/l*97.4%
remove-double-neg97.4%
sin-neg97.4%
neg-mul-197.4%
associate-/r*97.4%
associate-/l*97.5%
*-commutative97.5%
associate-*l/97.5%
associate-/l*97.5%
sin-neg97.5%
distribute-lft-neg-in97.5%
distribute-rgt-neg-in97.5%
associate-/l*97.5%
metadata-eval97.5%
/-rgt-identity97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 97.5%
Final simplification73.8%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.1) (not (<= b 3.8e-8))) (* r (tan b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.1) || !(b <= 3.8e-8)) {
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 <= (-0.1d0)) .or. (.not. (b <= 3.8d-8))) 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 <= -0.1) || !(b <= 3.8e-8)) {
tmp = r * Math.tan(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.1) or not (b <= 3.8e-8): tmp = r * math.tan(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.1) || !(b <= 3.8e-8)) 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 <= -0.1) || ~((b <= 3.8e-8))) tmp = r * tan(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.1], N[Not[LessEqual[b, 3.8e-8]], $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 -0.1 \lor \neg \left(b \leq 3.8 \cdot 10^{-8}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -0.10000000000000001 or 3.80000000000000028e-8 < b Initial program 52.9%
associate-/l*52.8%
remove-double-neg52.8%
sin-neg52.8%
neg-mul-152.8%
associate-/r*52.8%
associate-/l*52.9%
*-commutative52.9%
associate-*l/52.9%
associate-/l*52.9%
sin-neg52.9%
distribute-lft-neg-in52.9%
distribute-rgt-neg-in52.9%
associate-/l*52.9%
metadata-eval52.9%
/-rgt-identity52.9%
+-commutative52.9%
Simplified52.9%
Taylor expanded in a around 0 52.7%
tan-quot52.9%
expm1-log1p-u38.7%
expm1-udef37.8%
Applied egg-rr37.8%
expm1-def38.7%
expm1-log1p52.9%
Simplified52.9%
if -0.10000000000000001 < b < 3.80000000000000028e-8Initial program 97.5%
associate-/l*97.4%
remove-double-neg97.4%
sin-neg97.4%
neg-mul-197.4%
associate-/r*97.4%
associate-/l*97.5%
*-commutative97.5%
associate-*l/97.5%
associate-/l*97.5%
sin-neg97.5%
distribute-lft-neg-in97.5%
distribute-rgt-neg-in97.5%
associate-/l*97.5%
metadata-eval97.5%
/-rgt-identity97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 97.5%
Final simplification73.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 73.8%
associate-/l*73.7%
remove-double-neg73.7%
sin-neg73.7%
neg-mul-173.7%
associate-/r*73.7%
associate-/l*73.8%
*-commutative73.8%
associate-*l/73.8%
associate-/l*73.8%
sin-neg73.8%
distribute-lft-neg-in73.8%
distribute-rgt-neg-in73.8%
associate-/l*73.8%
metadata-eval73.8%
/-rgt-identity73.8%
+-commutative73.8%
Simplified73.8%
Taylor expanded in a around 0 57.1%
tan-quot57.2%
expm1-log1p-u49.6%
expm1-udef34.0%
Applied egg-rr34.0%
expm1-def49.6%
expm1-log1p57.2%
Simplified57.2%
Final simplification57.2%
(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 73.8%
associate-/l*73.7%
remove-double-neg73.7%
sin-neg73.7%
neg-mul-173.7%
associate-/r*73.7%
associate-/l*73.8%
*-commutative73.8%
associate-*l/73.8%
associate-/l*73.8%
sin-neg73.8%
distribute-lft-neg-in73.8%
distribute-rgt-neg-in73.8%
associate-/l*73.8%
metadata-eval73.8%
/-rgt-identity73.8%
+-commutative73.8%
Simplified73.8%
Taylor expanded in b around 0 48.9%
Taylor expanded in a around 0 32.2%
*-commutative32.2%
Simplified32.2%
Final simplification32.2%
herbie shell --seed 2023330
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))