
(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 16 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
(let* ((t_0 (* (sin b) (sin a))))
(/
(* r (sin b))
(+ (fma (- (sin b)) (sin a) t_0) (- (* (cos a) (cos b)) t_0)))))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (r * sin(b)) / (fma(-sin(b), sin(a), t_0) + ((cos(a) * cos(b)) - t_0));
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(r * sin(b)) / Float64(fma(Float64(-sin(b)), sin(a), t_0) + Float64(Float64(cos(a) * cos(b)) - t_0))) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[((-N[Sin[b], $MachinePrecision]) * N[Sin[a], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(-\sin b, \sin a, t_0\right) + \left(\cos a \cdot \cos b - t_0\right)}
\end{array}
\end{array}
Initial program 75.5%
associate-*r/75.6%
+-commutative75.6%
Simplified75.6%
cos-sum99.6%
Applied egg-rr99.6%
*-un-lft-identity99.6%
prod-diff99.5%
Applied egg-rr99.5%
fma-udef99.6%
*-rgt-identity99.6%
unsub-neg99.6%
*-commutative99.6%
fma-udef99.6%
*-rgt-identity99.6%
distribute-lft-neg-in99.6%
*-rgt-identity99.6%
fma-udef99.6%
Simplified99.6%
Final simplification99.6%
(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.5%
+-commutative75.5%
Simplified75.5%
cos-sum99.6%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (- (* (cos a) (cos b)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return sin(b) * (r / ((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 = sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / ((Math.cos(a) * Math.cos(b)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return math.sin(b) * (r / ((math.cos(a) * math.cos(b)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(sin(b) * Float64(r / Float64(Float64(cos(a) * cos(b)) - Float64(sin(b) * sin(a))))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / ((cos(a) * cos(b)) - (sin(b) * sin(a)))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / 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}
\\
\sin b \cdot \frac{r}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 75.5%
*-commutative75.5%
associate-/r/75.5%
+-commutative75.5%
Simplified75.5%
div-inv75.5%
clear-num75.5%
*-commutative75.5%
Applied egg-rr75.5%
cos-sum99.6%
Applied egg-rr99.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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos a \cdot \cos b - \sin b \cdot \sin a}
\end{array}
Initial program 75.5%
associate-*r/75.6%
+-commutative75.6%
Simplified75.6%
cos-sum99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (if (or (<= a -0.00034) (not (<= a 7e+53))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -0.00034) || !(a <= 7e+53)) {
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 <= (-0.00034d0)) .or. (.not. (a <= 7d+53))) 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 <= -0.00034) || !(a <= 7e+53)) {
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 <= -0.00034) or not (a <= 7e+53): 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 <= -0.00034) || !(a <= 7e+53)) 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 <= -0.00034) || ~((a <= 7e+53))) 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, -0.00034], N[Not[LessEqual[a, 7e+53]], $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 -0.00034 \lor \neg \left(a \leq 7 \cdot 10^{+53}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -3.4e-4 or 7.00000000000000038e53 < a Initial program 56.8%
+-commutative56.8%
Simplified56.8%
Taylor expanded in b around 0 57.8%
if -3.4e-4 < a < 7.00000000000000038e53Initial program 94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 94.9%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (if (<= a -0.0019) (* (sin b) (/ r (cos a))) (if (<= a 7e+53) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.0019) {
tmp = sin(b) * (r / cos(a));
} else if (a <= 7e+53) {
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 <= (-0.0019d0)) then
tmp = sin(b) * (r / cos(a))
else if (a <= 7d+53) 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 <= -0.0019) {
tmp = Math.sin(b) * (r / Math.cos(a));
} else if (a <= 7e+53) {
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 <= -0.0019: tmp = math.sin(b) * (r / math.cos(a)) elif a <= 7e+53: 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 <= -0.0019) tmp = Float64(sin(b) * Float64(r / cos(a))); elseif (a <= 7e+53) 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 <= -0.0019) tmp = sin(b) * (r / cos(a)); elseif (a <= 7e+53) 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, -0.0019], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7e+53], 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 -0.0019:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\mathbf{elif}\;a \leq 7 \cdot 10^{+53}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -0.0019Initial program 60.1%
*-commutative60.1%
associate-/r/60.2%
+-commutative60.2%
Simplified60.2%
div-inv60.3%
clear-num60.2%
*-commutative60.2%
Applied egg-rr60.2%
Taylor expanded in b around 0 61.6%
if -0.0019 < a < 7.00000000000000038e53Initial program 94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 94.9%
if 7.00000000000000038e53 < a Initial program 53.3%
+-commutative53.3%
Simplified53.3%
Taylor expanded in b around 0 54.0%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (if (<= a -2.4e-5) (/ (sin b) (/ (cos a) r)) (if (<= a 1.1e+54) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -2.4e-5) {
tmp = sin(b) / (cos(a) / r);
} else if (a <= 1.1e+54) {
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 <= (-2.4d-5)) then
tmp = sin(b) / (cos(a) / r)
else if (a <= 1.1d+54) 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 <= -2.4e-5) {
tmp = Math.sin(b) / (Math.cos(a) / r);
} else if (a <= 1.1e+54) {
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 <= -2.4e-5: tmp = math.sin(b) / (math.cos(a) / r) elif a <= 1.1e+54: 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 <= -2.4e-5) tmp = Float64(sin(b) / Float64(cos(a) / r)); elseif (a <= 1.1e+54) 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 <= -2.4e-5) tmp = sin(b) / (cos(a) / r); elseif (a <= 1.1e+54) 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, -2.4e-5], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[a], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.1e+54], 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 -2.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{\sin b}{\frac{\cos a}{r}}\\
\mathbf{elif}\;a \leq 1.1 \cdot 10^{+54}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -2.4000000000000001e-5Initial program 60.1%
*-commutative60.1%
associate-/r/60.2%
+-commutative60.2%
Simplified60.2%
Taylor expanded in b around 0 61.6%
if -2.4000000000000001e-5 < a < 1.09999999999999995e54Initial program 94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 94.9%
if 1.09999999999999995e54 < a Initial program 53.3%
+-commutative53.3%
Simplified53.3%
Taylor expanded in b around 0 54.0%
Final simplification76.1%
(FPCore (r a b) :precision binary64 (if (<= a -0.00013) (/ (* r (sin b)) (cos a)) (if (<= a 7e+53) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -0.00013) {
tmp = (r * sin(b)) / cos(a);
} else if (a <= 7e+53) {
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 <= (-0.00013d0)) then
tmp = (r * sin(b)) / cos(a)
else if (a <= 7d+53) 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 <= -0.00013) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else if (a <= 7e+53) {
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 <= -0.00013: tmp = (r * math.sin(b)) / math.cos(a) elif a <= 7e+53: 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 <= -0.00013) tmp = Float64(Float64(r * sin(b)) / cos(a)); elseif (a <= 7e+53) 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 <= -0.00013) tmp = (r * sin(b)) / cos(a); elseif (a <= 7e+53) 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, -0.00013], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7e+53], 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 -0.00013:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{elif}\;a \leq 7 \cdot 10^{+53}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -1.29999999999999989e-4Initial program 60.1%
associate-*r/60.2%
+-commutative60.2%
Simplified60.2%
Taylor expanded in b around 0 61.7%
if -1.29999999999999989e-4 < a < 7.00000000000000038e53Initial program 94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 94.9%
if 7.00000000000000038e53 < a Initial program 53.3%
+-commutative53.3%
Simplified53.3%
Taylor expanded in b around 0 54.0%
Final simplification76.1%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* r (sin b))))
(if (<= a -0.00185)
(/ t_0 (cos a))
(if (<= a 7e+53) (/ t_0 (cos b)) (* r (/ (sin b) (cos a)))))))
double code(double r, double a, double b) {
double t_0 = r * sin(b);
double tmp;
if (a <= -0.00185) {
tmp = t_0 / cos(a);
} else if (a <= 7e+53) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = r * sin(b)
if (a <= (-0.00185d0)) then
tmp = t_0 / cos(a)
else if (a <= 7d+53) then
tmp = t_0 / 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 t_0 = r * Math.sin(b);
double tmp;
if (a <= -0.00185) {
tmp = t_0 / Math.cos(a);
} else if (a <= 7e+53) {
tmp = t_0 / Math.cos(b);
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): t_0 = r * math.sin(b) tmp = 0 if a <= -0.00185: tmp = t_0 / math.cos(a) elif a <= 7e+53: tmp = t_0 / math.cos(b) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) t_0 = Float64(r * sin(b)) tmp = 0.0 if (a <= -0.00185) tmp = Float64(t_0 / cos(a)); elseif (a <= 7e+53) tmp = Float64(t_0 / cos(b)); else tmp = Float64(r * Float64(sin(b) / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) t_0 = r * sin(b); tmp = 0.0; if (a <= -0.00185) tmp = t_0 / cos(a); elseif (a <= 7e+53) tmp = t_0 / cos(b); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.00185], N[(t$95$0 / N[Cos[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 7e+53], N[(t$95$0 / N[Cos[b], $MachinePrecision]), $MachinePrecision], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := r \cdot \sin b\\
\mathbf{if}\;a \leq -0.00185:\\
\;\;\;\;\frac{t_0}{\cos a}\\
\mathbf{elif}\;a \leq 7 \cdot 10^{+53}:\\
\;\;\;\;\frac{t_0}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if a < -0.0018500000000000001Initial program 60.1%
associate-*r/60.2%
+-commutative60.2%
Simplified60.2%
Taylor expanded in b around 0 61.7%
if -0.0018500000000000001 < a < 7.00000000000000038e53Initial program 94.9%
+-commutative94.9%
Simplified94.9%
Taylor expanded in a around 0 95.0%
if 7.00000000000000038e53 < a Initial program 53.3%
+-commutative53.3%
Simplified53.3%
Taylor expanded in b around 0 54.0%
Final simplification76.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 75.5%
Final simplification75.5%
(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(Float64(r * 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[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos \left(b + a\right)}
\end{array}
Initial program 75.5%
associate-*r/75.6%
+-commutative75.6%
Simplified75.6%
Final simplification75.6%
(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.5%
+-commutative75.5%
Simplified75.5%
Taylor expanded in b around 0 54.6%
Final simplification54.6%
(FPCore (r a b) :precision binary64 (if (or (<= b -1.2) (not (<= b 3200.0))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -1.2) || !(b <= 3200.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 <= (-1.2d0)) .or. (.not. (b <= 3200.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 <= -1.2) || !(b <= 3200.0)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -1.2) or not (b <= 3200.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 <= -1.2) || !(b <= 3200.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 <= -1.2) || ~((b <= 3200.0))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -1.2], N[Not[LessEqual[b, 3200.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 -1.2 \lor \neg \left(b \leq 3200\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.19999999999999996 or 3200 < b Initial program 52.7%
*-commutative52.7%
associate-/r/52.7%
+-commutative52.7%
Simplified52.7%
Taylor expanded in b around 0 11.9%
Taylor expanded in a around 0 12.6%
if -1.19999999999999996 < b < 3200Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.4%
Final simplification55.0%
(FPCore (r a b) :precision binary64 (if (<= b -1.2) (/ (sin b) (/ 1.0 r)) (if (<= b 3200.0) (* r (/ b (cos a))) (* r (sin b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.2) {
tmp = sin(b) / (1.0 / r);
} else if (b <= 3200.0) {
tmp = r * (b / cos(a));
} else {
tmp = r * sin(b);
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-1.2d0)) then
tmp = sin(b) / (1.0d0 / r)
else if (b <= 3200.0d0) then
tmp = r * (b / cos(a))
else
tmp = r * sin(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -1.2) {
tmp = Math.sin(b) / (1.0 / r);
} else if (b <= 3200.0) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * Math.sin(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.2: tmp = math.sin(b) / (1.0 / r) elif b <= 3200.0: tmp = r * (b / math.cos(a)) else: tmp = r * math.sin(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.2) tmp = Float64(sin(b) / Float64(1.0 / r)); elseif (b <= 3200.0) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(r * sin(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -1.2) tmp = sin(b) / (1.0 / r); elseif (b <= 3200.0) tmp = r * (b / cos(a)); else tmp = r * sin(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.2], N[(N[Sin[b], $MachinePrecision] / N[(1.0 / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3200.0], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2:\\
\;\;\;\;\frac{\sin b}{\frac{1}{r}}\\
\mathbf{elif}\;b \leq 3200:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \sin b\\
\end{array}
\end{array}
if b < -1.19999999999999996Initial program 56.9%
*-commutative56.9%
associate-/r/56.9%
+-commutative56.9%
Simplified56.9%
Taylor expanded in b around 0 11.3%
Taylor expanded in a around 0 12.3%
if -1.19999999999999996 < b < 3200Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in b around 0 99.4%
if 3200 < b Initial program 48.4%
*-commutative48.4%
associate-/r/48.4%
+-commutative48.4%
Simplified48.4%
Taylor expanded in b around 0 12.5%
Taylor expanded in a around 0 12.8%
Final simplification55.0%
(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 75.5%
*-commutative75.5%
associate-/r/75.5%
+-commutative75.5%
Simplified75.5%
Taylor expanded in b around 0 54.6%
Taylor expanded in a around 0 37.3%
Final simplification37.3%
(FPCore (r a b) :precision binary64 (* r b))
double code(double r, double a, double b) {
return r * b;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * b
end function
public static double code(double r, double a, double b) {
return r * b;
}
def code(r, a, b): return r * b
function code(r, a, b) return Float64(r * b) end
function tmp = code(r, a, b) tmp = r * b; end
code[r_, a_, b_] := N[(r * b), $MachinePrecision]
\begin{array}{l}
\\
r \cdot b
\end{array}
Initial program 75.5%
+-commutative75.5%
Simplified75.5%
Taylor expanded in b around 0 50.4%
Taylor expanded in a around 0 32.9%
Final simplification32.9%
herbie shell --seed 2023258
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))