
(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 11 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 b) (sin a))))
(*
(/ (sin b) (+ (- (* (cos a) (cos b)) t_0) (fma (sin a) (- (sin b)) t_0)))
r)))
double code(double r, double a, double b) {
double t_0 = sin(b) * sin(a);
return (sin(b) / (((cos(a) * cos(b)) - t_0) + fma(sin(a), -sin(b), t_0))) * r;
}
function code(r, a, b) t_0 = Float64(sin(b) * sin(a)) return Float64(Float64(sin(b) / Float64(Float64(Float64(cos(a) * cos(b)) - t_0) + fma(sin(a), Float64(-sin(b)), t_0))) * r) end
code[r_, a_, b_] := Block[{t$95$0 = N[(N[Sin[b], $MachinePrecision] * N[Sin[a], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Sin[b], $MachinePrecision] / N[(N[(N[(N[Cos[a], $MachinePrecision] * N[Cos[b], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] + N[(N[Sin[a], $MachinePrecision] * (-N[Sin[b], $MachinePrecision]) + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin b \cdot \sin a\\
\frac{\sin b}{\left(\cos a \cdot \cos b - t_0\right) + \mathsf{fma}\left(\sin a, -\sin b, t_0\right)} \cdot r
\end{array}
\end{array}
Initial program 74.3%
associate-*r/74.3%
*-commutative74.3%
+-commutative74.3%
Simplified74.3%
cos-sum99.5%
Applied egg-rr99.5%
*-un-lft-identity99.5%
prod-diff99.5%
Applied egg-rr99.5%
*-rgt-identity99.5%
fma-neg99.5%
*-commutative99.5%
*-commutative99.5%
fma-udef99.5%
*-rgt-identity99.5%
distribute-lft-neg-in99.5%
*-commutative99.5%
*-rgt-identity99.5%
fma-def99.5%
*-commutative99.5%
Simplified99.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 74.3%
associate-*r/74.3%
*-commutative74.3%
+-commutative74.3%
Simplified74.3%
cos-sum99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (r a b) :precision binary64 (if (or (<= b -0.022) (not (<= b 0.00065))) (* r (/ (sin b) (cos b))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if ((b <= -0.022) || !(b <= 0.00065)) {
tmp = r * (sin(b) / cos(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 <= (-0.022d0)) .or. (.not. (b <= 0.00065d0))) then
tmp = r * (sin(b) / cos(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 <= -0.022) || !(b <= 0.00065)) {
tmp = r * (Math.sin(b) / Math.cos(b));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if (b <= -0.022) or not (b <= 0.00065): tmp = r * (math.sin(b) / math.cos(b)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if ((b <= -0.022) || !(b <= 0.00065)) tmp = Float64(r * Float64(sin(b) / cos(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 <= -0.022) || ~((b <= 0.00065))) tmp = r * (sin(b) / cos(b)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[Or[LessEqual[b, -0.022], N[Not[LessEqual[b, 0.00065]], $MachinePrecision]], N[(r * N[(N[Sin[b], $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.022 \lor \neg \left(b \leq 0.00065\right):\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -0.021999999999999999 or 6.4999999999999997e-4 < b Initial program 55.4%
associate-*r/55.3%
*-commutative55.3%
+-commutative55.3%
Simplified55.3%
Taylor expanded in a around 0 57.1%
if -0.021999999999999999 < b < 6.4999999999999997e-4Initial program 97.0%
associate-*r/97.1%
*-commutative97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 96.5%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= b -0.022) (/ r (/ (cos b) (sin b))) (if (<= b 0.00065) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.022) {
tmp = r / (cos(b) / sin(b));
} else if (b <= 0.00065) {
tmp = r * (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 (b <= (-0.022d0)) then
tmp = r / (cos(b) / sin(b))
else if (b <= 0.00065d0) then
tmp = r * (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 (b <= -0.022) {
tmp = r / (Math.cos(b) / Math.sin(b));
} else if (b <= 0.00065) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.022: tmp = r / (math.cos(b) / math.sin(b)) elif b <= 0.00065: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.022) tmp = Float64(r / Float64(cos(b) / sin(b))); elseif (b <= 0.00065) tmp = Float64(r * Float64(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 (b <= -0.022) tmp = r / (cos(b) / sin(b)); elseif (b <= 0.00065) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.022], N[(r / N[(N[Cos[b], $MachinePrecision] / N[Sin[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.00065], N[(r * N[(b / 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}\;b \leq -0.022:\\
\;\;\;\;\frac{r}{\frac{\cos b}{\sin b}}\\
\mathbf{elif}\;b \leq 0.00065:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -0.021999999999999999Initial program 53.7%
associate-/l*53.6%
+-commutative53.6%
Simplified53.6%
Taylor expanded in a around 0 56.6%
if -0.021999999999999999 < b < 6.4999999999999997e-4Initial program 97.0%
associate-*r/97.1%
*-commutative97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 96.5%
if 6.4999999999999997e-4 < b Initial program 57.3%
associate-*r/57.3%
*-commutative57.3%
+-commutative57.3%
Simplified57.3%
Taylor expanded in a around 0 57.7%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= b -0.022) (/ (sin b) (/ (cos b) r)) (if (<= b 0.00065) (* r (/ b (cos a))) (* r (/ (sin b) (cos b))))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.022) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 0.00065) {
tmp = r * (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 (b <= (-0.022d0)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 0.00065d0) then
tmp = r * (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 (b <= -0.022) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 0.00065) {
tmp = r * (b / Math.cos(a));
} else {
tmp = r * (Math.sin(b) / Math.cos(b));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.022: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 0.00065: tmp = r * (b / math.cos(a)) else: tmp = r * (math.sin(b) / math.cos(b)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.022) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 0.00065) tmp = Float64(r * Float64(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 (b <= -0.022) tmp = sin(b) / (cos(b) / r); elseif (b <= 0.00065) tmp = r * (b / cos(a)); else tmp = r * (sin(b) / cos(b)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.022], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.00065], N[(r * N[(b / 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}\;b \leq -0.022:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 0.00065:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{\sin b}{\cos b}\\
\end{array}
\end{array}
if b < -0.021999999999999999Initial program 53.7%
associate-*r/53.6%
*-commutative53.6%
+-commutative53.6%
Simplified53.6%
cos-sum99.0%
Applied egg-rr99.0%
Taylor expanded in a around 0 56.7%
associate-/l*56.7%
Simplified56.7%
if -0.021999999999999999 < b < 6.4999999999999997e-4Initial program 97.0%
associate-*r/97.1%
*-commutative97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 96.5%
if 6.4999999999999997e-4 < b Initial program 57.3%
associate-*r/57.3%
*-commutative57.3%
+-commutative57.3%
Simplified57.3%
Taylor expanded in a around 0 57.7%
Final simplification75.0%
(FPCore (r a b) :precision binary64 (if (<= b -0.022) (/ (sin b) (/ (cos b) r)) (if (<= b 0.00065) (* r (/ b (cos a))) (/ (* (sin b) r) (cos b)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -0.022) {
tmp = sin(b) / (cos(b) / r);
} else if (b <= 0.00065) {
tmp = r * (b / cos(a));
} else {
tmp = (sin(b) * r) / 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 (b <= (-0.022d0)) then
tmp = sin(b) / (cos(b) / r)
else if (b <= 0.00065d0) then
tmp = r * (b / cos(a))
else
tmp = (sin(b) * r) / cos(b)
end if
code = tmp
end function
public static double code(double r, double a, double b) {
double tmp;
if (b <= -0.022) {
tmp = Math.sin(b) / (Math.cos(b) / r);
} else if (b <= 0.00065) {
tmp = r * (b / Math.cos(a));
} else {
tmp = (Math.sin(b) * r) / Math.cos(b);
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -0.022: tmp = math.sin(b) / (math.cos(b) / r) elif b <= 0.00065: tmp = r * (b / math.cos(a)) else: tmp = (math.sin(b) * r) / math.cos(b) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -0.022) tmp = Float64(sin(b) / Float64(cos(b) / r)); elseif (b <= 0.00065) tmp = Float64(r * Float64(b / cos(a))); else tmp = Float64(Float64(sin(b) * r) / cos(b)); end return tmp end
function tmp_2 = code(r, a, b) tmp = 0.0; if (b <= -0.022) tmp = sin(b) / (cos(b) / r); elseif (b <= 0.00065) tmp = r * (b / cos(a)); else tmp = (sin(b) * r) / cos(b); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -0.022], N[(N[Sin[b], $MachinePrecision] / N[(N[Cos[b], $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.00065], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[b], $MachinePrecision] * r), $MachinePrecision] / N[Cos[b], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.022:\\
\;\;\;\;\frac{\sin b}{\frac{\cos b}{r}}\\
\mathbf{elif}\;b \leq 0.00065:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin b \cdot r}{\cos b}\\
\end{array}
\end{array}
if b < -0.021999999999999999Initial program 53.7%
associate-*r/53.6%
*-commutative53.6%
+-commutative53.6%
Simplified53.6%
cos-sum99.0%
Applied egg-rr99.0%
Taylor expanded in a around 0 56.7%
associate-/l*56.7%
Simplified56.7%
if -0.021999999999999999 < b < 6.4999999999999997e-4Initial program 97.0%
associate-*r/97.1%
*-commutative97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 96.5%
if 6.4999999999999997e-4 < b Initial program 57.3%
associate-*r/57.3%
*-commutative57.3%
+-commutative57.3%
Simplified57.3%
Taylor expanded in a around 0 57.8%
Final simplification75.0%
(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 74.3%
associate-/l*74.2%
+-commutative74.2%
Simplified74.2%
associate-/r/74.3%
Applied egg-rr74.3%
Final simplification74.3%
(FPCore (r a b) :precision binary64 (if (<= b -1.4) (/ r (- (/ 1.0 b) (sin a))) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.4) {
tmp = r / ((1.0 / b) - sin(a));
} 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.4d0)) then
tmp = r / ((1.0d0 / b) - sin(a))
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.4) {
tmp = r / ((1.0 / b) - Math.sin(a));
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.4: tmp = r / ((1.0 / b) - math.sin(a)) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.4) tmp = Float64(r / Float64(Float64(1.0 / b) - sin(a))); 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.4) tmp = r / ((1.0 / b) - sin(a)); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.4], N[(r / N[(N[(1.0 / b), $MachinePrecision] - N[Sin[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4:\\
\;\;\;\;\frac{r}{\frac{1}{b} - \sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.3999999999999999Initial program 53.7%
associate-/l*53.6%
+-commutative53.6%
Simplified53.6%
Taylor expanded in b around 0 10.0%
neg-mul-110.0%
+-commutative10.0%
unsub-neg10.0%
Simplified10.0%
Taylor expanded in a around 0 10.0%
if -1.3999999999999999 < b Initial program 82.5%
associate-*r/82.5%
*-commutative82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in b around 0 62.7%
Final simplification47.7%
(FPCore (r a b) :precision binary64 (if (<= b -1.28) (/ (- r) (sin a)) (* r (/ b (cos a)))))
double code(double r, double a, double b) {
double tmp;
if (b <= -1.28) {
tmp = -r / sin(a);
} 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.28d0)) then
tmp = -r / sin(a)
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.28) {
tmp = -r / Math.sin(a);
} else {
tmp = r * (b / Math.cos(a));
}
return tmp;
}
def code(r, a, b): tmp = 0 if b <= -1.28: tmp = -r / math.sin(a) else: tmp = r * (b / math.cos(a)) return tmp
function code(r, a, b) tmp = 0.0 if (b <= -1.28) tmp = Float64(Float64(-r) / sin(a)); 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.28) tmp = -r / sin(a); else tmp = r * (b / cos(a)); end tmp_2 = tmp; end
code[r_, a_, b_] := If[LessEqual[b, -1.28], N[((-r) / N[Sin[a], $MachinePrecision]), $MachinePrecision], N[(r * N[(b / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.28:\\
\;\;\;\;\frac{-r}{\sin a}\\
\mathbf{else}:\\
\;\;\;\;r \cdot \frac{b}{\cos a}\\
\end{array}
\end{array}
if b < -1.28000000000000003Initial program 53.7%
associate-/l*53.6%
+-commutative53.6%
Simplified53.6%
Taylor expanded in b around 0 10.0%
neg-mul-110.0%
+-commutative10.0%
unsub-neg10.0%
Simplified10.0%
Taylor expanded in b around inf 9.9%
associate-*r/9.9%
neg-mul-19.9%
Simplified9.9%
if -1.28000000000000003 < b Initial program 82.5%
associate-*r/82.5%
*-commutative82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in b around 0 62.7%
Final simplification47.6%
(FPCore (r a b) :precision binary64 (/ r (+ (/ 1.0 b) (* b -0.3333333333333333))))
double code(double r, double a, double b) {
return r / ((1.0 / b) + (b * -0.3333333333333333));
}
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)))
end function
public static double code(double r, double a, double b) {
return r / ((1.0 / b) + (b * -0.3333333333333333));
}
def code(r, a, b): return r / ((1.0 / b) + (b * -0.3333333333333333))
function code(r, a, b) return Float64(r / Float64(Float64(1.0 / b) + Float64(b * -0.3333333333333333))) end
function tmp = code(r, a, b) tmp = r / ((1.0 / b) + (b * -0.3333333333333333)); end
code[r_, a_, b_] := N[(r / N[(N[(1.0 / b), $MachinePrecision] + N[(b * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{r}{\frac{1}{b} + b \cdot -0.3333333333333333}
\end{array}
Initial program 74.3%
associate-/l*74.2%
+-commutative74.2%
Simplified74.2%
Taylor expanded in b around 0 47.2%
fma-def47.2%
distribute-rgt-out--47.2%
metadata-eval47.2%
neg-mul-147.2%
+-commutative47.2%
unsub-neg47.2%
Simplified47.2%
Taylor expanded in a around 0 33.8%
Final simplification33.8%
(FPCore (r a b) :precision binary64 (* b r))
double code(double r, double a, double b) {
return 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 = b * r
end function
public static double code(double r, double a, double b) {
return b * r;
}
def code(r, a, b): return b * r
function code(r, a, b) return Float64(b * r) end
function tmp = code(r, a, b) tmp = b * r; end
code[r_, a_, b_] := N[(b * r), $MachinePrecision]
\begin{array}{l}
\\
b \cdot r
\end{array}
Initial program 74.3%
associate-*r/74.3%
*-commutative74.3%
+-commutative74.3%
Simplified74.3%
Taylor expanded in a around 0 60.4%
+-commutative60.4%
mul-1-neg60.4%
unsub-neg60.4%
*-commutative60.4%
Simplified60.4%
Taylor expanded in b around 0 33.2%
Final simplification33.2%
herbie shell --seed 2023229
(FPCore (r a b)
:name "rsin A (should all be same)"
:precision binary64
(/ (* r (sin b)) (cos (+ a b))))