
(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 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(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 a) (- (sin b))))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (sin(a) * -sin(b)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(sin(a) * Float64(-sin(b))))) 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[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(\cos b, \cos a, \sin a \cdot \left(-\sin b\right)\right)}
\end{array}
Initial program 74.5%
+-commutative74.5%
Simplified74.5%
cos-sum99.5%
fma-neg99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((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 = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(b) * cos(a)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / 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}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 74.5%
associate-/l*74.4%
+-commutative74.4%
Simplified74.4%
associate-/r/74.6%
Applied egg-rr74.6%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return sin(b) * (r / (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 = sin(b) * (r / (cos(b) * cos(a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / (Math.cos(b) * Math.cos(a)));
}
def code(r, a, b): return math.sin(b) * (r / (math.cos(b) * math.cos(a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(cos(b) * cos(a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / (cos(b) * cos(a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos b \cdot \cos a}
\end{array}
Initial program 74.5%
associate-/l*74.4%
+-commutative74.4%
Simplified74.4%
associate-/r/74.6%
Applied egg-rr74.6%
cos-sum99.5%
Applied egg-rr99.5%
sin-mult75.8%
cos-sum76.7%
div-sub76.7%
sub-neg76.7%
add-sqr-sqrt40.0%
sqrt-unprod75.9%
sqr-neg75.9%
sqrt-unprod45.7%
add-sqr-sqrt75.2%
cos-diff75.9%
Applied egg-rr75.9%
+-inverses75.9%
Simplified75.9%
Final simplification75.9%
(FPCore (r a b) :precision binary64 (if (or (<= a -5.6e-5) (not (<= a 0.000112))) (* (sin b) (/ r (cos a))) (* r (tan b))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -5.6e-5) || !(a <= 0.000112)) {
tmp = sin(b) * (r / 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 <= (-5.6d-5)) .or. (.not. (a <= 0.000112d0))) then
tmp = sin(b) * (r / 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 <= -5.6e-5) || !(a <= 0.000112)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = r * Math.tan(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -5.6e-5) or not (a <= 0.000112): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = r * math.tan(b) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -5.6e-5) || !(a <= 0.000112)) tmp = Float64(sin(b) * Float64(r / cos(a))); else tmp = Float64(r * tan(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -5.6e-5) || ~((a <= 0.000112))) tmp = sin(b) * (r / cos(a)); else tmp = r * tan(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -5.6e-5], N[Not[LessEqual[a, 0.000112]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.6 \cdot 10^{-5} \lor \neg \left(a \leq 0.000112\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \tan b\\
\end{array}
\end{array}
if a < -5.59999999999999992e-5 or 1.11999999999999998e-4 < a Initial program 50.6%
associate-/l*50.6%
+-commutative50.6%
Simplified50.6%
associate-/r/50.6%
Applied egg-rr50.6%
Taylor expanded in b around 0 51.4%
if -5.59999999999999992e-5 < a < 1.11999999999999998e-4Initial program 99.2%
associate-/l*99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.1%
expm1-log1p-u82.8%
expm1-udef31.8%
clear-num31.8%
quot-tan31.8%
Applied egg-rr31.8%
expm1-def82.8%
expm1-log1p99.0%
associate-/r/99.3%
/-rgt-identity99.3%
Simplified99.3%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= a -4.6e-5) (* (sin b) (/ r (cos a))) (if (<= a 0.0048) (* r (tan b)) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -4.6e-5) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 0.0048) {
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 <= (-4.6d-5)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 0.0048d0) 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 <= -4.6e-5) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 0.0048) {
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 <= -4.6e-5: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 0.0048: 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 <= -4.6e-5) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 0.0048) 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 <= -4.6e-5) tmp = sin(b) * (r / cos(a)); elseif (a <= 0.0048) tmp = r * tan(b); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -4.6e-5], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.0048], 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 -4.6 \cdot 10^{-5}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 0.0048:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -4.6e-5Initial program 41.7%
associate-/l*41.7%
+-commutative41.7%
Simplified41.7%
associate-/r/41.8%
Applied egg-rr41.8%
Taylor expanded in b around 0 42.7%
if -4.6e-5 < a < 0.00479999999999999958Initial program 99.2%
associate-/l*99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.1%
expm1-log1p-u82.8%
expm1-udef31.8%
clear-num31.8%
quot-tan31.8%
Applied egg-rr31.8%
expm1-def82.8%
expm1-log1p99.0%
associate-/r/99.3%
/-rgt-identity99.3%
Simplified99.3%
if 0.00479999999999999958 < a Initial program 58.5%
associate-/l*58.5%
remove-double-neg58.5%
sin-neg58.5%
neg-mul-158.5%
associate-/r*58.5%
associate-/l*58.5%
*-commutative58.5%
associate-*l/58.5%
associate-/l*58.5%
sin-neg58.5%
distribute-lft-neg-in58.5%
distribute-rgt-neg-in58.5%
associate-/l*58.5%
metadata-eval58.5%
/-rgt-identity58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 59.1%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= a -0.000195) (* (sin b) (/ r (cos a))) (if (<= a 0.00011) (* r (tan b)) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.000195) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 0.00011) {
tmp = r * tan(b);
} else {
tmp = r / (cos(a) / sin(b));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.000195d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 0.00011d0) then
tmp = r * tan(b)
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -0.000195) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 0.00011) {
tmp = r * Math.tan(b);
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -0.000195: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 0.00011: tmp = r * math.tan(b) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -0.000195) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 0.00011) tmp = Float64(r * tan(b)); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.000195) tmp = sin(b) * (r / cos(a)); elseif (a <= 0.00011) tmp = r * tan(b); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.000195], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.00011], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000195:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 0.00011:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -1.94999999999999996e-4Initial program 41.7%
associate-/l*41.7%
+-commutative41.7%
Simplified41.7%
associate-/r/41.8%
Applied egg-rr41.8%
Taylor expanded in b around 0 42.7%
if -1.94999999999999996e-4 < a < 1.10000000000000004e-4Initial program 99.2%
associate-/l*99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.1%
expm1-log1p-u82.8%
expm1-udef31.8%
clear-num31.8%
quot-tan31.8%
Applied egg-rr31.8%
expm1-def82.8%
expm1-log1p99.0%
associate-/r/99.3%
/-rgt-identity99.3%
Simplified99.3%
if 1.10000000000000004e-4 < a Initial program 58.5%
associate-/l*58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 59.1%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= a -0.00052) (* (sin b) (/ r (cos a))) (if (<= a 0.000115) (* r (tan b)) (/ (* r (sin b)) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00052) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 0.000115) {
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 <= (-0.00052d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 0.000115d0) 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 <= -0.00052) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 0.000115) {
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 <= -0.00052: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 0.000115: 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 <= -0.00052) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 0.000115) tmp = Float64(r * tan(b)); else tmp = Float64(Float64(r * sin(b)) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -0.00052) tmp = sin(b) * (r / cos(a)); elseif (a <= 0.000115) tmp = r * tan(b); else tmp = (r * sin(b)) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -0.00052], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.000115], N[(r * N[Tan[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00052:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 0.000115:\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\end{array}
\end{array}
if a < -5.19999999999999954e-4Initial program 41.7%
associate-/l*41.7%
+-commutative41.7%
Simplified41.7%
associate-/r/41.8%
Applied egg-rr41.8%
Taylor expanded in b around 0 42.7%
if -5.19999999999999954e-4 < a < 1.15e-4Initial program 99.2%
associate-/l*99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.1%
expm1-log1p-u82.8%
expm1-udef31.8%
clear-num31.8%
quot-tan31.8%
Applied egg-rr31.8%
expm1-def82.8%
expm1-log1p99.0%
associate-/r/99.3%
/-rgt-identity99.3%
Simplified99.3%
if 1.15e-4 < a Initial program 58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 59.1%
Final simplification75.0%
(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 74.5%
associate-/l*74.4%
+-commutative74.4%
Simplified74.4%
associate-/r/74.6%
Applied egg-rr74.6%
Final simplification74.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.00049) (not (<= b 2.8e-32))) (* r (tan b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.00049) || !(b <= 2.8e-32)) {
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.00049d0)) .or. (.not. (b <= 2.8d-32))) 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.00049) || !(b <= 2.8e-32)) {
tmp = r * Math.tan(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.00049) or not (b <= 2.8e-32): 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.00049) || !(b <= 2.8e-32)) 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.00049) || ~((b <= 2.8e-32))) tmp = r * tan(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.00049], N[Not[LessEqual[b, 2.8e-32]], $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.00049 \lor \neg \left(b \leq 2.8 \cdot 10^{-32}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.8999999999999998e-4 or 2.7999999999999999e-32 < b Initial program 52.6%
associate-/l*52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in a around 0 52.5%
expm1-log1p-u38.9%
expm1-udef14.3%
clear-num14.3%
quot-tan14.3%
Applied egg-rr14.3%
expm1-def38.8%
expm1-log1p52.5%
associate-/r/52.6%
/-rgt-identity52.6%
Simplified52.6%
if -4.8999999999999998e-4 < b < 2.7999999999999999e-32Initial program 99.0%
associate-/l*98.8%
remove-double-neg98.8%
sin-neg98.8%
neg-mul-198.8%
associate-/r*98.8%
associate-/l*99.0%
*-commutative99.0%
associate-*l/99.0%
associate-/l*99.0%
sin-neg99.0%
distribute-lft-neg-in99.0%
distribute-rgt-neg-in99.0%
associate-/l*99.0%
metadata-eval99.0%
/-rgt-identity99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in b around 0 99.0%
Final simplification74.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -5e-6) (not (<= b 2.8e-32))) (* r (tan b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5e-6) || !(b <= 2.8e-32)) {
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 <= (-5d-6)) .or. (.not. (b <= 2.8d-32))) 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 <= -5e-6) || !(b <= 2.8e-32)) {
tmp = r * Math.tan(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5e-6) or not (b <= 2.8e-32): tmp = r * math.tan(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -5e-6) || !(b <= 2.8e-32)) 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 <= -5e-6) || ~((b <= 2.8e-32))) tmp = r * tan(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5e-6], N[Not[LessEqual[b, 2.8e-32]], $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 -5 \cdot 10^{-6} \lor \neg \left(b \leq 2.8 \cdot 10^{-32}\right):\\
\;\;\;\;r \cdot \tan b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -5.00000000000000041e-6 or 2.7999999999999999e-32 < b Initial program 52.6%
associate-/l*52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in a around 0 52.5%
expm1-log1p-u38.9%
expm1-udef14.3%
clear-num14.3%
quot-tan14.3%
Applied egg-rr14.3%
expm1-def38.8%
expm1-log1p52.5%
associate-/r/52.6%
/-rgt-identity52.6%
Simplified52.6%
if -5.00000000000000041e-6 < b < 2.7999999999999999e-32Initial program 99.0%
+-commutative99.0%
Simplified99.0%
cos-sum99.8%
fma-neg99.8%
Applied egg-rr99.8%
Taylor expanded in b around 0 99.0%
*-commutative99.0%
associate-/l*98.8%
associate-/r/99.0%
Simplified99.0%
Final simplification74.5%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * 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 * sin(b)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 74.5%
associate-/l*74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in b around 0 53.6%
mul-1-neg53.6%
unsub-neg53.6%
Simplified53.6%
Taylor expanded in a around 0 38.9%
Final simplification38.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 74.5%
associate-/l*74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in a around 0 58.2%
expm1-log1p-u49.3%
expm1-udef22.7%
clear-num22.7%
quot-tan22.7%
Applied egg-rr22.7%
expm1-def49.3%
expm1-log1p58.2%
associate-/r/58.3%
/-rgt-identity58.3%
Simplified58.3%
Final simplification58.3%
(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 74.5%
associate-/l*74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in a around 0 58.2%
Taylor expanded in b around 0 36.3%
Final simplification36.3%
(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 74.5%
associate-/l*74.4%
remove-double-neg74.4%
sin-neg74.4%
neg-mul-174.4%
associate-/r*74.4%
associate-/l*74.5%
*-commutative74.5%
associate-*l/74.5%
associate-/l*74.5%
sin-neg74.5%
distribute-lft-neg-in74.5%
distribute-rgt-neg-in74.5%
associate-/l*74.5%
metadata-eval74.5%
/-rgt-identity74.5%
+-commutative74.5%
Simplified74.5%
Taylor expanded in b around 0 51.8%
Taylor expanded in a around 0 35.3%
*-commutative35.3%
Simplified35.3%
Final simplification35.3%
herbie shell --seed 2024020
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))