
(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 11 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 (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.4%
cancel-sign-sub-inv99.4%
fma-def99.4%
Applied egg-rr99.4%
Final simplification99.4%
(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(r * Float64(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[(r * N[(N[Sin[b], $MachinePrecision] / 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}
\\
r \cdot \frac{\sin b}{\cos b \cdot \cos a - \sin b \cdot \sin a}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b)
:precision binary64
(if (<= a -1.8e-6)
(/ r (/ (cos a) (sin b)))
(if (<= a 4.2e-5)
(* r (* (sin b) (/ 1.0 (cos b))))
(* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -1.8e-6) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 4.2e-5) {
tmp = r * (sin(b) * (1.0 / 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 <= (-1.8d-6)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 4.2d-5) then
tmp = r * (sin(b) * (1.0d0 / 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 <= -1.8e-6) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 4.2e-5) {
tmp = r * (Math.sin(b) * (1.0 / Math.cos(b)));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -1.8e-6: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 4.2e-5: tmp = r * (math.sin(b) * (1.0 / math.cos(b))) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -1.8e-6) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 4.2e-5) tmp = Float64(r * Float64(sin(b) * Float64(1.0 / 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 <= -1.8e-6) tmp = r / (cos(a) / sin(b)); elseif (a <= 4.2e-5) tmp = r * (sin(b) * (1.0 / cos(b))); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -1.8e-6], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4.2e-5], N[(r * N[(N[Sin[b], $MachinePrecision] * N[(1.0 / N[Cos[b], $MachinePrecision]), $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 -1.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 4.2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \left(\sin b \cdot \frac{1}{\cos b}\right)\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -1.79999999999999992e-6Initial program 56.1%
associate-*r/56.1%
associate-/l*56.1%
+-commutative56.1%
Simplified56.1%
Taylor expanded in b around 0 57.4%
if -1.79999999999999992e-6 < a < 4.19999999999999977e-5Initial program 99.1%
+-commutative99.1%
Simplified99.1%
clear-num99.0%
associate-/r/99.1%
Applied egg-rr99.1%
Taylor expanded in a around 0 99.1%
if 4.19999999999999977e-5 < a Initial program 55.9%
+-commutative55.9%
Simplified55.9%
Taylor expanded in b around 0 57.3%
Final simplification78.1%
(FPCore (r a b) :precision binary64 (if (or (<= a -1.8e-6) (not (<= a 1.18e-5))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -1.8e-6) || !(a <= 1.18e-5)) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r * (sin(b) / 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 <= (-1.8d-6)) .or. (.not. (a <= 1.18d-5))) then
tmp = r * (sin(b) / cos(a))
else
tmp = r * (sin(b) / cos(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((a <= -1.8e-6) || !(a <= 1.18e-5)) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (a <= -1.8e-6) or not (a <= 1.18e-5): tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if ((a <= -1.8e-6) || !(a <= 1.18e-5)) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r * Float64(sin(b) / cos(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((a <= -1.8e-6) || ~((a <= 1.18e-5))) tmp = r * (sin(b) / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[a, -1.8e-6], N[Not[LessEqual[a, 1.18e-5]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{-6} \lor \neg \left(a \leq 1.18 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -1.79999999999999992e-6 or 1.18000000000000005e-5 < a Initial program 56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in b around 0 57.4%
if -1.79999999999999992e-6 < a < 1.18000000000000005e-5Initial program 99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.1%
Final simplification78.0%
(FPCore (r a b) :precision binary64 (if (<= a -1.8e-6) (/ r (/ (cos a) (sin b))) (if (<= a 5.8e-5) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -1.8e-6) {
tmp = r / (cos(a) / sin(b));
} else if (a <= 5.8e-5) {
tmp = r * (sin(b) / 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 <= (-1.8d-6)) then
tmp = r / (cos(a) / sin(b))
else if (a <= 5.8d-5) then
tmp = r * (sin(b) / 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 <= -1.8e-6) {
tmp = r / (Math.cos(a) / Math.sin(b));
} else if (a <= 5.8e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -1.8e-6: tmp = r / (math.cos(a) / math.sin(b)) elif a <= 5.8e-5: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -1.8e-6) tmp = Float64(r / Float64(cos(a) / sin(b))); elseif (a <= 5.8e-5) tmp = Float64(r * Float64(sin(b) / 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 <= -1.8e-6) tmp = r / (cos(a) / sin(b)); elseif (a <= 5.8e-5) tmp = r * (sin(b) / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -1.8e-6], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.8e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / 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 -1.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\mathbf{elif}\;a \leq 5.8 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -1.79999999999999992e-6Initial program 56.1%
associate-*r/56.1%
associate-/l*56.1%
+-commutative56.1%
Simplified56.1%
Taylor expanded in b around 0 57.4%
if -1.79999999999999992e-6 < a < 5.8e-5Initial program 99.1%
+-commutative99.1%
Simplified99.1%
Taylor expanded in a around 0 99.1%
if 5.8e-5 < a Initial program 55.9%
+-commutative55.9%
Simplified55.9%
Taylor expanded in b around 0 57.3%
Final simplification78.1%
(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 (* r (/ (sin b) (cos a))))
double code(double r, double a, double b) {
return r * (sin(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 = r * (sin(b) / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / Math.cos(a));
}
def code(r, a, b): return r * (math.sin(b) / math.cos(a))
function code(r, a, b) return Float64(r * Float64(sin(b) / cos(a))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / cos(a)); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a}
\end{array}
Initial program 77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in b around 0 53.6%
Final simplification53.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -450000.0) (not (<= b 0.9))) (/ r (- (/ 1.0 b) (sin a))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -450000.0) || !(b <= 0.9)) {
tmp = r / ((1.0 / b) - sin(a));
} 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 <= (-450000.0d0)) .or. (.not. (b <= 0.9d0))) then
tmp = r / ((1.0d0 / b) - sin(a))
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 <= -450000.0) || !(b <= 0.9)) {
tmp = r / ((1.0 / b) - Math.sin(a));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -450000.0) or not (b <= 0.9): tmp = r / ((1.0 / b) - math.sin(a)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -450000.0) || !(b <= 0.9)) tmp = Float64(r / Float64(Float64(1.0 / b) - sin(a))); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -450000.0) || ~((b <= 0.9))) tmp = r / ((1.0 / b) - sin(a)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -450000.0], N[Not[LessEqual[b, 0.9]], $MachinePrecision]], N[(r / N[(N[(1.0 / b), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -450000 \lor \neg \left(b \leq 0.9\right):\\
\;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.5e5 or 0.900000000000000022 < b Initial program 57.4%
associate-*r/57.3%
associate-/l*57.3%
+-commutative57.3%
Simplified57.3%
Taylor expanded in b around 0 10.0%
+-commutative10.0%
neg-mul-110.0%
unsub-neg10.0%
Simplified10.0%
Taylor expanded in a around 0 10.0%
if -4.5e5 < b < 0.900000000000000022Initial program 98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in b around 0 96.6%
Final simplification51.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -980000.0) (not (<= b 1.4e+20))) (/ (- r) (sin a)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -980000.0) || !(b <= 1.4e+20)) {
tmp = -r / sin(a);
} 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 <= (-980000.0d0)) .or. (.not. (b <= 1.4d+20))) then
tmp = -r / sin(a)
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 <= -980000.0) || !(b <= 1.4e+20)) {
tmp = -r / Math.sin(a);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -980000.0) or not (b <= 1.4e+20): tmp = -r / math.sin(a) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -980000.0) || !(b <= 1.4e+20)) tmp = Float64(Float64(-r) / sin(a)); else tmp = Float64(r * Float64(b / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -980000.0) || ~((b <= 1.4e+20))) tmp = -r / sin(a); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -980000.0], N[Not[LessEqual[b, 1.4e+20]], $MachinePrecision]], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -980000 \lor \neg \left(b \leq 1.4 \cdot 10^{+20}\right):\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -9.8e5 or 1.4e20 < b Initial program 57.0%
associate-*r/56.9%
associate-/l*57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in b around 0 10.0%
+-commutative10.0%
neg-mul-110.0%
unsub-neg10.0%
Simplified10.0%
Taylor expanded in b around inf 10.0%
associate-*r/10.0%
neg-mul-110.0%
Simplified10.0%
if -9.8e5 < b < 1.4e20Initial program 98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in b around 0 94.5%
Final simplification51.9%
(FPCore (r a b) :precision binary64 (if (or (<= b -1150000.0) (not (<= b 8.6e+16))) (/ (- r) (sin a)) (* r b)))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1150000.0) || !(b <= 8.6e+16)) {
tmp = -r / sin(a);
} else {
tmp = r * 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 <= (-1150000.0d0)) .or. (.not. (b <= 8.6d+16))) then
tmp = -r / sin(a)
else
tmp = r * b
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -1150000.0) || !(b <= 8.6e+16)) {
tmp = -r / Math.sin(a);
} else {
tmp = r * b;
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1150000.0) or not (b <= 8.6e+16): tmp = -r / math.sin(a) else: tmp = r * b return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1150000.0) || !(b <= 8.6e+16)) tmp = Float64(Float64(-r) / sin(a)); else tmp = Float64(r * b); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -1150000.0) || ~((b <= 8.6e+16))) tmp = -r / sin(a); else tmp = r * b; end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1150000.0], N[Not[LessEqual[b, 8.6e+16]], $MachinePrecision]], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], N[(r * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1150000 \lor \neg \left(b \leq 8.6 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot b\\
\end{array}
\end{array}
if b < -1.15e6 or 8.6e16 < b Initial program 57.0%
associate-*r/56.9%
associate-/l*57.0%
+-commutative57.0%
Simplified57.0%
Taylor expanded in b around 0 10.0%
+-commutative10.0%
neg-mul-110.0%
unsub-neg10.0%
Simplified10.0%
Taylor expanded in b around inf 10.0%
associate-*r/10.0%
neg-mul-110.0%
Simplified10.0%
if -1.15e6 < b < 8.6e16Initial program 98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in b around 0 94.5%
Taylor expanded in a around 0 61.5%
Final simplification35.5%
(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 48.7%
Taylor expanded in a around 0 32.2%
Final simplification32.2%
herbie shell --seed 2023305
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))