
(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 15 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) (fma (sin b) (- (sin a)) (* (cos a) (cos b))))))
double code(double r, double a, double b) {
return r * (sin(b) / fma(sin(b), -sin(a), (cos(a) * cos(b))));
}
function code(r, a, b) return Float64(r * Float64(sin(b) / fma(sin(b), Float64(-sin(a)), Float64(cos(a) * cos(b))))) end
code[r_, a_, b_] := N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Sin[b], $MachinePrecision] * (-N[Sin[a], $MachinePrecision]) + N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{\sin b}{\mathsf{fma}\left(\sin b, -\sin a, \cos a \cdot \cos b\right)}
\end{array}
Initial program 75.7%
+-commutative75.7%
Simplified75.7%
cos-sum99.5%
sub-neg99.5%
Applied egg-rr99.5%
+-commutative99.5%
distribute-rgt-neg-in99.5%
fma-define99.5%
*-commutative99.5%
Simplified99.5%
(FPCore (r a b)
:precision binary64
(let* ((t_0 (/ (sin b) (cos (+ b a)))))
(if (<= t_0 -0.04)
(* r (/ (sin b) (- (cos b) (* (sin b) (sin a)))))
(* r t_0))))
double code(double r, double a, double b) {
double t_0 = sin(b) / cos((b + a));
double tmp;
if (t_0 <= -0.04) {
tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a))));
} else {
tmp = r * 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) / cos((b + a))
if (t_0 <= (-0.04d0)) then
tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a))))
else
tmp = r * t_0
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double t_0 = Math.sin(b) / Math.cos((b + a));
double tmp;
if (t_0 <= -0.04) {
tmp = r * (Math.sin(b) / (Math.cos(b) - (Math.sin(b) * Math.sin(a))));
} else {
tmp = r * t_0;
}
return tmp;
}
def code(r, a, b): t_0 = math.sin(b) / math.cos((b + a)) tmp = 0 if t_0 <= -0.04: tmp = r * (math.sin(b) / (math.cos(b) - (math.sin(b) * math.sin(a)))) else: tmp = r * t_0 return tmp
function code(r, a, b) t_0 = Float64(sin(b) / cos(Float64(b + a))) tmp = 0.0 if (t_0 <= -0.04) tmp = Float64(r * Float64(sin(b) / Float64(cos(b) - Float64(sin(b) * sin(a))))); else tmp = Float64(r * t_0); end return tmp end
function tmp_2 = code(r, a, b) t_0 = sin(b) / cos((b + a)); tmp = 0.0; if (t_0 <= -0.04) tmp = r * (sin(b) / (cos(b) - (sin(b) * sin(a)))); else tmp = r * t_0; end tmp_2 = tmp; end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.04], N[(r * N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] - N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin b}{\cos \left(b + a\right)}\\
\mathbf{if}\;t\_0 \leq -0.04:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b - \sin b \cdot \sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot t\_0\\
\end{array}
\end{array}
if (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) < -0.0400000000000000008Initial program 52.0%
+-commutative52.0%
Simplified52.0%
cos-sum99.3%
Applied egg-rr99.2%
Taylor expanded in a around 0 58.3%
if -0.0400000000000000008 < (/.f64 (sin.f64 b) (cos.f64 (+.f64 a b))) Initial program 84.9%
Final simplification77.4%
(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.7%
associate-*r/75.6%
+-commutative75.6%
Simplified75.6%
*-commutative75.6%
associate-/l*75.7%
Applied egg-rr75.7%
cos-sum99.5%
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(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.7%
+-commutative75.7%
Simplified75.7%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -240000.0) (not (<= b 2.75e-11))) (* (sin b) (/ r (cos b))) (* r (/ (sin b) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -240000.0) || !(b <= 2.75e-11)) {
tmp = sin(b) * (r / 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 <= (-240000.0d0)) .or. (.not. (b <= 2.75d-11))) then
tmp = sin(b) * (r / 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 <= -240000.0) || !(b <= 2.75e-11)) {
tmp = Math.sin(b) * (r / Math.cos(b));
} else {
tmp = r * (Math.sin(b) / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -240000.0) or not (b <= 2.75e-11): tmp = math.sin(b) * (r / math.cos(b)) else: tmp = r * (math.sin(b) / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -240000.0) || !(b <= 2.75e-11)) tmp = Float64(sin(b) * Float64(r / 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 <= -240000.0) || ~((b <= 2.75e-11))) tmp = sin(b) * (r / cos(b)); else tmp = r * (sin(b) / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -240000.0], N[Not[LessEqual[b, 2.75e-11]], $MachinePrecision]], N[(N[Sin[b], $MachinePrecision] * N[(r / 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 -240000 \lor \neg \left(b \leq 2.75 \cdot 10^{-11}\right):\\
\;\;\;\;\sin b \cdot \frac{r}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if b < -2.4e5 or 2.74999999999999987e-11 < b Initial program 55.6%
associate-*r/55.5%
+-commutative55.5%
Simplified55.5%
*-commutative55.5%
associate-/l*55.6%
Applied egg-rr55.6%
Taylor expanded in a around 0 57.1%
if -2.4e5 < b < 2.74999999999999987e-11Initial program 98.0%
+-commutative98.0%
Simplified98.0%
Taylor expanded in b around 0 98.0%
Final simplification76.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -240000.0) (not (<= b 2.75e-11))) (* r (/ (sin b) (cos b))) (* r (/ (sin b) (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -240000.0) || !(b <= 2.75e-11)) {
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 <= (-240000.0d0)) .or. (.not. (b <= 2.75d-11))) 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 <= -240000.0) || !(b <= 2.75e-11)) {
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 <= -240000.0) or not (b <= 2.75e-11): 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 <= -240000.0) || !(b <= 2.75e-11)) 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 <= -240000.0) || ~((b <= 2.75e-11))) 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, -240000.0], N[Not[LessEqual[b, 2.75e-11]], $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 -240000 \lor \neg \left(b \leq 2.75 \cdot 10^{-11}\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos a}\\
\end{array}
\end{array}
if b < -2.4e5 or 2.74999999999999987e-11 < b Initial program 55.6%
+-commutative55.6%
Simplified55.6%
Taylor expanded in a around 0 57.0%
associate-/l*57.1%
Simplified57.1%
if -2.4e5 < b < 2.74999999999999987e-11Initial program 98.0%
+-commutative98.0%
Simplified98.0%
Taylor expanded in b around 0 98.0%
Final simplification76.4%
(FPCore (r a b) :precision binary64 (* (sin b) (/ r (cos (+ b a)))))
double code(double r, double a, double b) {
return sin(b) * (r / cos((b + a)));
}
real(8) function code(r, a, b)
real(8), intent (in) :: r
real(8), intent (in) :: a
real(8), intent (in) :: b
code = sin(b) * (r / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return Math.sin(b) * (r / Math.cos((b + a)));
}
def code(r, a, b): return math.sin(b) * (r / math.cos((b + a)))
function code(r, a, b) return Float64(sin(b) * Float64(r / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = sin(b) * (r / cos((b + a))); end
code[r_, a_, b_] := N[(N[Sin[b], $MachinePrecision] * N[(r / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin b \cdot \frac{r}{\cos \left(b + a\right)}
\end{array}
Initial program 75.7%
associate-*r/75.6%
+-commutative75.6%
Simplified75.6%
*-commutative75.6%
associate-/l*75.7%
Applied egg-rr75.7%
(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.7%
Final simplification75.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 75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in b around 0 53.0%
(FPCore (r a b) :precision binary64 (* r (/ b (cos (+ b a)))))
double code(double r, double a, double b) {
return r * (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 * (b / cos((b + a)))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos((b + a)));
}
def code(r, a, b): return r * (b / math.cos((b + a)))
function code(r, a, b) return Float64(r * Float64(b / cos(Float64(b + a)))) end
function tmp = code(r, a, b) tmp = r * (b / cos((b + a))); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[N[(b + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos \left(b + a\right)}
\end{array}
Initial program 75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in b around 0 49.1%
(FPCore (r a b) :precision binary64 (* r (/ b (cos a))))
double code(double r, double a, double b) {
return r * (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 * (b / cos(a))
end function
public static double code(double r, double a, double b) {
return r * (b / Math.cos(a));
}
def code(r, a, b): return r * (b / math.cos(a))
function code(r, a, b) return Float64(r * Float64(b / cos(a))) end
function tmp = code(r, a, b) tmp = r * (b / cos(a)); end
code[r_, a_, b_] := N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
r \cdot \frac{b}{\cos a}
\end{array}
Initial program 75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in b around 0 48.8%
*-commutative48.8%
associate-/l*48.8%
Simplified48.8%
(FPCore (r a b) :precision binary64 (* b (/ r (cos a))))
double code(double r, double a, double b) {
return b * (r / 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 = b * (r / cos(a))
end function
public static double code(double r, double a, double b) {
return b * (r / Math.cos(a));
}
def code(r, a, b): return b * (r / math.cos(a))
function code(r, a, b) return Float64(b * Float64(r / cos(a))) end
function tmp = code(r, a, b) tmp = b * (r / cos(a)); end
code[r_, a_, b_] := N[(b * N[(r / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{r}{\cos a}
\end{array}
Initial program 75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in b around 0 48.8%
associate-/l*48.8%
Simplified48.8%
(FPCore (r a b) :precision binary64 (/ 1.0 (+ (* -0.3333333333333333 (/ b r)) (/ 1.0 (* r b)))))
double code(double r, double a, double b) {
return 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (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 = 1.0d0 / (((-0.3333333333333333d0) * (b / r)) + (1.0d0 / (r * b)))
end function
public static double code(double r, double a, double b) {
return 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (r * b)));
}
def code(r, a, b): return 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (r * b)))
function code(r, a, b) return Float64(1.0 / Float64(Float64(-0.3333333333333333 * Float64(b / r)) + Float64(1.0 / Float64(r * b)))) end
function tmp = code(r, a, b) tmp = 1.0 / ((-0.3333333333333333 * (b / r)) + (1.0 / (r * b))); end
code[r_, a_, b_] := N[(1.0 / N[(N[(-0.3333333333333333 * N[(b / r), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(r * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{-0.3333333333333333 \cdot \frac{b}{r} + \frac{1}{r \cdot b}}
\end{array}
Initial program 75.7%
+-commutative75.7%
Simplified75.7%
associate-*r/75.6%
clear-num75.1%
Applied egg-rr75.1%
Taylor expanded in b around 0 49.4%
Taylor expanded in a around 0 33.0%
Taylor expanded in a around 0 34.9%
Final simplification34.9%
(FPCore (r a b) :precision binary64 (/ r (- (- (/ 1.0 b) (* b 0.3333333333333333)) a)))
double code(double r, double a, double b) {
return r / (((1.0 / b) - (b * 0.3333333333333333)) - 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 / (((1.0d0 / b) - (b * 0.3333333333333333d0)) - a)
end function
public static double code(double r, double a, double b) {
return r / (((1.0 / b) - (b * 0.3333333333333333)) - a);
}
def code(r, a, b): return r / (((1.0 / b) - (b * 0.3333333333333333)) - a)
function code(r, a, b) return Float64(r / Float64(Float64(Float64(1.0 / b) - Float64(b * 0.3333333333333333)) - a)) end
function tmp = code(r, a, b) tmp = r / (((1.0 / b) - (b * 0.3333333333333333)) - a); end
code[r_, a_, b_] := N[(r / N[(N[(N[(1.0 / b), $MachinePrecision] - N[(b * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\left(\frac{1}{b} - b \cdot 0.3333333333333333\right) - a}
\end{array}
Initial program 75.7%
+-commutative75.7%
Simplified75.7%
associate-*r/75.6%
clear-num75.1%
Applied egg-rr75.1%
Taylor expanded in b around 0 49.4%
Taylor expanded in a around 0 33.0%
Taylor expanded in r around -inf 34.6%
associate-*r/34.6%
neg-mul-134.6%
associate--l+34.6%
*-commutative34.6%
Simplified34.6%
Final simplification34.6%
(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.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in b around 0 48.8%
associate-/l*48.8%
Simplified48.8%
Taylor expanded in a around 0 34.6%
*-commutative34.6%
Simplified34.6%
herbie shell --seed 2024150
(FPCore (r a b)
:name "rsin B (should all be same)"
:precision binary64
(* r (/ (sin b) (cos (+ a b)))))