
(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 13 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)) (- (* (cos b) (cos a)) (* (sin a) (sin b)))))
double code(double r, double a, double b) {
return (r * sin(b)) / ((cos(b) * cos(a)) - (sin(a) * 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)) / ((cos(b) * cos(a)) - (sin(a) * sin(b)))
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(a) * Math.sin(b)));
}
def code(r, a, b): return (r * math.sin(b)) / ((math.cos(b) * math.cos(a)) - (math.sin(a) * math.sin(b)))
function code(r, a, b) return Float64(Float64(r * sin(b)) / Float64(Float64(cos(b) * cos(a)) - Float64(sin(a) * sin(b)))) end
function tmp = code(r, a, b) tmp = (r * sin(b)) / ((cos(b) * cos(a)) - (sin(a) * sin(b))); end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[a], $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\cos b \cdot \cos a - \sin a \cdot \sin b}
\end{array}
Initial program 80.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.9
Applied rewrites80.9%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (/ (* r (sin b)) (fma (- (sin a)) (sin b) (* (cos b) (cos a)))))
double code(double r, double a, double b) {
return (r * sin(b)) / fma(-sin(a), sin(b), (cos(b) * cos(a)));
}
function code(r, a, b) return Float64(Float64(r * sin(b)) / fma(Float64(-sin(a)), sin(b), Float64(cos(b) * cos(a)))) end
code[r_, a_, b_] := N[(N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision] / N[((-N[Sin[a], $MachinePrecision]) * N[Sin[b], $MachinePrecision] + N[(N[Cos[b], $MachinePrecision] * N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r \cdot \sin b}{\mathsf{fma}\left(-\sin a, \sin b, \cos b \cdot \cos a\right)}
\end{array}
Initial program 80.9%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in r around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (r a b) :precision binary64 (* 2.0 (/ (* (cos (- a b)) (* r (sin b))) (+ (cos (- b (- a (+ a b)))) (cos (- (- (- b a) b) a))))))
double code(double r, double a, double b) {
return 2.0 * ((cos((a - b)) * (r * sin(b))) / (cos((b - (a - (a + b)))) + cos((((b - a) - 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 = 2.0d0 * ((cos((a - b)) * (r * sin(b))) / (cos((b - (a - (a + b)))) + cos((((b - a) - b) - a))))
end function
public static double code(double r, double a, double b) {
return 2.0 * ((Math.cos((a - b)) * (r * Math.sin(b))) / (Math.cos((b - (a - (a + b)))) + Math.cos((((b - a) - b) - a))));
}
def code(r, a, b): return 2.0 * ((math.cos((a - b)) * (r * math.sin(b))) / (math.cos((b - (a - (a + b)))) + math.cos((((b - a) - b) - a))))
function code(r, a, b) return Float64(2.0 * Float64(Float64(cos(Float64(a - b)) * Float64(r * sin(b))) / Float64(cos(Float64(b - Float64(a - Float64(a + b)))) + cos(Float64(Float64(Float64(b - a) - b) - a))))) end
function tmp = code(r, a, b) tmp = 2.0 * ((cos((a - b)) * (r * sin(b))) / (cos((b - (a - (a + b)))) + cos((((b - a) - b) - a)))); end
code[r_, a_, b_] := N[(2.0 * N[(N[(N[Cos[N[(a - b), $MachinePrecision]], $MachinePrecision] * N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(b - N[(a - N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[(N[(b - a), $MachinePrecision] - b), $MachinePrecision] - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \frac{\cos \left(a - b\right) \cdot \left(r \cdot \sin b\right)}{\cos \left(b - \left(a - \left(a + b\right)\right)\right) + \cos \left(\left(\left(b - a\right) - b\right) - a\right)}
\end{array}
Initial program 80.9%
lift-cos.f64N/A
lift-+.f64N/A
cos-sumN/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Applied rewrites80.7%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f6481.3
Applied rewrites81.3%
Final simplification81.3%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (/ r (cos b)) (sin b)))) (if (<= b -0.0011) t_0 (if (<= b 7.2e-8) (* (/ b (cos a)) r) t_0))))
double code(double r, double a, double b) {
double t_0 = (r / cos(b)) * sin(b);
double tmp;
if (b <= -0.0011) {
tmp = t_0;
} else if (b <= 7.2e-8) {
tmp = (b / cos(a)) * r;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = (r / cos(b)) * sin(b)
if (b <= (-0.0011d0)) then
tmp = t_0
else if (b <= 7.2d-8) then
tmp = (b / cos(a)) * r
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (r / Math.cos(b)) * Math.sin(b);
double tmp;
if (b <= -0.0011) {
tmp = t_0;
} else if (b <= 7.2e-8) {
tmp = (b / Math.cos(a)) * r;
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (r / math.cos(b)) * math.sin(b) tmp = 0 if b <= -0.0011: tmp = t_0 elif b <= 7.2e-8: tmp = (b / math.cos(a)) * r else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(r / cos(b)) * sin(b)) tmp = 0.0 if (b <= -0.0011) tmp = t_0; elseif (b <= 7.2e-8) tmp = Float64(Float64(b / cos(a)) * r); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = (r / cos(b)) * sin(b); tmp = 0.0; if (b <= -0.0011) tmp = t_0; elseif (b <= 7.2e-8) tmp = (b / cos(a)) * r; else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(r / N[Cos[b], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -0.0011], t$95$0, If[LessEqual[b, 7.2e-8], N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{r}{\cos b} \cdot \sin b\\
\mathbf{if}\;b \leq -0.0011:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 7.2 \cdot 10^{-8}:\\
\;\;\;\;\frac{b}{\cos a} \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -0.00110000000000000007 or 7.19999999999999962e-8 < b Initial program 55.8%
Taylor expanded in a around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6456.6
Applied rewrites56.6%
if -0.00110000000000000007 < b < 7.19999999999999962e-8Initial program 99.2%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6499.2
Applied rewrites99.2%
Final simplification81.2%
(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}
Initial program 80.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.9
Applied rewrites80.9%
Final simplification80.9%
(FPCore (r a b) :precision binary64 (* (/ r (cos (+ a b))) (sin b)))
double code(double r, double a, double b) {
return (r / cos((a + b))) * 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 / cos((a + b))) * sin(b)
end function
public static double code(double r, double a, double b) {
return (r / Math.cos((a + b))) * Math.sin(b);
}
def code(r, a, b): return (r / math.cos((a + b))) * math.sin(b)
function code(r, a, b) return Float64(Float64(r / cos(Float64(a + b))) * sin(b)) end
function tmp = code(r, a, b) tmp = (r / cos((a + b))) * sin(b); end
code[r_, a_, b_] := N[(N[(r / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[b], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos \left(a + b\right)} \cdot \sin b
\end{array}
Initial program 80.9%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6480.9
Applied rewrites80.9%
(FPCore (r a b) :precision binary64 (* (/ (sin b) (cos (+ a b))) r))
double code(double r, double a, double b) {
return (sin(b) / cos((a + 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 = (sin(b) / cos((a + b))) * r
end function
public static double code(double r, double a, double b) {
return (Math.sin(b) / Math.cos((a + b))) * r;
}
def code(r, a, b): return (math.sin(b) / math.cos((a + b))) * r
function code(r, a, b) return Float64(Float64(sin(b) / cos(Float64(a + b))) * r) end
function tmp = code(r, a, b) tmp = (sin(b) / cos((a + b))) * r; end
code[r_, a_, b_] := N[(N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin b}{\cos \left(a + b\right)} \cdot r
\end{array}
Initial program 80.9%
Final simplification80.9%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (* (/ (sin b) 1.0) r)))
(if (<= b -1.05e+14)
t_0
(if (<= b 4.6)
(/ (* (* (fma -0.16666666666666666 (* b b) 1.0) r) b) (cos (+ a b)))
t_0))))
double code(double r, double a, double b) {
double t_0 = (sin(b) / 1.0) * r;
double tmp;
if (b <= -1.05e+14) {
tmp = t_0;
} else if (b <= 4.6) {
tmp = ((fma(-0.16666666666666666, (b * b), 1.0) * r) * b) / cos((a + b));
} else {
tmp = t_0;
}
return tmp;
}
function code(r, a, b) t_0 = Float64(Float64(sin(b) / 1.0) * r) tmp = 0.0 if (b <= -1.05e+14) tmp = t_0; elseif (b <= 4.6) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(b * b), 1.0) * r) * b) / cos(Float64(a + b))); else tmp = t_0; end return tmp end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(N[Sin[b], $MachinePrecision] / 1.0), $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -1.05e+14], t$95$0, If[LessEqual[b, 4.6], N[(N[(N[(N[(-0.16666666666666666 * N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision] * r), $MachinePrecision] * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{1} \cdot r\\
\mathbf{if}\;b \leq -1.05 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 4.6:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.16666666666666666, b \cdot b, 1\right) \cdot r\right) \cdot b}{\cos \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.05e14 or 4.5999999999999996 < b Initial program 55.2%
Taylor expanded in b around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f645.8
Applied rewrites5.8%
Taylor expanded in a around 0
Applied rewrites13.0%
if -1.05e14 < b < 4.5999999999999996Initial program 98.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
Taylor expanded in b around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification63.5%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (/ (sin b) 1.0) r))) (if (<= b -4.0) t_0 (if (<= b 260.0) (/ (* r b) (cos (+ a b))) t_0))))
double code(double r, double a, double b) {
double t_0 = (sin(b) / 1.0) * r;
double tmp;
if (b <= -4.0) {
tmp = t_0;
} else if (b <= 260.0) {
tmp = (r * b) / cos((a + b));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = (sin(b) / 1.0d0) * r
if (b <= (-4.0d0)) then
tmp = t_0
else if (b <= 260.0d0) then
tmp = (r * b) / cos((a + b))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (Math.sin(b) / 1.0) * r;
double tmp;
if (b <= -4.0) {
tmp = t_0;
} else if (b <= 260.0) {
tmp = (r * b) / Math.cos((a + b));
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (math.sin(b) / 1.0) * r tmp = 0 if b <= -4.0: tmp = t_0 elif b <= 260.0: tmp = (r * b) / math.cos((a + b)) else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(sin(b) / 1.0) * r) tmp = 0.0 if (b <= -4.0) tmp = t_0; elseif (b <= 260.0) tmp = Float64(Float64(r * b) / cos(Float64(a + b))); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = (sin(b) / 1.0) * r; tmp = 0.0; if (b <= -4.0) tmp = t_0; elseif (b <= 260.0) tmp = (r * b) / cos((a + b)); else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(N[Sin[b], $MachinePrecision] / 1.0), $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -4.0], t$95$0, If[LessEqual[b, 260.0], N[(N[(r * b), $MachinePrecision] / N[Cos[N[(a + b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{1} \cdot r\\
\mathbf{if}\;b \leq -4:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 260:\\
\;\;\;\;\frac{r \cdot b}{\cos \left(a + b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -4 or 260 < b Initial program 54.6%
Taylor expanded in b around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f646.0
Applied rewrites6.0%
Taylor expanded in a around 0
Applied rewrites12.9%
if -4 < b < 260Initial program 99.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
Taylor expanded in b around 0
lower-*.f6498.5
Applied rewrites98.5%
Final simplification63.4%
(FPCore (r a b) :precision binary64 (let* ((t_0 (* (/ (sin b) 1.0) r))) (if (<= b -4.8) t_0 (if (<= b 2.0) (* (/ b (cos a)) r) t_0))))
double code(double r, double a, double b) {
double t_0 = (sin(b) / 1.0) * r;
double tmp;
if (b <= -4.8) {
tmp = t_0;
} else if (b <= 2.0) {
tmp = (b / cos(a)) * r;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = (sin(b) / 1.0d0) * r
if (b <= (-4.8d0)) then
tmp = t_0
else if (b <= 2.0d0) then
tmp = (b / cos(a)) * r
else
tmp = t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = (Math.sin(b) / 1.0) * r;
double tmp;
if (b <= -4.8) {
tmp = t_0;
} else if (b <= 2.0) {
tmp = (b / Math.cos(a)) * r;
} else {
tmp = t_0;
}
return tmp;
}
def code(r, a, b): t_0 = (math.sin(b) / 1.0) * r tmp = 0 if b <= -4.8: tmp = t_0 elif b <= 2.0: tmp = (b / math.cos(a)) * r else: tmp = t_0 return tmp
function code(r, a, b) t_0 = Float64(Float64(sin(b) / 1.0) * r) tmp = 0.0 if (b <= -4.8) tmp = t_0; elseif (b <= 2.0) tmp = Float64(Float64(b / cos(a)) * r); else tmp = t_0; end return tmp end
function tmp_2 = code(r, a, b) t_0 = (sin(b) / 1.0) * r; tmp = 0.0; if (b <= -4.8) tmp = t_0; elseif (b <= 2.0) tmp = (b / cos(a)) * r; else tmp = t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[(N[Sin[b], $MachinePrecision] / 1.0), $MachinePrecision] * r), $MachinePrecision]}, If[LessEqual[b, -4.8], t$95$0, If[LessEqual[b, 2.0], N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{1} \cdot r\\
\mathbf{if}\;b \leq -4.8:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 2:\\
\;\;\;\;\frac{b}{\cos a} \cdot r\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -4.79999999999999982 or 2 < b Initial program 55.0%
Taylor expanded in b around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f646.0
Applied rewrites6.0%
Taylor expanded in a around 0
Applied rewrites12.8%
if -4.79999999999999982 < b < 2Initial program 99.3%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6499.0
Applied rewrites99.0%
Final simplification63.3%
(FPCore (r a b) :precision binary64 (* (/ b (cos a)) r))
double code(double r, double a, double b) {
return (b / cos(a)) * 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 / cos(a)) * r
end function
public static double code(double r, double a, double b) {
return (b / Math.cos(a)) * r;
}
def code(r, a, b): return (b / math.cos(a)) * r
function code(r, a, b) return Float64(Float64(b / cos(a)) * r) end
function tmp = code(r, a, b) tmp = (b / cos(a)) * r; end
code[r_, a_, b_] := N[(N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{\cos a} \cdot r
\end{array}
Initial program 80.9%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6459.5
Applied rewrites59.5%
Final simplification59.5%
(FPCore (r a b) :precision binary64 (* (/ r (cos a)) b))
double code(double r, double a, double b) {
return (r / 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 / cos(a)) * b
end function
public static double code(double r, double a, double b) {
return (r / Math.cos(a)) * b;
}
def code(r, a, b): return (r / math.cos(a)) * b
function code(r, a, b) return Float64(Float64(r / cos(a)) * b) end
function tmp = code(r, a, b) tmp = (r / cos(a)) * b; end
code[r_, a_, b_] := N[(N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\cos a} \cdot b
\end{array}
Initial program 80.9%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6480.9
Applied rewrites80.9%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f6459.5
Applied rewrites59.5%
(FPCore (r a b) :precision binary64 (* (/ b 1.0) r))
double code(double r, double a, double b) {
return (b / 1.0) * 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 / 1.0d0) * r
end function
public static double code(double r, double a, double b) {
return (b / 1.0) * r;
}
def code(r, a, b): return (b / 1.0) * r
function code(r, a, b) return Float64(Float64(b / 1.0) * r) end
function tmp = code(r, a, b) tmp = (b / 1.0) * r; end
code[r_, a_, b_] := N[(N[(b / 1.0), $MachinePrecision] * r), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{1} \cdot r
\end{array}
Initial program 80.9%
Taylor expanded in b around 0
lower-/.f64N/A
lower-cos.f6459.5
Applied rewrites59.5%
Taylor expanded in a around 0
Applied rewrites37.9%
Final simplification37.9%
herbie shell --seed 2024283
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))