
(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 (* 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 76.7%
associate-/l*76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
cancel-sign-sub-inv99.5%
fma-define99.6%
Applied egg-rr99.6%
Final simplification99.6%
(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 76.7%
associate-/l*76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
cos-sum99.5%
Applied egg-rr99.5%
(FPCore (r a b) :precision binary64 (if (or (<= a -550.0) (not (<= a 0.0001))) (* r (/ (sin b) (cos a))) (* r (/ (sin b) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if ((a <= -550.0) || !(a <= 0.0001)) {
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 <= (-550.0d0)) .or. (.not. (a <= 0.0001d0))) 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 <= -550.0) || !(a <= 0.0001)) {
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 <= -550.0) or not (a <= 0.0001): 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 <= -550.0) || !(a <= 0.0001)) 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 <= -550.0) || ~((a <= 0.0001))) 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, -550.0], N[Not[LessEqual[a, 0.0001]], $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 -550 \lor \neg \left(a \leq 0.0001\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if a < -550 or 1.00000000000000005e-4 < a Initial program 55.9%
associate-/l*56.0%
remove-double-neg56.0%
remove-double-neg56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in b around 0 55.9%
if -550 < a < 1.00000000000000005e-4Initial program 97.7%
associate-/l*97.8%
remove-double-neg97.8%
remove-double-neg97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in a around 0 97.7%
associate-/l*97.8%
Simplified97.8%
Final simplification76.7%
(FPCore (r a b) :precision binary64 (if (<= a -550.0) (* r (/ (sin b) (cos a))) (if (<= a 5.5e-5) (* r (/ (sin b) (cos b))) (/ r (/ (cos a) (sin b))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -550.0) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 5.5e-5) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = r / (cos(a) / 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 (a <= (-550.0d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 5.5d-5) then
tmp = r * (sin(b) / cos(b))
else
tmp = r / (cos(a) / sin(b))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -550.0) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 5.5e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r / (Math.cos(a) / Math.sin(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -550.0: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 5.5e-5: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r / (math.cos(a) / math.sin(b)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -550.0) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 5.5e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(r / Float64(cos(a) / sin(b))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -550.0) tmp = r * (sin(b) / cos(a)); elseif (a <= 5.5e-5) tmp = r * (sin(b) / cos(b)); else tmp = r / (cos(a) / sin(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -550.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.5e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r / N[(N[Cos[a], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -550:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\frac{r}{\frac{\cos a}{\sin b}}\\
\end{array}
\end{array}
if a < -550Initial program 56.8%
associate-/l*56.9%
remove-double-neg56.9%
remove-double-neg56.9%
+-commutative56.9%
Simplified56.9%
Taylor expanded in b around 0 57.2%
if -550 < a < 5.5000000000000002e-5Initial program 97.7%
associate-/l*97.8%
remove-double-neg97.8%
remove-double-neg97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in a around 0 97.7%
associate-/l*97.8%
Simplified97.8%
if 5.5000000000000002e-5 < a Initial program 55.0%
associate-/l*55.0%
remove-double-neg55.0%
remove-double-neg55.0%
+-commutative55.0%
Simplified55.0%
log1p-expm1-u55.0%
Applied egg-rr55.0%
Taylor expanded in b around 0 54.4%
log1p-expm1-u54.6%
clear-num54.6%
un-div-inv54.7%
Applied egg-rr54.7%
(FPCore (r a b) :precision binary64 (if (<= a -550.0) (* r (/ (sin b) (cos a))) (if (<= a 4e-5) (* r (/ (sin b) (cos b))) (* (sin b) (/ r (cos a))))))
double code(double r, double a, double b) {
double tmp;
if (a <= -550.0) {
tmp = r * (sin(b) / cos(a));
} else if (a <= 4e-5) {
tmp = r * (sin(b) / cos(b));
} else {
tmp = sin(b) * (r / 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 <= (-550.0d0)) then
tmp = r * (sin(b) / cos(a))
else if (a <= 4d-5) then
tmp = r * (sin(b) / cos(b))
else
tmp = sin(b) * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (a <= -550.0) {
tmp = r * (Math.sin(b) / Math.cos(a));
} else if (a <= 4e-5) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = Math.sin(b) * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if a <= -550.0: tmp = r * (math.sin(b) / math.cos(a)) elif a <= 4e-5: tmp = r * (math.sin(b) / math.cos(b)) else: tmp = math.sin(b) * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (a <= -550.0) tmp = Float64(r * Float64(sin(b) / cos(a))); elseif (a <= 4e-5) tmp = Float64(r * Float64(sin(b) / cos(b))); else tmp = Float64(sin(b) * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (a <= -550.0) tmp = r * (sin(b) / cos(a)); elseif (a <= 4e-5) tmp = r * (sin(b) / cos(b)); else tmp = sin(b) * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[a, -550.0], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 4e-5], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -550:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\mathbf{elif}\;a \leq 4 \cdot 10^{-5}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;\sin b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if a < -550Initial program 56.8%
associate-/l*56.9%
remove-double-neg56.9%
remove-double-neg56.9%
+-commutative56.9%
Simplified56.9%
Taylor expanded in b around 0 57.2%
if -550 < a < 4.00000000000000033e-5Initial program 97.7%
associate-/l*97.8%
remove-double-neg97.8%
remove-double-neg97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in a around 0 97.7%
associate-/l*97.8%
Simplified97.8%
if 4.00000000000000033e-5 < a Initial program 55.0%
+-commutative55.0%
Simplified55.0%
*-commutative55.0%
associate-/l*55.1%
Applied egg-rr55.1%
Taylor expanded in b around 0 54.6%
(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 76.7%
associate-/l*76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
(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 76.7%
associate-/l*76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 55.1%
(FPCore (r a b) :precision binary64 (if (or (<= b -590.0) (not (<= b 1.7e+15))) (* r (sin b)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -590.0) || !(b <= 1.7e+15)) {
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 <= (-590.0d0)) .or. (.not. (b <= 1.7d+15))) 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 <= -590.0) || !(b <= 1.7e+15)) {
tmp = r * Math.sin(b);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -590.0) or not (b <= 1.7e+15): tmp = r * math.sin(b) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -590.0) || !(b <= 1.7e+15)) 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 <= -590.0) || ~((b <= 1.7e+15))) tmp = r * sin(b); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -590.0], N[Not[LessEqual[b, 1.7e+15]], $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 -590 \lor \neg \left(b \leq 1.7 \cdot 10^{+15}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -590 or 1.7e15 < b Initial program 55.6%
associate-/l*55.7%
remove-double-neg55.7%
remove-double-neg55.7%
+-commutative55.7%
Simplified55.7%
log1p-expm1-u54.8%
Applied egg-rr54.8%
Taylor expanded in b around 0 13.2%
Taylor expanded in a around 0 13.6%
if -590 < b < 1.7e15Initial program 97.1%
associate-/l*97.1%
remove-double-neg97.1%
remove-double-neg97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 95.6%
*-commutative95.6%
associate-/l*95.7%
Simplified95.7%
Final simplification55.3%
(FPCore (r a b) :precision binary64 (if (or (<= b -590.0) (not (<= b 1.7e+15))) (* r (sin b)) (* b (/ r (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -590.0) || !(b <= 1.7e+15)) {
tmp = r * sin(b);
} else {
tmp = b * (r / 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 <= (-590.0d0)) .or. (.not. (b <= 1.7d+15))) then
tmp = r * sin(b)
else
tmp = b * (r / cos(a))
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if ((b <= -590.0) || !(b <= 1.7e+15)) {
tmp = r * Math.sin(b);
} else {
tmp = b * (r / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -590.0) or not (b <= 1.7e+15): tmp = r * math.sin(b) else: tmp = b * (r / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -590.0) || !(b <= 1.7e+15)) tmp = Float64(r * sin(b)); else tmp = Float64(b * Float64(r / cos(a))); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if ((b <= -590.0) || ~((b <= 1.7e+15))) tmp = r * sin(b); else tmp = b * (r / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -590.0], N[Not[LessEqual[b, 1.7e+15]], $MachinePrecision]], N[(r * N[Sin[b], $MachinePrecision]), $MachinePrecision], N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -590 \lor \neg \left(b \leq 1.7 \cdot 10^{+15}\right):\\
\;\;\;\;r \cdot \sin b\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{r}{\cos a}\\
\end{array}
\end{array}
if b < -590 or 1.7e15 < b Initial program 55.6%
associate-/l*55.7%
remove-double-neg55.7%
remove-double-neg55.7%
+-commutative55.7%
Simplified55.7%
log1p-expm1-u54.8%
Applied egg-rr54.8%
Taylor expanded in b around 0 13.2%
Taylor expanded in a around 0 13.6%
if -590 < b < 1.7e15Initial program 97.1%
associate-/l*97.1%
remove-double-neg97.1%
remove-double-neg97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 95.6%
associate-/l*95.6%
Simplified95.6%
Final simplification55.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 76.7%
associate-/l*76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
log1p-expm1-u76.3%
Applied egg-rr76.3%
Taylor expanded in b around 0 55.0%
Taylor expanded in a around 0 38.0%
(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 76.7%
associate-/l*76.7%
remove-double-neg76.7%
remove-double-neg76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in b around 0 50.5%
associate-/l*50.5%
Simplified50.5%
Taylor expanded in a around 0 33.4%
*-commutative33.4%
Simplified33.4%
(FPCore (r a b) :precision binary64 0.0)
double code(double r, double a, double b) {
return 0.0;
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.0d0
end function
public static double code(double r, double a, double b) {
return 0.0;
}
def code(r, a, b): return 0.0
function code(r, a, b) return 0.0 end
function tmp = code(r, a, b) tmp = 0.0; end
code[r_, a_, b_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 76.7%
+-commutative76.7%
Simplified76.7%
add-log-exp18.6%
exp-prod17.9%
Applied egg-rr17.9%
Taylor expanded in r around 0 17.5%
*-commutative17.5%
Simplified17.5%
Taylor expanded in r around 0 17.5%
Taylor expanded in b around 0 17.5%
herbie shell --seed 2024182
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))