
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (cos (+ a b))))
double code(double r, double a, double b) {
return (r * sin(b)) / cos((a + b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / cos((a + b))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / Math.cos((a + b));
}
def code(r, a, b): return (r * math.sin(b)) / math.cos((a + b))
function code(r, a, b) return Float64(Float64(r * sin(b)) / cos(Float64(a + b))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / cos((a + b)); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(a + b\right)}
\end{array}
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (cos b) (cos a) (* (sin b) (- (sin a))))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(cos(b), cos(a), (sin(b) * -sin(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(cos(b), cos(a), Float64(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 76.1%
+-commutative76.1%
Simplified76.1%
cos-sum99.6%
cancel-sign-sub-inv99.6%
fma-def99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (/ r (/ (- (* (cos b) (cos a)) (* (sin b) (sin a))) (sin b))))
double code(double r, double a, double b) {
return r / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / sin(b));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / sin(b))
end function
public static double code(double r, double a, double b) {
return r / (((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))) / Math.sin(b));
}
def code(r, a, b): return r / (((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))) / math.sin(b))
function code(r, a, b) return Float64(r / Float64(Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))) / sin(b))) end
function tmp = code(r, a, b) tmp = r / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / sin(b)); end
code[r_, a_, b_] := N[(r / N[(N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos b \cdot \cos a - \sin b \cdot \sin a}{\sin b}}
\end{array}
Initial program 76.1%
+-commutative76.1%
Simplified76.1%
cos-sum99.6%
cancel-sign-sub-inv99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in r around 0 99.6%
associate-/l*99.4%
neg-mul-199.4%
+-commutative99.4%
sub-neg99.4%
*-commutative99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (sin b) (/ (- (* (cos b) (cos a)) (* (sin b) (sin a))) r)))
double code(double r, double a, double b) {
return sin(b) / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / 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(b) * cos(a)) - (sin(b) * sin(a))) / r)
end function
public static double code(double r, double a, double b) {
return Math.sin(b) / (((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))) / r);
}
def code(r, a, b): return math.sin(b) / (((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))) / r)
function code(r, a, b) return Float64(sin(b) / Float64(Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a))) / r)) end
function tmp = code(r, a, b) tmp = sin(b) / (((cos(b) * cos(a)) - (sin(b) * sin(a))) / r); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] / N[(N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\frac{\cos b \cdot \cos a - \sin b \cdot \sin a}{r}}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (- (* (cos b) (cos a)) (* (sin b) (sin a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a)))
end function
public static double code(double r, double a, double b) {
return (r * Math.sin(b)) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(b) * sin(a)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(b) * sin(a))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 76.1%
+-commutative76.1%
Simplified76.1%
cos-sum99.5%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -4.8e-5) (not (<= b 1.65e-44))) (* (sin b) (/ r (cos b))) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8e-5) || !(b <= 1.65e-44)) {
tmp = sin(b) * (r / cos(b));
} else {
tmp = (r * b) / cos((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 ((b <= (-4.8d-5)) .or. (.not. (b <= 1.65d-44))) then
tmp = sin(b) * (r / cos(b))
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -4.8e-5) || !(b <= 1.65e-44)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -4.8e-5) or not (b <= 1.65e-44): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -4.8e-5) || !(b <= 1.65e-44)) tmp = Float64(sin(b) * Float64(r / cos(b))); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -4.8e-5) || ~((b <= 1.65e-44))) tmp = sin(b) * (r / cos(b)); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -4.8e-5], N[Not[LessEqual[b, 1.65e-44]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{-5} \lor \neg \left(b \leq 1.65 \cdot 10^{-44}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -4.8000000000000001e-5 or 1.65000000000000003e-44 < b Initial program 54.5%
*-commutative54.5%
associate-/l*54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in a around 0 54.8%
associate-/l*54.7%
associate-/r/54.7%
Simplified54.7%
if -4.8000000000000001e-5 < b < 1.65000000000000003e-44Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.4%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (<= b -7e-5) (/ (sin b) (/ (cos b) r)) (if (<= b 1.65e-44) (/ (* r b) (cos (+ b a))) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -7e-5) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 1.65e-44) {
tmp = (r * b) / cos((b + a));
} else {
tmp = sin(b) * (r / cos(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 <= (-7d-5)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 1.65d-44) then
tmp = (r * b) / cos((b + a))
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -7e-5) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 1.65e-44) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -7e-5: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 1.65e-44: tmp = (r * b) / math.cos((b + a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -7e-5) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 1.65e-44) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -7e-5) tmp = sin(b) / (cos(b) / r); elseif (b <= 1.65e-44) tmp = (r * b) / cos((b + a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -7e-5], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-44], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-44}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -6.9999999999999994e-5Initial program 56.4%
*-commutative56.4%
associate-/l*56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in a around 0 55.9%
if -6.9999999999999994e-5 < b < 1.65000000000000003e-44Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.4%
if 1.65000000000000003e-44 < b Initial program 52.8%
*-commutative52.8%
associate-/l*52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in a around 0 53.7%
associate-/l*53.7%
associate-/r/53.8%
Simplified53.8%
Final simplification76.2%
(FPCore (r a b) :precision binary64 (if (<= b -3.1e-5) (/ (* r (sin b)) (cos b)) (if (<= b 1.65e-44) (/ (* r b) (cos (+ b a))) (* (sin b) (/ r (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -3.1e-5) {
tmp = (r * sin(b)) / cos(b);
} else if (b <= 1.65e-44) {
tmp = (r * b) / cos((b + a));
} else {
tmp = sin(b) * (r / cos(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 <= (-3.1d-5)) then
tmp = (r * sin(b)) / cos(b)
else if (b <= 1.65d-44) then
tmp = (r * b) / cos((b + a))
else
tmp = sin(b) * (r / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -3.1e-5) {
tmp = (r * Math.sin(b)) / Math.cos(b);
} else if (b <= 1.65e-44) {
tmp = (r * b) / Math.cos((b + a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -3.1e-5: tmp = (r * math.sin(b)) / math.cos(b) elif b <= 1.65e-44: tmp = (r * b) / math.cos((b + a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -3.1e-5) tmp = Float64(Float64(r * sin(b)) / cos(b)); elseif (b <= 1.65e-44) tmp = Float64(Float64(r * b) / cos(Float64(b + a))); else tmp = Float64(sin(b) * Float64(r / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -3.1e-5) tmp = (r * sin(b)) / cos(b); elseif (b <= 1.65e-44) tmp = (r * b) / cos((b + a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -3.1e-5], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-44], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.1 \cdot 10^{-5}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos b}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-44}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if b < -3.10000000000000014e-5Initial program 56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in a around 0 56.0%
if -3.10000000000000014e-5 < b < 1.65000000000000003e-44Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.4%
if 1.65000000000000003e-44 < b Initial program 52.8%
*-commutative52.8%
associate-/l*52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in a around 0 53.7%
associate-/l*53.7%
associate-/r/53.8%
Simplified53.8%
Final simplification76.2%
(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 76.1%
*-commutative76.1%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
clear-num75.4%
associate-/r/75.9%
clear-num76.0%
Applied egg-rr76.0%
Final simplification76.0%
(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 76.1%
*-commutative76.1%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
associate-/r/76.1%
Applied egg-rr76.1%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos a))))
double code(double r, double a, double b) {
return sin(b) * (r / 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(a))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos(a));
}
def code(r, a, b): return math.sin(b) * (r / math.cos(a))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos(a)); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos a}
\end{array}
Initial program 76.1%
+-commutative76.1%
Simplified76.1%
Taylor expanded in b around 0 55.0%
associate-/l*54.9%
associate-/r/55.0%
Applied egg-rr55.0%
Final simplification55.0%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.8e+15) (not (<= b 25000.0))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.8e+15) || !(b <= 25000.0)) {
tmp = r * sin(b);
} else {
tmp = b * (r / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2.8d+15)) .or. (.not. (b <= 25000.0d0))) then
tmp = r * sin(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2.8e+15) || !(b <= 25000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.8e+15) or not (b <= 25000.0): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.8e+15) || !(b <= 25000.0)) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.8e+15) || ~((b <= 25000.0))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.8e+15], N[Not[LessEqual[b, 25000.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+15} \lor \neg \left(b \leq 25000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -2.8e15 or 25000 < b Initial program 53.9%
+-commutative53.9%
Simplified53.9%
Taylor expanded in b around 0 12.1%
Taylor expanded in a around 0 12.5%
*-commutative12.5%
Simplified12.5%
if -2.8e15 < b < 25000Initial program 97.2%
*-commutative97.2%
associate-/l*97.1%
+-commutative97.1%
Simplified97.1%
cos-sum99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.6%
Taylor expanded in b around 0 96.2%
associate-*r/96.2%
Simplified96.2%
Final simplification55.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.8e+15) (not (<= b 160.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.8e+15) || !(b <= 160.0)) {
tmp = r * sin(b);
} else {
tmp = r * (b / cos(a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2.8d+15)) .or. (.not. (b <= 160.0d0))) then
tmp = r * sin(b)
else
tmp = r * (b / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2.8e+15) || !(b <= 160.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.8e+15) or not (b <= 160.0): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.8e+15) || !(b <= 160.0)) tmp = Float64(r * sin(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 <= -2.8e+15) || ~((b <= 160.0))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.8e+15], N[Not[LessEqual[b, 160.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+15} \lor \neg \left(b \leq 160\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -2.8e15 or 160 < b Initial program 53.9%
+-commutative53.9%
Simplified53.9%
Taylor expanded in b around 0 12.1%
Taylor expanded in a around 0 12.5%
*-commutative12.5%
Simplified12.5%
if -2.8e15 < b < 160Initial program 97.2%
*-commutative97.2%
associate-/l*97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 96.2%
associate-/l*96.1%
associate-/r/96.2%
Simplified96.2%
Final simplification55.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.8e+15) (not (<= b 160.0))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.8e+15) || !(b <= 160.0)) {
tmp = r * sin(b);
} else {
tmp = (r * b) / cos(a);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-2.8d+15)) .or. (.not. (b <= 160.0d0))) then
tmp = r * sin(b)
else
tmp = (r * b) / cos(a)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -2.8e+15) || !(b <= 160.0)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -2.8e+15) or not (b <= 160.0): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -2.8e+15) || !(b <= 160.0)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -2.8e+15) || ~((b <= 160.0))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -2.8e+15], N[Not[LessEqual[b, 160.0]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+15} \lor \neg \left(b \leq 160\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -2.8e15 or 160 < b Initial program 53.9%
+-commutative53.9%
Simplified53.9%
Taylor expanded in b around 0 12.1%
Taylor expanded in a around 0 12.5%
*-commutative12.5%
Simplified12.5%
if -2.8e15 < b < 160Initial program 97.2%
*-commutative97.2%
associate-/l*97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 96.2%
Final simplification55.3%
(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 76.1%
+-commutative76.1%
Simplified76.1%
Taylor expanded in b around 0 55.0%
Taylor expanded in a around 0 39.7%
*-commutative39.7%
Simplified39.7%
Final simplification39.7%
(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 76.1%
*-commutative76.1%
associate-/l*76.0%
+-commutative76.0%
Simplified76.0%
Taylor expanded in b around 0 51.2%
associate-/l*51.1%
associate-/r/51.1%
Simplified51.1%
Taylor expanded in a around 0 35.8%
*-commutative35.8%
Simplified35.8%
Final simplification35.8%
herbie shell --seed 2023293
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))