
(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 14 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
(let* ((t_0 (- (sin a))))
(*
r
(/
(sin b)
(fma
(cos b)
(cos a)
(fma (sin b) t_0 (fma t_0 (sin b) (* (sin b) (sin a)))))))))
double code(double r, double a, double b) {
double t_0 = -sin(a);
return r * (sin(b) / fma(cos(b), cos(a), fma(sin(b), t_0, fma(t_0, sin(b), (sin(b) * sin(a))))));
}
function code(r, a, b) t_0 = Float64(-sin(a)) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), fma(sin(b), t_0, fma(t_0, sin(b), Float64(sin(b) * sin(a))))))) end
code[r_, a_, b_] := Block[{t$95$0 = (-N[Sin[a], $MachinePrecision])}, N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * t$95$0 + N[(t$95$0 * N[Sin[b], $MachinePrecision] + N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin a\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, \mathsf{fma}\left(\sin b, t\_0, \mathsf{fma}\left(t\_0, \sin b, \sin b \cdot \sin a\right)\right)\right)}
\end{array}
\end{array}
Initial program 77.1%
associate-/l*77.1%
+-commutative77.1%
Simplified77.1%
cos-sum99.5%
Applied egg-rr99.5%
prod-diff99.5%
*-commutative99.5%
fma-define99.5%
associate-+l+99.5%
distribute-rgt-neg-in99.5%
*-commutative99.5%
Applied egg-rr99.5%
fma-define99.5%
fma-define99.5%
*-commutative99.5%
Simplified99.5%
Final simplification99.5%
(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.1%
associate-/l*77.1%
+-commutative77.1%
Simplified77.1%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (- (* (cos b) (cos a)) (* (sin b) (sin a))))))
double code(double r, double a, double b) {
return r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * (sin(b) / ((cos(b) * cos(a)) - (sin(b) * sin(a))))
end function
public static double code(double r, double a, double b) {
return r * (Math.sin(b) / ((Math.cos(b) * Math.cos(a)) - (Math.sin(b) * Math.sin(a))));
}
def code(r, a, b): return r * (math.sin(b) / ((math.cos(b) * math.cos(a)) - (math.sin(b) * math.sin(a))))
function code(r, a, b) return Float64(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.1%
associate-/l*77.1%
+-commutative77.1%
Simplified77.1%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (* r (/ (sin b) (fma (cos b) (cos a) 0.0))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(cos(b), cos(a), 0.0));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(cos(b), cos(a), 0.0))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\cos b, \cos a, 0\right)}
\end{array}
Initial program 77.1%
associate-/l*77.1%
+-commutative77.1%
Simplified77.1%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.5%
Applied egg-rr99.5%
add-sqr-sqrt50.9%
sqrt-unprod87.8%
sqr-neg87.8%
sqrt-unprod36.9%
add-sqr-sqrt77.2%
sin-mult78.2%
div-sub78.2%
Applied egg-rr78.2%
+-inverses78.2%
Simplified78.2%
(FPCore (r a b) :precision binary64 (if (or (<= b -2.8e+14) (not (<= b 2.8e-5))) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -2.8e+14) || !(b <= 2.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 ((b <= (-2.8d+14)) .or. (.not. (b <= 2.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 ((b <= -2.8e+14) || !(b <= 2.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 (b <= -2.8e+14) or not (b <= 2.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 ((b <= -2.8e+14) || !(b <= 2.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 ((b <= -2.8e+14) || ~((b <= 2.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[Or[LessEqual[b, -2.8e+14], N[Not[LessEqual[b, 2.8e-5]], $MachinePrecision]], 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}\;b \leq -2.8 \cdot 10^{+14} \lor \neg \left(b \leq 2.8 \cdot 10^{-5}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if b < -2.8e14 or 2.79999999999999996e-5 < b Initial program 57.6%
associate-/l*57.7%
+-commutative57.7%
Simplified57.7%
Taylor expanded in a around 0 58.5%
if -2.8e14 < b < 2.79999999999999996e-5Initial program 97.5%
associate-/l*97.4%
+-commutative97.4%
Simplified97.4%
Taylor expanded in b around 0 97.3%
Final simplification77.4%
(FPCore (r a b) :precision binary64 (if (<= b -2.8e+14) (* r (/ (sin b) (cos b))) (if (<= b 8.5e-6) (/ (* r (sin b)) (cos a)) (/ r (/ (cos b) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.8e+14) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 8.5e-6) {
tmp = (r * sin(b)) / cos(a);
} else {
tmp = r / (cos(b) / 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 <= (-2.8d+14)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 8.5d-6) then
tmp = (r * sin(b)) / cos(a)
else
tmp = r / (cos(b) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.8e+14) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 8.5e-6) {
tmp = (r * Math.sin(b)) / Math.cos(a);
} else {
tmp = r / (Math.cos(b) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.8e+14: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 8.5e-6: tmp = (r * math.sin(b)) / math.cos(a) else: tmp = r / (math.cos(b) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.8e+14) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 8.5e-6) tmp = Float64(Float64(r * sin(b)) / cos(a)); else tmp = Float64(r / Float64(cos(b) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.8e+14) tmp = r * (sin(b) / cos(b)); elseif (b <= 8.5e-6) tmp = (r * sin(b)) / cos(a); else tmp = r / (cos(b) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.8e+14], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-6], N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+14}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-6}:\\
\;\;\;\;\frac{r \cdot \sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\end{array}
\end{array}
if b < -2.8e14Initial program 54.9%
associate-/l*55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in a around 0 55.8%
if -2.8e14 < b < 8.4999999999999999e-6Initial program 97.5%
+-commutative97.5%
Simplified97.5%
Taylor expanded in b around 0 97.3%
if 8.4999999999999999e-6 < b Initial program 60.4%
associate-/l*60.4%
+-commutative60.4%
Simplified60.4%
clear-num60.5%
un-div-inv60.5%
Applied egg-rr60.5%
Taylor expanded in a around 0 61.4%
(FPCore (r a b) :precision binary64 (if (<= b -2.8e+14) (* r (/ (sin b) (cos b))) (if (<= b 2e-5) (* r (/ (sin b) (cos a))) (/ r (/ (cos b) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -2.8e+14) {
tmp = r * (sin(b) / cos(b));
} else if (b <= 2e-5) {
tmp = r * (sin(b) / cos(a));
} else {
tmp = r / (cos(b) / 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 <= (-2.8d+14)) then
tmp = r * (sin(b) / cos(b))
else if (b <= 2d-5) then
tmp = r * (sin(b) / cos(a))
else
tmp = r / (cos(b) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -2.8e+14) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else if (b <= 2e-5) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else {
tmp = r / (Math.cos(b) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -2.8e+14: tmp = r * (math.sin(b) / math.cos(b)) elif b <= 2e-5: tmp = r * (math.sin(b) / math.cos(a)) else: tmp = r / (math.cos(b) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -2.8e+14) tmp = Float64(r * Float64(sin(b) / cos(b))); elseif (b <= 2e-5) tmp = Float64(r * Float64(sin(b) / cos(a))); else tmp = Float64(r / Float64(cos(b) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -2.8e+14) tmp = r * (sin(b) / cos(b)); elseif (b <= 2e-5) tmp = r * (sin(b) / cos(a)); else tmp = r / (cos(b) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -2.8e+14], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+14}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\end{array}
\end{array}
if b < -2.8e14Initial program 54.9%
associate-/l*55.0%
+-commutative55.0%
Simplified55.0%
Taylor expanded in a around 0 55.8%
if -2.8e14 < b < 2.00000000000000016e-5Initial program 97.5%
associate-/l*97.4%
+-commutative97.4%
Simplified97.4%
Taylor expanded in b around 0 97.3%
if 2.00000000000000016e-5 < b Initial program 60.4%
associate-/l*60.4%
+-commutative60.4%
Simplified60.4%
clear-num60.5%
un-div-inv60.5%
Applied egg-rr60.5%
Taylor expanded in a around 0 61.4%
(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.1%
associate-/l*77.1%
+-commutative77.1%
Simplified77.1%
(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.1%
associate-/l*77.1%
+-commutative77.1%
Simplified77.1%
Taylor expanded in b around 0 53.7%
(FPCore (r a b) :precision binary64 (if (or (<= b -90000.0) (not (<= b 16.5))) (* r (sin b)) (/ (* r b) (cos (+ b a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -90000.0) || !(b <= 16.5)) {
tmp = r * sin(b);
} else {
tmp = (r * b) / cos((b + a));
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b <= (-90000.0d0)) .or. (.not. (b <= 16.5d0))) then
tmp = r * sin(b)
else
tmp = (r * b) / cos((b + a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -90000.0) || !(b <= 16.5)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos((b + a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -90000.0) or not (b <= 16.5): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos((b + a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -90000.0) || !(b <= 16.5)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(Float64(b + a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -90000.0) || ~((b <= 16.5))) tmp = r * sin(b); else tmp = (r * b) / cos((b + a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -90000.0], N[Not[LessEqual[b, 16.5]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -90000 \lor \neg \left(b \leq 16.5\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(b + a\right)}\\
\end{array}
\end{array}
if b < -9e4 or 16.5 < b Initial program 57.2%
+-commutative57.2%
Simplified57.2%
Taylor expanded in b around 0 11.9%
Taylor expanded in a around 0 13.2%
Simplified13.2%
if -9e4 < b < 16.5Initial program 98.0%
+-commutative98.0%
Simplified98.0%
Taylor expanded in b around 0 97.5%
Final simplification54.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -43.0) (not (<= b 7.8))) (* r (sin b)) (/ (* r b) (cos a))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -43.0) || !(b <= 7.8)) {
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 <= (-43.0d0)) .or. (.not. (b <= 7.8d0))) 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 <= -43.0) || !(b <= 7.8)) {
tmp = r * Math.sin(b);
} else {
tmp = (r * b) / Math.cos(a);
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -43.0) or not (b <= 7.8): tmp = r * math.sin(b) else: tmp = (r * b) / math.cos(a) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -43.0) || !(b <= 7.8)) tmp = Float64(r * sin(b)); else tmp = Float64(Float64(r * b) / cos(a)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -43.0) || ~((b <= 7.8))) tmp = r * sin(b); else tmp = (r * b) / cos(a); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -43.0], N[Not[LessEqual[b, 7.8]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(N[(r * b), $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -43 \lor \neg \left(b \leq 7.8\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;\frac{r \cdot b}{\cos a}\\
\end{array}
\end{array}
if b < -43 or 7.79999999999999982 < b Initial program 57.2%
+-commutative57.2%
Simplified57.2%
Taylor expanded in b around 0 11.9%
Taylor expanded in a around 0 13.2%
Simplified13.2%
if -43 < b < 7.79999999999999982Initial program 98.0%
associate-/l*97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 97.5%
Final simplification54.4%
(FPCore (r a b) :precision binary64 (if (or (<= b -43.0) (not (<= b 8.5))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -43.0) || !(b <= 8.5)) {
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 <= (-43.0d0)) .or. (.not. (b <= 8.5d0))) 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 <= -43.0) || !(b <= 8.5)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -43.0) or not (b <= 8.5): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -43.0) || !(b <= 8.5)) 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 <= -43.0) || ~((b <= 8.5))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -43.0], N[Not[LessEqual[b, 8.5]], $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 -43 \lor \neg \left(b \leq 8.5\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -43 or 8.5 < b Initial program 57.2%
+-commutative57.2%
Simplified57.2%
Taylor expanded in b around 0 11.9%
Taylor expanded in a around 0 13.2%
Simplified13.2%
if -43 < b < 8.5Initial program 98.0%
associate-/l*97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in b around 0 97.5%
Final simplification54.3%
(FPCore (r a b) :precision binary64 (* r (sin b)))
double code(double r, double a, double b) {
return r * sin(b);
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = r * sin(b)
end function
public static double code(double r, double a, double b) {
return r * Math.sin(b);
}
def code(r, a, b): return r * math.sin(b)
function code(r, a, b) return Float64(r * sin(b)) end
function tmp = code(r, a, b) tmp = r * sin(b); end
code[r_, a_, b_] := N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \sin b
\end{array}
Initial program 77.1%
+-commutative77.1%
Simplified77.1%
Taylor expanded in b around 0 53.7%
Taylor expanded in a around 0 40.1%
Simplified40.1%
Final simplification40.1%
(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.1%
associate-/l*77.1%
+-commutative77.1%
Simplified77.1%
Taylor expanded in b around 0 49.3%
Taylor expanded in a around 0 35.2%
herbie shell --seed 2024137
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))