
(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 12 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 75.6%
associate-/l*75.6%
+-commutative75.6%
Simplified75.6%
add-log-exp42.3%
Applied egg-rr42.3%
cos-sum66.1%
Applied egg-rr66.1%
rem-log-exp99.4%
div-sub99.4%
sub-neg99.4%
*-commutative99.4%
associate-/l*99.4%
quot-tan99.5%
associate-/l*99.5%
Applied egg-rr99.5%
+-commutative99.5%
associate-/r/99.5%
*-inverses99.5%
distribute-lft-neg-in99.5%
metadata-eval99.5%
mul-1-neg99.5%
Simplified99.5%
tan-quot99.4%
associate-/l*99.4%
+-commutative99.4%
unsub-neg99.4%
associate-/l*99.4%
tan-quot99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00225) (not (<= a 0.00145))) (* r (/ (sin b) (cos a))) (* r (/ 1.0 (- (/ 1.0 (tan b)) a)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00225) || !(a <= 0.00145)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-0.00225d0)) .or. (.not. (a <= 0.00145d0))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00225) || !(a <= 0.00145)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -0.00225) or not (a <= 0.00145): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -0.00225) || !(a <= 0.00145)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -0.00225) || ~((a <= 0.00145))) tmp = r * (sin(b) / cos(a)); else tmp = r * (1.0 / ((1.0 / tan(b)) - a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -0.00225], N[Not[LessEqual[a, 0.00145]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00225 \lor \neg \left(a \leq 0.00145\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\end{array}
\end{array}
if a < -0.00224999999999999983 or 0.00145 < a Initial program 57.1%
associate-/l*57.1%
remove-double-neg57.1%
sin-neg57.1%
neg-mul-157.1%
associate-/r*57.1%
associate-/l*57.1%
*-commutative57.1%
associate-*l/57.1%
associate-/l*57.1%
sin-neg57.1%
distribute-lft-neg-in57.1%
distribute-rgt-neg-in57.1%
associate-/l*57.1%
metadata-eval57.1%
/-rgt-identity57.1%
+-commutative57.1%
Simplified57.1%
Taylor expanded in b around 0 57.1%
if -0.00224999999999999983 < a < 0.00145Initial program 98.4%
associate-/l*98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in a around 0 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
Simplified99.0%
div-inv99.1%
clear-num99.0%
quot-tan99.2%
Applied egg-rr99.2%
Final simplification76.0%
(FPCore (r a b)
:precision binary64
(if (<= a -0.0072)
(* r (/ (sin b) (cos a)))
(if (<= a 0.065)
(* r (/ 1.0 (- (/ 1.0 (tan b)) a)))
(/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.0072) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 0.065) {
tmp = r * (1.0 / ((1.0 / tan(b)) - a));
} 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.0072d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 0.065d0) then
tmp = r * (1.0d0 / ((1.0d0 / tan(b)) - a))
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.0072) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 0.065) {
tmp = r * (1.0 / ((1.0 / Math.tan(b)) - a));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.0072: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 0.065: tmp = r * (1.0 / ((1.0 / math.tan(b)) - a)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.0072) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 0.065) tmp = Float64(r * Float64(1.0 / Float64(Float64(1.0 / tan(b)) - a))); 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.0072) tmp = r * (sin(b) / cos(a)); elseif (a <= 0.065) tmp = r * (1.0 / ((1.0 / tan(b)) - a)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.0072], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.065], N[(r * N[(1.0 / N[(N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $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.0072:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 0.065:\\
\;\;\;\;r \cdot \frac{1}{\frac{1}{\tan b} - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -0.0071999999999999998Initial program 54.2%
associate-/l*54.2%
remove-double-neg54.2%
sin-neg54.2%
neg-mul-154.2%
associate-/r*54.2%
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 55.2%
if -0.0071999999999999998 < a < 0.065000000000000002Initial program 98.4%
associate-/l*98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in a around 0 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
Simplified99.0%
div-inv99.1%
clear-num99.0%
quot-tan99.2%
Applied egg-rr99.2%
if 0.065000000000000002 < a Initial program 60.1%
associate-/l*60.3%
+-commutative60.3%
Simplified60.3%
Taylor expanded in b around 0 59.2%
Final simplification76.0%
(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 75.6%
associate-/l*75.6%
+-commutative75.6%
Simplified75.6%
associate-/r/75.7%
Applied egg-rr75.7%
Final simplification75.7%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (cos (+ a b)) r)))
double code(double r, double a, double b) {
return sin(b) / (cos((a + b)) / r);
}
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) / (cos((a + b)) / r)
end function
public static double code(double r, double a, double b) {
return Math.sin(b) / (Math.cos((a + b)) / r);
}
def code(r, a, b): return math.sin(b) / (math.cos((a + b)) / r)
function code(r, a, b) return Float64(sin(b) / Float64(cos(Float64(a + b)) / r)) end
function tmp = code(r, a, b) tmp = sin(b) / (cos((a + b)) / r); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\cos \left(a + b\right)}{r}}
\end{array}
Initial program 75.6%
associate-/l*75.6%
remove-double-neg75.6%
sin-neg75.6%
neg-mul-175.6%
associate-/r*75.6%
associate-/l*75.6%
*-commutative75.6%
associate-*l/75.7%
associate-/l*75.7%
sin-neg75.7%
distribute-lft-neg-in75.7%
distribute-rgt-neg-in75.7%
associate-/l*75.7%
metadata-eval75.7%
/-rgt-identity75.7%
+-commutative75.7%
Simplified75.7%
associate-*l/75.6%
associate-/l*75.7%
Applied egg-rr75.7%
Final simplification75.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -4e-5) (not (<= b 1050000.0))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4e-5) || !(b <= 1050000.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 <= (-4d-5)) .or. (.not. (b <= 1050000.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 <= -4e-5) || !(b <= 1050000.0)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4e-5) or not (b <= 1050000.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 <= -4e-5) || !(b <= 1050000.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 <= -4e-5) || ~((b <= 1050000.0))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4e-5], N[Not[LessEqual[b, 1050000.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 -4 \cdot 10^{-5} \lor \neg \left(b \leq 1050000\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.00000000000000033e-5 or 1.05e6 < b Initial program 51.8%
associate-/l*51.8%
+-commutative51.8%
Simplified51.8%
Taylor expanded in a around 0 50.6%
clear-num50.6%
associate-/r/50.7%
clear-num50.7%
quot-tan50.8%
Applied egg-rr50.8%
if -4.00000000000000033e-5 < b < 1.05e6Initial program 99.1%
associate-/l*99.0%
remove-double-neg99.0%
sin-neg99.0%
neg-mul-199.0%
associate-/r*99.0%
associate-/l*99.1%
*-commutative99.1%
associate-*l/99.1%
associate-/l*99.1%
sin-neg99.1%
distribute-lft-neg-in99.1%
distribute-rgt-neg-in99.1%
associate-/l*99.1%
metadata-eval99.1%
/-rgt-identity99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in b around 0 99.0%
Final simplification75.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -2e-5) (not (<= b 1050000.0))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2e-5) || !(b <= 1050000.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 <= (-2d-5)) .or. (.not. (b <= 1050000.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 <= -2e-5) || !(b <= 1050000.0)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2e-5) or not (b <= 1050000.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 <= -2e-5) || !(b <= 1050000.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 <= -2e-5) || ~((b <= 1050000.0))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2e-5], N[Not[LessEqual[b, 1050000.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 -2 \cdot 10^{-5} \lor \neg \left(b \leq 1050000\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -2.00000000000000016e-5 or 1.05e6 < b Initial program 51.8%
associate-/l*51.8%
+-commutative51.8%
Simplified51.8%
Taylor expanded in a around 0 50.6%
clear-num50.6%
associate-/r/50.7%
clear-num50.7%
quot-tan50.8%
Applied egg-rr50.8%
if -2.00000000000000016e-5 < b < 1.05e6Initial program 99.1%
associate-/l*99.0%
remove-double-neg99.0%
sin-neg99.0%
neg-mul-199.0%
associate-/r*99.0%
associate-/l*99.1%
*-commutative99.1%
associate-*l/99.1%
associate-/l*99.1%
sin-neg99.1%
distribute-lft-neg-in99.1%
distribute-rgt-neg-in99.1%
associate-/l*99.1%
metadata-eval99.1%
/-rgt-identity99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in b around 0 99.0%
*-commutative99.0%
clear-num99.0%
un-div-inv99.0%
Applied egg-rr99.0%
associate-/r/99.1%
Simplified99.1%
Final simplification75.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.4e-27) (not (<= b 1050000.0))) (* r (tan b)) (/ b (/ (cos a) r))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.4e-27) || !(b <= 1050000.0)) {
tmp = r * tan(b);
} else {
tmp = b / (cos(a) / r);
}
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-27)) .or. (.not. (b <= 1050000.0d0))) then
tmp = r * tan(b)
else
tmp = b / (cos(a) / r)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2.4e-27) || !(b <= 1050000.0)) {
tmp = r * Math.tan(b);
} else {
tmp = b / (Math.cos(a) / r);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.4e-27) or not (b <= 1050000.0): tmp = r * math.tan(b) else: tmp = b / (math.cos(a) / r) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.4e-27) || !(b <= 1050000.0)) tmp = Float64(r * tan(b)); else tmp = Float64(b / Float64(cos(a) / r)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.4e-27) || ~((b <= 1050000.0))) tmp = r * tan(b); else tmp = b / (cos(a) / r); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.4e-27], N[Not[LessEqual[b, 1050000.0]], $MachinePrecision]], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(b / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-27} \lor \neg \left(b \leq 1050000\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{\cos a}{r}}\\
\end{array}
\end{array}
if b < -2.40000000000000002e-27 or 1.05e6 < b Initial program 52.6%
associate-/l*52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in a around 0 51.4%
clear-num51.4%
associate-/r/51.4%
clear-num51.4%
quot-tan51.6%
Applied egg-rr51.6%
if -2.40000000000000002e-27 < b < 1.05e6Initial program 99.1%
associate-/l*99.0%
remove-double-neg99.0%
sin-neg99.0%
neg-mul-199.0%
associate-/r*99.0%
associate-/l*99.1%
*-commutative99.1%
associate-*l/99.1%
associate-/l*99.1%
sin-neg99.1%
distribute-lft-neg-in99.1%
distribute-rgt-neg-in99.1%
associate-/l*99.1%
metadata-eval99.1%
/-rgt-identity99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in b around 0 99.0%
associate-/l*99.1%
Simplified99.1%
Final simplification75.1%
(FPCore (r a b) :precision binary64 (if (<= b -2.4e-27) (* r (tan b)) (if (<= b 1050000.0) (/ b (/ (cos a) r)) (/ r (/ 1.0 (tan b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.4e-27) {
tmp = r * tan(b);
} else if (b <= 1050000.0) {
tmp = b / (cos(a) / r);
} else {
tmp = r / (1.0 / 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.4d-27)) then
tmp = r * tan(b)
else if (b <= 1050000.0d0) then
tmp = b / (cos(a) / r)
else
tmp = r / (1.0d0 / tan(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.4e-27) {
tmp = r * Math.tan(b);
} else if (b <= 1050000.0) {
tmp = b / (Math.cos(a) / r);
} else {
tmp = r / (1.0 / Math.tan(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.4e-27: tmp = r * math.tan(b) elif b <= 1050000.0: tmp = b / (math.cos(a) / r) else: tmp = r / (1.0 / math.tan(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.4e-27) tmp = Float64(r * tan(b)); elseif (b <= 1050000.0) tmp = Float64(b / Float64(cos(a) / r)); else tmp = Float64(r / Float64(1.0 / tan(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.4e-27) tmp = r * tan(b); elseif (b <= 1050000.0) tmp = b / (cos(a) / r); else tmp = r / (1.0 / tan(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.4e-27], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1050000.0], N[(b / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-27}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 1050000:\\
\;\;\;\;\frac{b}{\frac{\cos a}{r}}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{1}{\tan b}}\\
\end{array}
\end{array}
if b < -2.40000000000000002e-27Initial program 55.0%
associate-/l*55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in a around 0 52.9%
clear-num52.9%
associate-/r/52.9%
clear-num53.0%
quot-tan53.1%
Applied egg-rr53.1%
if -2.40000000000000002e-27 < b < 1.05e6Initial program 99.1%
associate-/l*99.0%
remove-double-neg99.0%
sin-neg99.0%
neg-mul-199.0%
associate-/r*99.0%
associate-/l*99.1%
*-commutative99.1%
associate-*l/99.1%
associate-/l*99.1%
sin-neg99.1%
distribute-lft-neg-in99.1%
distribute-rgt-neg-in99.1%
associate-/l*99.1%
metadata-eval99.1%
/-rgt-identity99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in b around 0 99.0%
associate-/l*99.1%
Simplified99.1%
if 1.05e6 < b Initial program 50.1%
associate-/l*50.1%
+-commutative50.1%
Simplified50.1%
Taylor expanded in a around 0 49.9%
expm1-log1p-u43.9%
expm1-udef43.7%
clear-num43.7%
quot-tan43.8%
Applied egg-rr43.8%
expm1-def44.0%
expm1-log1p50.0%
Simplified50.0%
Final simplification75.1%
(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.6%
associate-/l*75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in a around 0 57.1%
clear-num56.5%
associate-/r/57.1%
clear-num57.1%
quot-tan57.2%
Applied egg-rr57.2%
Final simplification57.2%
(FPCore (r a b) :precision binary64 (/ r (+ (* b -0.3333333333333333) (/ 1.0 b))))
double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / 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 * (-0.3333333333333333d0)) + (1.0d0 / b))
end function
public static double code(double r, double a, double b) {
return r / ((b * -0.3333333333333333) + (1.0 / b));
}
def code(r, a, b): return r / ((b * -0.3333333333333333) + (1.0 / b))
function code(r, a, b) return Float64(r / Float64(Float64(b * -0.3333333333333333) + Float64(1.0 / b))) end
function tmp = code(r, a, b) tmp = r / ((b * -0.3333333333333333) + (1.0 / b)); end
code[r_, a_, b_] := N[(r / N[(N[(b * -0.3333333333333333), $MachinePrecision] + N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{b \cdot -0.3333333333333333 + \frac{1}{b}}
\end{array}
Initial program 75.6%
associate-/l*75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in a around 0 57.1%
Taylor expanded in b around 0 34.0%
Final simplification34.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.6%
associate-/l*75.6%
remove-double-neg75.6%
sin-neg75.6%
neg-mul-175.6%
associate-/r*75.6%
associate-/l*75.6%
*-commutative75.6%
associate-*l/75.7%
associate-/l*75.7%
sin-neg75.7%
distribute-lft-neg-in75.7%
distribute-rgt-neg-in75.7%
associate-/l*75.7%
metadata-eval75.7%
/-rgt-identity75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in b around 0 51.8%
Taylor expanded in a around 0 33.9%
Final simplification33.9%
herbie shell --seed 2024027
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))