
(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 (* (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 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
associate-/r/77.8%
Applied egg-rr77.8%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (/ r (- (/ (cos a) (/ (sin b) (cos b))) (sin a))))
double code(double r, double a, double b) {
return r / ((cos(a) / (sin(b) / cos(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) / (sin(b) / cos(b))) - sin(a))
end function
public static double code(double r, double a, double b) {
return r / ((Math.cos(a) / (Math.sin(b) / Math.cos(b))) - Math.sin(a));
}
def code(r, a, b): return r / ((math.cos(a) / (math.sin(b) / math.cos(b))) - math.sin(a))
function code(r, a, b) return Float64(r / Float64(Float64(cos(a) / Float64(sin(b) / cos(b))) - sin(a))) end
function tmp = code(r, a, b) tmp = r / ((cos(a) / (sin(b) / cos(b))) - sin(a)); end
code[r_, a_, b_] := N[(r / N[(N[(N[Cos[a], $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{\cos a}{\frac{\sin b}{\cos b}} - \sin a}
\end{array}
Initial program 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-def99.5%
Applied egg-rr99.5%
distribute-lft-neg-out99.5%
fma-neg99.5%
prod-diff99.5%
Applied egg-rr99.5%
prod-diff99.5%
*-commutative99.5%
div-sub99.5%
Applied egg-rr99.5%
*-commutative99.5%
associate-/l*99.4%
associate-/l*99.4%
*-inverses99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (if (or (<= a -6.5e-5) (not (<= a 2.8e-5))) (* (sin b) (/ r (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -6.5e-5) || !(a <= 2.8e-5)) {
tmp = sin(b) * (r / cos(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 ((a <= (-6.5d-5)) .or. (.not. (a <= 2.8d-5))) then
tmp = sin(b) * (r / cos(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 ((a <= -6.5e-5) || !(a <= 2.8e-5)) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -6.5e-5) or not (a <= 2.8e-5): tmp = math.sin(b) * (r / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -6.5e-5) || !(a <= 2.8e-5)) tmp = Float64(sin(b) * Float64(r / cos(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 ((a <= -6.5e-5) || ~((a <= 2.8e-5))) tmp = sin(b) * (r / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -6.5e-5], N[Not[LessEqual[a, 2.8e-5]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[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}\;a \leq -6.5 \cdot 10^{-5} \lor \neg \left(a \leq 2.8 \cdot 10^{-5}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -6.49999999999999943e-5 or 2.79999999999999996e-5 < a Initial program 56.7%
associate-/l*56.8%
+-commutative56.8%
Simplified56.8%
associate-/r/56.8%
Applied egg-rr56.8%
Taylor expanded in b around 0 58.2%
if -6.49999999999999943e-5 < a < 2.79999999999999996e-5Initial program 99.5%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in a around 0 99.5%
Final simplification78.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -6e-5) (not (<= a 0.00033))) (* r (/ (sin b) (cos a))) (* (sin b) (/ r (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -6e-5) || !(a <= 0.00033)) {
tmp = r * (sin(b) / cos(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 ((a <= (-6d-5)) .or. (.not. (a <= 0.00033d0))) then
tmp = r * (sin(b) / cos(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 ((a <= -6e-5) || !(a <= 0.00033)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = Math.sin(b) * (r / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -6e-5) or not (a <= 0.00033): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = math.sin(b) * (r / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -6e-5) || !(a <= 0.00033)) tmp = Float64(r * Float64(sin(b) / cos(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 ((a <= -6e-5) || ~((a <= 0.00033))) tmp = r * (sin(b) / cos(a)); else tmp = sin(b) * (r / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -6e-5], N[Not[LessEqual[a, 0.00033]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[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}\;a \leq -6 \cdot 10^{-5} \lor \neg \left(a \leq 0.00033\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\end{array}
\end{array}
if a < -6.00000000000000015e-5 or 3.3e-4 < a Initial program 56.7%
associate-*r/56.9%
*-commutative56.9%
+-commutative56.9%
Simplified56.9%
Taylor expanded in b around 0 58.2%
if -6.00000000000000015e-5 < a < 3.3e-4Initial program 99.5%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in a around 0 99.5%
Final simplification78.5%
(FPCore (r a b) :precision binary64 (if (<= a -5.9e-5) (* r (* (sin b) (/ 1.0 (cos a)))) (if (<= a 3.8e-5) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -5.9e-5) {
tmp = r * (sin(b) * (1.0 / cos(a)));
} else if (a <= 3.8e-5) {
tmp = sin(b) * (r / cos(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 <= (-5.9d-5)) then
tmp = r * (sin(b) * (1.0d0 / cos(a)))
else if (a <= 3.8d-5) then
tmp = sin(b) * (r / cos(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 <= -5.9e-5) {
tmp = r * (Math.sin(b) * (1.0 / Math.cos(a)));
} else if (a <= 3.8e-5) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -5.9e-5: tmp = r * (math.sin(b) * (1.0 / math.cos(a))) elif a <= 3.8e-5: tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -5.9e-5) tmp = Float64(r * Float64(sin(b) * Float64(1.0 / cos(a)))); elseif (a <= 3.8e-5) tmp = Float64(sin(b) * Float64(r / cos(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 <= -5.9e-5) tmp = r * (sin(b) * (1.0 / cos(a))); elseif (a <= 3.8e-5) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -5.9e-5], N[(r * N[(N[Sin[b], $MachinePrecision] * N[(1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.8e-5], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[b], $MachinePrecision]), $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 -5.9 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \left(\sin b \cdot \frac{1}{\cos a}\right)\\
\mathbf{elif}\;a \leq 3.8 \cdot 10^{-5}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -5.8999999999999998e-5Initial program 58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in b around 0 60.1%
div-inv60.1%
associate-*l*60.2%
Applied egg-rr60.2%
if -5.8999999999999998e-5 < a < 3.8000000000000002e-5Initial program 99.5%
associate-/l*99.3%
+-commutative99.3%
Simplified99.3%
associate-/r/99.5%
Applied egg-rr99.5%
Taylor expanded in a around 0 99.5%
if 3.8000000000000002e-5 < a Initial program 54.9%
associate-*r/55.0%
*-commutative55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in b around 0 56.1%
Final simplification78.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.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
associate-/r/77.8%
Applied egg-rr77.8%
Final simplification77.8%
(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.8%
associate-*r/77.8%
*-commutative77.8%
+-commutative77.8%
Simplified77.8%
Final simplification77.8%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= b -15500000000000.0)
(fabs t_0)
(if (<= b 8000000000000.0) (* r (/ b (cos a))) t_0))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (b <= -15500000000000.0) {
tmp = fabs(t_0);
} else if (b <= 8000000000000.0) {
tmp = r * (b / cos(a));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = r * sin(b)
if (b <= (-15500000000000.0d0)) then
tmp = abs(t_0)
else if (b <= 8000000000000.0d0) then
tmp = r * (b / cos(a))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = r * Math.sin(b);
double tmp;
if (b <= -15500000000000.0) {
tmp = Math.abs(t_0);
} else if (b <= 8000000000000.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = r * math.sin(b) tmp = 0 if b <= -15500000000000.0: tmp = math.fabs(t_0) elif b <= 8000000000000.0: tmp = r * (b / math.cos(a)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (b <= -15500000000000.0) tmp = abs(t_0); elseif (b <= 8000000000000.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * sin(b); tmp = 0.0; if (b <= -15500000000000.0) tmp = abs(t_0); elseif (b <= 8000000000000.0) tmp = r * (b / cos(a)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -15500000000000.0], N[Abs[t$95$0], $MachinePrecision], If[LessEqual[b, 8000000000000.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;b \leq -15500000000000:\\
\;\;\;\;\left|t_0\right|\\
\mathbf{elif}\;b \leq 8000000000000:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -1.55e13Initial program 55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in b around 0 12.8%
Taylor expanded in a around 0 11.4%
add-sqr-sqrt5.5%
sqrt-unprod9.2%
pow29.2%
Applied egg-rr9.2%
unpow29.2%
rem-sqrt-square12.2%
Simplified12.2%
if -1.55e13 < b < 8e12Initial program 97.8%
associate-*r/97.9%
*-commutative97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 95.1%
if 8e12 < b Initial program 57.7%
+-commutative57.7%
Simplified57.7%
Taylor expanded in b around 0 10.1%
Taylor expanded in a around 0 13.6%
Final simplification55.3%
(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 77.8%
associate-/l*77.8%
+-commutative77.8%
Simplified77.8%
associate-/r/77.8%
Applied egg-rr77.8%
Taylor expanded in b around 0 54.5%
Final simplification54.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -5e+20) (not (<= b 8000000000000.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -5e+20) || !(b <= 8000000000000.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 <= (-5d+20)) .or. (.not. (b <= 8000000000000.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 <= -5e+20) || !(b <= 8000000000000.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -5e+20) or not (b <= 8000000000000.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 <= -5e+20) || !(b <= 8000000000000.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 <= -5e+20) || ~((b <= 8000000000000.0))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -5e+20], N[Not[LessEqual[b, 8000000000000.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 -5 \cdot 10^{+20} \lor \neg \left(b \leq 8000000000000\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -5e20 or 8e12 < b Initial program 56.1%
+-commutative56.1%
Simplified56.1%
Taylor expanded in b around 0 11.5%
Taylor expanded in a around 0 12.6%
if -5e20 < b < 8e12Initial program 97.8%
associate-*r/97.9%
*-commutative97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 94.4%
Final simplification55.1%
(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 77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 54.5%
Taylor expanded in a around 0 39.6%
Final simplification39.6%
(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.8%
associate-*r/77.8%
*-commutative77.8%
+-commutative77.8%
Simplified77.8%
Taylor expanded in b around 0 50.5%
Taylor expanded in a around 0 35.3%
Final simplification35.3%
herbie shell --seed 2023178
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))