
(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}
Sampling outcomes in binary64 precision:
Herbie found 14 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(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}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (sin b) (- (sin a)) (* (cos a) (cos b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(sin(b), -sin(a), (cos(a) * cos(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 77.4%
associate-*r/77.5%
+-commutative77.5%
Simplified77.5%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-rgt-neg-in99.5%
fma-define99.5%
*-commutative99.5%
Simplified99.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 77.4%
associate-*r/77.5%
+-commutative77.5%
Simplified77.5%
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) (fma (cos b) (cos a) (* (sin b) (- (sin a)))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), (sin(b) * -sin(a))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), Float64(sin(b) * Float64(-sin(a)))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin b \cdot \left(-\sin a\right)\right)}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
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 a) (cos b)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(a) * cos(b)) - (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(a) * cos(b)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(a) * cos(b)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
associate-*r/77.5%
+-commutative77.5%
Simplified77.5%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (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(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (<= a -8e-6) (/ r (/ (cos a) (sin b))) (if (<= a 2.6e-7) (* r (tan b)) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -8e-6) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 2.6e-7) {
tmp = r * tan(b);
} else {
tmp = r * (sin(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 (a <= (-8d-6)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 2.6d-7) then
tmp = r * tan(b)
else
tmp = r * (sin(b) / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -8e-6) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 2.6e-7) {
tmp = r * Math.tan(b);
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -8e-6: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 2.6e-7: tmp = r * math.tan(b) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -8e-6) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 2.6e-7) tmp = Float64(r * tan(b)); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -8e-6) tmp = r / (cos(a) / sin(b)); elseif (a <= 2.6e-7) tmp = r * tan(b); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -8e-6], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.6e-7], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 2.6 \cdot 10^{-7}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -7.99999999999999964e-6Initial program 53.0%
+-commutative53.0%
Simplified53.0%
clear-num53.0%
un-div-inv53.1%
Applied egg-rr53.1%
Taylor expanded in b around 0 51.2%
if -7.99999999999999964e-6 < a < 2.59999999999999999e-7Initial program 99.6%
+-commutative99.6%
Simplified99.6%
clear-num99.5%
un-div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in a around 0 99.6%
div-inv99.5%
clear-num99.6%
quot-tan99.8%
Applied egg-rr99.8%
if 2.59999999999999999e-7 < a Initial program 58.0%
+-commutative58.0%
Simplified58.0%
Taylor expanded in b around 0 57.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(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 77.4%
associate-*r/77.5%
+-commutative77.5%
Simplified77.5%
(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 77.4%
associate-*r/77.5%
+-commutative77.5%
Simplified77.5%
*-commutative77.5%
associate-/l*77.4%
Applied egg-rr77.4%
(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 77.4%
Final simplification77.4%
(FPCore (r a b) :precision binary64 (if (<= b -8.8e-5) (* r (tan b)) (if (<= b 7.1e-6) (* r (/ b (cos (+ b a)))) (/ r (/ 1.0 (tan b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -8.8e-5) {
tmp = r * tan(b);
} else if (b <= 7.1e-6) {
tmp = r * (b / cos((b + a)));
} 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 <= (-8.8d-5)) then
tmp = r * tan(b)
else if (b <= 7.1d-6) then
tmp = r * (b / cos((b + a)))
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 <= -8.8e-5) {
tmp = r * Math.tan(b);
} else if (b <= 7.1e-6) {
tmp = r * (b / Math.cos((b + a)));
} else {
tmp = r / (1.0 / Math.tan(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -8.8e-5: tmp = r * math.tan(b) elif b <= 7.1e-6: tmp = r * (b / math.cos((b + a))) else: tmp = r / (1.0 / math.tan(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -8.8e-5) tmp = Float64(r * tan(b)); elseif (b <= 7.1e-6) tmp = Float64(r * Float64(b / cos(Float64(b + a)))); 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 <= -8.8e-5) tmp = r * tan(b); elseif (b <= 7.1e-6) tmp = r * (b / cos((b + a))); else tmp = r / (1.0 / tan(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -8.8e-5], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.1e-6], N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.8 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 7.1 \cdot 10^{-6}:\\
\;\;\;\;r \cdot \frac{b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{1}{\tan b}}\\
\end{array}
\end{array}
if b < -8.7999999999999998e-5Initial program 56.2%
+-commutative56.2%
Simplified56.2%
clear-num56.1%
un-div-inv56.3%
Applied egg-rr56.3%
Taylor expanded in a around 0 55.3%
div-inv55.2%
clear-num55.3%
quot-tan55.3%
Applied egg-rr55.3%
if -8.7999999999999998e-5 < b < 7.0999999999999998e-6Initial program 99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 98.7%
if 7.0999999999999998e-6 < b Initial program 54.9%
+-commutative54.9%
Simplified54.9%
clear-num54.9%
un-div-inv55.1%
Applied egg-rr55.1%
Taylor expanded in a around 0 54.2%
add-cube-cbrt53.3%
*-un-lft-identity53.3%
times-frac53.3%
pow253.3%
clear-num53.3%
quot-tan53.4%
Applied egg-rr53.4%
/-rgt-identity53.4%
associate-*r/53.4%
unpow253.4%
rem-3cbrt-lft54.3%
Simplified54.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -6e-5) (not (<= b 7e-6))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -6e-5) || !(b <= 7e-6)) {
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 <= (-6d-5)) .or. (.not. (b <= 7d-6))) 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 <= -6e-5) || !(b <= 7e-6)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -6e-5) or not (b <= 7e-6): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -6e-5) || !(b <= 7e-6)) 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 <= -6e-5) || ~((b <= 7e-6))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -6e-5], N[Not[LessEqual[b, 7e-6]], $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 -6 \cdot 10^{-5} \lor \neg \left(b \leq 7 \cdot 10^{-6}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -6.00000000000000015e-5 or 6.99999999999999989e-6 < b Initial program 55.5%
+-commutative55.5%
Simplified55.5%
clear-num55.5%
un-div-inv55.6%
Applied egg-rr55.6%
Taylor expanded in a around 0 54.7%
div-inv54.5%
clear-num54.6%
quot-tan54.8%
Applied egg-rr54.8%
if -6.00000000000000015e-5 < b < 6.99999999999999989e-6Initial program 99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 98.6%
associate-/l*98.6%
Simplified98.6%
Final simplification76.8%
(FPCore (r a b) :precision binary64 (if (<= b -5.8e-5) (* r (tan b)) (if (<= b 6.1e-6) (* b (/ r (cos a))) (/ r (/ 1.0 (tan b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -5.8e-5) {
tmp = r * tan(b);
} else if (b <= 6.1e-6) {
tmp = b * (r / cos(a));
} 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 <= (-5.8d-5)) then
tmp = r * tan(b)
else if (b <= 6.1d-6) then
tmp = b * (r / cos(a))
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 <= -5.8e-5) {
tmp = r * Math.tan(b);
} else if (b <= 6.1e-6) {
tmp = b * (r / Math.cos(a));
} else {
tmp = r / (1.0 / Math.tan(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -5.8e-5: tmp = r * math.tan(b) elif b <= 6.1e-6: tmp = b * (r / math.cos(a)) else: tmp = r / (1.0 / math.tan(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -5.8e-5) tmp = Float64(r * tan(b)); elseif (b <= 6.1e-6) tmp = Float64(b * Float64(r / cos(a))); 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 <= -5.8e-5) tmp = r * tan(b); elseif (b <= 6.1e-6) tmp = b * (r / cos(a)); else tmp = r / (1.0 / tan(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -5.8e-5], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.1e-6], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(1.0 / N[Tan[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.8 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{elif}\;b \leq 6.1 \cdot 10^{-6}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{1}{\tan b}}\\
\end{array}
\end{array}
if b < -5.8e-5Initial program 56.2%
+-commutative56.2%
Simplified56.2%
clear-num56.1%
un-div-inv56.3%
Applied egg-rr56.3%
Taylor expanded in a around 0 55.3%
div-inv55.2%
clear-num55.3%
quot-tan55.3%
Applied egg-rr55.3%
if -5.8e-5 < b < 6.10000000000000004e-6Initial program 99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 98.6%
associate-/l*98.6%
Simplified98.6%
if 6.10000000000000004e-6 < b Initial program 54.9%
+-commutative54.9%
Simplified54.9%
clear-num54.9%
un-div-inv55.1%
Applied egg-rr55.1%
Taylor expanded in a around 0 54.2%
add-cube-cbrt53.3%
*-un-lft-identity53.3%
times-frac53.3%
pow253.3%
clear-num53.3%
quot-tan53.4%
Applied egg-rr53.4%
/-rgt-identity53.4%
associate-*r/53.4%
unpow253.4%
rem-3cbrt-lft54.3%
Simplified54.3%
(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 77.4%
+-commutative77.4%
Simplified77.4%
clear-num77.3%
un-div-inv77.4%
Applied egg-rr77.4%
Taylor expanded in a around 0 60.8%
div-inv60.7%
clear-num60.8%
quot-tan60.9%
Applied egg-rr60.9%
(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 77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in b around 0 52.3%
associate-/l*52.3%
Simplified52.3%
Taylor expanded in a around 0 36.3%
*-commutative36.3%
Simplified36.3%
herbie shell --seed 2024155
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))