
(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) (fma (sin a) (- (sin b)) (* (cos a) (cos b)))) r))
double code(double r, double a, double b) {
return (sin(b) / fma(sin(a), -sin(b), (cos(a) * cos(b)))) * r;
}
function code(r, a, b) return Float64(Float64(sin(b) / fma(sin(a), Float64(-sin(b)), Float64(cos(a) * cos(b)))) * r) end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\mathsf{fma}\left(\sin a, -\sin b, \cos a \cdot \cos b\right)} \cdot r
\end{array}
Initial program 75.1%
associate-/l*75.1%
remove-double-neg75.1%
sin-neg75.1%
neg-mul-175.1%
associate-/r*75.1%
associate-/l*75.1%
*-commutative75.1%
associate-*l/75.2%
associate-/l*75.2%
sin-neg75.2%
distribute-lft-neg-in75.2%
distribute-rgt-neg-in75.2%
associate-/l*75.2%
metadata-eval75.2%
/-rgt-identity75.2%
+-commutative75.2%
Simplified75.2%
cos-sum99.4%
sub-neg99.4%
Applied egg-rr99.4%
+-commutative99.4%
distribute-lft-neg-in99.4%
*-commutative99.4%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(r * Float64(sin(b) / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = r * (sin(b) / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 75.1%
associate-/l*75.1%
remove-double-neg75.1%
sin-neg75.1%
neg-mul-175.1%
associate-/r*75.1%
associate-/l*75.1%
*-commutative75.1%
associate-*l/75.2%
associate-/l*75.2%
sin-neg75.2%
distribute-lft-neg-in75.2%
distribute-rgt-neg-in75.2%
associate-/l*75.2%
metadata-eval75.2%
/-rgt-identity75.2%
+-commutative75.2%
Simplified75.2%
cos-sum99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (r a b) :precision binary64 (/ (* (sin b) r) (* (cos a) (cos b))))
double code(double r, double a, double b) {
return (sin(b) * r) / (cos(a) * cos(b));
}
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) * cos(b))
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) * r) / (Math.cos(a) * Math.cos(b));
}
def code(r, a, b): return (math.sin(b) * r) / (math.cos(a) * math.cos(b))
function code(r, a, b) return Float64(Float64(sin(b) * r) / Float64(cos(a) * cos(b))) end
function tmp = code(r, a, b) tmp = (sin(b) * r) / (cos(a) * cos(b)); end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b \cdot r}{\cos a \cdot \cos b}
\end{array}
Initial program 75.1%
+-commutative75.1%
Simplified75.1%
cos-sum99.4%
Applied egg-rr99.4%
sin-mult75.8%
div-sub75.8%
cos-diff76.5%
*-commutative76.5%
*-commutative76.5%
cos-diff75.8%
Applied egg-rr75.7%
+-inverses75.7%
Simplified75.7%
Final simplification75.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.3) (not (<= b 5.4e-5))) (* r (/ (sin b) (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.3) || !(b <= 5.4e-5)) {
tmp = r * (sin(b) / cos(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 <= (-1.3d0)) .or. (.not. (b <= 5.4d-5))) then
tmp = r * (sin(b) / cos(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 <= -1.3) || !(b <= 5.4e-5)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.3) or not (b <= 5.4e-5): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -1.3) || !(b <= 5.4e-5)) tmp = Float64(r * Float64(sin(b) / cos(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 <= -1.3) || ~((b <= 5.4e-5))) tmp = r * (sin(b) / cos(b)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.3], N[Not[LessEqual[b, 5.4e-5]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.3 \lor \neg \left(b \leq 5.4 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.30000000000000004 or 5.3999999999999998e-5 < b Initial program 55.9%
associate-/l*56.0%
remove-double-neg56.0%
sin-neg56.0%
neg-mul-156.0%
associate-/r*56.0%
associate-/l*55.9%
*-commutative55.9%
associate-*l/56.0%
associate-/l*56.0%
sin-neg56.0%
distribute-lft-neg-in56.0%
distribute-rgt-neg-in56.0%
associate-/l*56.0%
metadata-eval56.0%
/-rgt-identity56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in a around 0 55.1%
if -1.30000000000000004 < b < 5.3999999999999998e-5Initial program 97.9%
associate-/l*97.9%
remove-double-neg97.9%
sin-neg97.9%
neg-mul-197.9%
associate-/r*97.9%
associate-/l*97.9%
*-commutative97.9%
associate-*l/98.0%
associate-/l*98.0%
sin-neg98.0%
distribute-lft-neg-in98.0%
distribute-rgt-neg-in98.0%
associate-/l*98.0%
metadata-eval98.0%
/-rgt-identity98.0%
+-commutative98.0%
Simplified98.0%
Taylor expanded in b around 0 98.0%
Final simplification74.7%
(FPCore (r a b) :precision binary64 (if (<= b -1.3) (/ (sin b) (/ (cos b) r)) (if (<= b 2.5e-5) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.3) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 2.5e-5) {
tmp = r * (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 (b <= (-1.3d0)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 2.5d-5) then
tmp = r * (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 (b <= -1.3) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 2.5e-5) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.3: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 2.5e-5: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.3) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 2.5e-5) tmp = Float64(r * Float64(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 (b <= -1.3) tmp = sin(b) / (cos(b) / r); elseif (b <= 2.5e-5) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.3], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-5], N[(r * N[(b / 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}\;b \leq -1.3:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -1.30000000000000004Initial program 49.1%
associate-/l*49.1%
remove-double-neg49.1%
sin-neg49.1%
neg-mul-149.1%
associate-/r*49.1%
associate-/l*49.1%
*-commutative49.1%
associate-*l/49.2%
associate-/l*49.2%
sin-neg49.2%
distribute-lft-neg-in49.2%
distribute-rgt-neg-in49.2%
associate-/l*49.2%
metadata-eval49.2%
/-rgt-identity49.2%
+-commutative49.2%
Simplified49.2%
associate-*l/49.1%
associate-/l*49.3%
Applied egg-rr49.3%
Taylor expanded in a around 0 49.5%
if -1.30000000000000004 < b < 2.50000000000000012e-5Initial program 97.9%
associate-/l*97.9%
remove-double-neg97.9%
sin-neg97.9%
neg-mul-197.9%
associate-/r*97.9%
associate-/l*97.9%
*-commutative97.9%
associate-*l/98.0%
associate-/l*98.0%
sin-neg98.0%
distribute-lft-neg-in98.0%
distribute-rgt-neg-in98.0%
associate-/l*98.0%
metadata-eval98.0%
/-rgt-identity98.0%
+-commutative98.0%
Simplified98.0%
Taylor expanded in b around 0 98.0%
if 2.50000000000000012e-5 < b Initial program 63.7%
associate-/l*63.7%
remove-double-neg63.7%
sin-neg63.7%
neg-mul-163.7%
associate-/r*63.7%
associate-/l*63.7%
*-commutative63.7%
associate-*l/63.7%
associate-/l*63.7%
sin-neg63.7%
distribute-lft-neg-in63.7%
distribute-rgt-neg-in63.7%
associate-/l*63.7%
metadata-eval63.7%
/-rgt-identity63.7%
+-commutative63.7%
Simplified63.7%
Taylor expanded in a around 0 61.5%
Final simplification74.7%
(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 75.1%
associate-/l*75.1%
+-commutative75.1%
Simplified75.1%
associate-/r/75.2%
Applied egg-rr75.2%
Final simplification75.2%
(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 75.1%
associate-/l*75.1%
remove-double-neg75.1%
sin-neg75.1%
neg-mul-175.1%
associate-/r*75.1%
associate-/l*75.1%
*-commutative75.1%
associate-*l/75.2%
associate-/l*75.2%
sin-neg75.2%
distribute-lft-neg-in75.2%
distribute-rgt-neg-in75.2%
associate-/l*75.2%
metadata-eval75.2%
/-rgt-identity75.2%
+-commutative75.2%
Simplified75.2%
Taylor expanded in b around 0 51.3%
Final simplification51.3%
(FPCore (r a b) :precision binary64 (if (<= b -420000.0) (/ (- r) (sin a)) (if (<= b 1.12) (* r (/ b (cos a))) (/ r (- (/ 1.0 b) (sin a))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -420000.0) {
tmp = -r / sin(a);
} else if (b <= 1.12) {
tmp = r * (b / cos(a));
} else {
tmp = r / ((1.0 / b) - sin(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 <= (-420000.0d0)) then
tmp = -r / sin(a)
else if (b <= 1.12d0) then
tmp = r * (b / cos(a))
else
tmp = r / ((1.0d0 / b) - sin(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -420000.0) {
tmp = -r / Math.sin(a);
} else if (b <= 1.12) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r / ((1.0 / b) - Math.sin(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -420000.0: tmp = -r / math.sin(a) elif b <= 1.12: tmp = r * (b / math.cos(a)) else: tmp = r / ((1.0 / b) - math.sin(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -420000.0) tmp = Float64(Float64(-r) / sin(a)); elseif (b <= 1.12) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r / Float64(Float64(1.0 / b) - sin(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -420000.0) tmp = -r / sin(a); elseif (b <= 1.12) tmp = r * (b / cos(a)); else tmp = r / ((1.0 / b) - sin(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -420000.0], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.12], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[(1.0 / b), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -420000:\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{elif}\;b \leq 1.12:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\
\end{array}
\end{array}
if b < -4.2e5Initial program 49.1%
associate-/l*49.1%
+-commutative49.1%
Simplified49.1%
Taylor expanded in b around 0 10.5%
+-commutative10.5%
neg-mul-110.5%
unsub-neg10.5%
Simplified10.5%
Taylor expanded in b around inf 10.6%
associate-*r/10.6%
neg-mul-110.6%
Simplified10.6%
if -4.2e5 < b < 1.1200000000000001Initial program 97.1%
associate-/l*97.0%
remove-double-neg97.0%
sin-neg97.0%
neg-mul-197.0%
associate-/r*97.0%
associate-/l*97.1%
*-commutative97.1%
associate-*l/97.2%
associate-/l*97.2%
sin-neg97.2%
distribute-lft-neg-in97.2%
distribute-rgt-neg-in97.2%
associate-/l*97.2%
metadata-eval97.2%
/-rgt-identity97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in b around 0 96.6%
if 1.1200000000000001 < b Initial program 63.7%
associate-/l*63.7%
+-commutative63.7%
Simplified63.7%
Taylor expanded in b around 0 11.2%
+-commutative11.2%
neg-mul-111.2%
unsub-neg11.2%
Simplified11.2%
Taylor expanded in a around 0 11.2%
Final simplification50.7%
(FPCore (r a b) :precision binary64 (if (<= b -340000.0) (/ (- r) (sin a)) (if (<= b 2.7e+21) (/ (* b r) (cos (+ b a))) (/ r (- (/ 1.0 b) (sin a))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -340000.0) {
tmp = -r / sin(a);
} else if (b <= 2.7e+21) {
tmp = (b * r) / cos((b + a));
} else {
tmp = r / ((1.0 / b) - sin(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 <= (-340000.0d0)) then
tmp = -r / sin(a)
else if (b <= 2.7d+21) then
tmp = (b * r) / cos((b + a))
else
tmp = r / ((1.0d0 / b) - sin(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -340000.0) {
tmp = -r / Math.sin(a);
} else if (b <= 2.7e+21) {
tmp = (b * r) / Math.cos((b + a));
} else {
tmp = r / ((1.0 / b) - Math.sin(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -340000.0: tmp = -r / math.sin(a) elif b <= 2.7e+21: tmp = (b * r) / math.cos((b + a)) else: tmp = r / ((1.0 / b) - math.sin(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -340000.0) tmp = Float64(Float64(-r) / sin(a)); elseif (b <= 2.7e+21) tmp = Float64(Float64(b * r) / cos(Float64(b + a))); else tmp = Float64(r / Float64(Float64(1.0 / b) - sin(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -340000.0) tmp = -r / sin(a); elseif (b <= 2.7e+21) tmp = (b * r) / cos((b + a)); else tmp = r / ((1.0 / b) - sin(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -340000.0], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.7e+21], N[(N[(b * r), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[(1.0 / b), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -340000:\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{+21}:\\
\;\;\;\;\frac{b \cdot r}{\cos \left(b + a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\
\end{array}
\end{array}
if b < -3.4e5Initial program 49.1%
associate-/l*49.1%
+-commutative49.1%
Simplified49.1%
Taylor expanded in b around 0 10.5%
+-commutative10.5%
neg-mul-110.5%
unsub-neg10.5%
Simplified10.5%
Taylor expanded in b around inf 10.6%
associate-*r/10.6%
neg-mul-110.6%
Simplified10.6%
if -3.4e5 < b < 2.7e21Initial program 97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in b around 0 93.6%
if 2.7e21 < b Initial program 61.4%
associate-/l*61.4%
+-commutative61.4%
Simplified61.4%
Taylor expanded in b around 0 11.6%
+-commutative11.6%
neg-mul-111.6%
unsub-neg11.6%
Simplified11.6%
Taylor expanded in a around 0 11.6%
Final simplification50.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -430000.0) (not (<= b 42000000000000.0))) (/ (- r) (sin a)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -430000.0) || !(b <= 42000000000000.0)) {
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 <= (-430000.0d0)) .or. (.not. (b <= 42000000000000.0d0))) 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 <= -430000.0) || !(b <= 42000000000000.0)) {
tmp = -r / Math.sin(a);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -430000.0) or not (b <= 42000000000000.0): tmp = -r / math.sin(a) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -430000.0) || !(b <= 42000000000000.0)) 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 <= -430000.0) || ~((b <= 42000000000000.0))) tmp = -r / sin(a); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -430000.0], N[Not[LessEqual[b, 42000000000000.0]], $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 -430000 \lor \neg \left(b \leq 42000000000000\right):\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -4.3e5 or 4.2e13 < b Initial program 55.4%
associate-/l*55.4%
+-commutative55.4%
Simplified55.4%
Taylor expanded in b around 0 10.9%
+-commutative10.9%
neg-mul-110.9%
unsub-neg10.9%
Simplified10.9%
Taylor expanded in b around inf 10.7%
associate-*r/10.7%
neg-mul-110.7%
Simplified10.7%
if -4.3e5 < b < 4.2e13Initial program 97.1%
associate-/l*97.1%
remove-double-neg97.1%
sin-neg97.1%
neg-mul-197.1%
associate-/r*97.1%
associate-/l*97.1%
*-commutative97.1%
associate-*l/97.2%
associate-/l*97.2%
sin-neg97.2%
distribute-lft-neg-in97.2%
distribute-rgt-neg-in97.2%
associate-/l*97.2%
metadata-eval97.2%
/-rgt-identity97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in b around 0 95.1%
Final simplification50.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -360000.0) (not (<= b 1.95e-11))) (/ (- r) (sin a)) (* b r)))
double code(double r, double a, double b) {
double tmp;
if ((b <= -360000.0) || !(b <= 1.95e-11)) {
tmp = -r / sin(a);
} else {
tmp = b * r;
}
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 <= (-360000.0d0)) .or. (.not. (b <= 1.95d-11))) then
tmp = -r / sin(a)
else
tmp = b * r
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -360000.0) || !(b <= 1.95e-11)) {
tmp = -r / Math.sin(a);
} else {
tmp = b * r;
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -360000.0) or not (b <= 1.95e-11): tmp = -r / math.sin(a) else: tmp = b * r return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -360000.0) || !(b <= 1.95e-11)) tmp = Float64(Float64(-r) / sin(a)); else tmp = Float64(b * r); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -360000.0) || ~((b <= 1.95e-11))) tmp = -r / sin(a); else tmp = b * r; end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -360000.0], N[Not[LessEqual[b, 1.95e-11]], $MachinePrecision]], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], N[(b * r), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -360000 \lor \neg \left(b \leq 1.95 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{else}:\\
\;\;\;\;b \cdot r\\
\end{array}
\end{array}
if b < -3.6e5 or 1.95000000000000005e-11 < b Initial program 56.2%
associate-/l*56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in b around 0 11.5%
+-commutative11.5%
neg-mul-111.5%
unsub-neg11.5%
Simplified11.5%
Taylor expanded in b around inf 10.7%
associate-*r/10.7%
neg-mul-110.7%
Simplified10.7%
if -3.6e5 < b < 1.95000000000000005e-11Initial program 97.3%
associate-/l*97.2%
remove-double-neg97.2%
sin-neg97.2%
neg-mul-197.2%
associate-/r*97.2%
associate-/l*97.3%
*-commutative97.3%
associate-*l/97.4%
associate-/l*97.4%
sin-neg97.4%
distribute-lft-neg-in97.4%
distribute-rgt-neg-in97.4%
associate-/l*97.4%
metadata-eval97.4%
/-rgt-identity97.4%
+-commutative97.4%
Simplified97.4%
Taylor expanded in b around 0 96.7%
Taylor expanded in a around 0 65.5%
Final simplification35.9%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return b * r;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b * r
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 75.1%
associate-/l*75.1%
remove-double-neg75.1%
sin-neg75.1%
neg-mul-175.1%
associate-/r*75.1%
associate-/l*75.1%
*-commutative75.1%
associate-*l/75.2%
associate-/l*75.2%
sin-neg75.2%
distribute-lft-neg-in75.2%
distribute-rgt-neg-in75.2%
associate-/l*75.2%
metadata-eval75.2%
/-rgt-identity75.2%
+-commutative75.2%
Simplified75.2%
Taylor expanded in b around 0 46.9%
Taylor expanded in a around 0 32.3%
Final simplification32.3%
herbie shell --seed 2023334
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))