
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ eh (* ew (tan t)))))) (fabs (fma (* ew (sin t)) (cos t_1) (* eh (* (cos t) (sin t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * tan(t))));
return fabs(fma((ew * sin(t)), cos(t_1), (eh * (cos(t) * sin(t_1)))));
}
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * tan(t)))) return abs(fma(Float64(ew * sin(t)), cos(t_1), Float64(eh * Float64(cos(t) * sin(t_1))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \cos t\_1, eh \cdot \left(\cos t \cdot \sin t\_1\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (/ eh ew) (tan t)))) (t_2 (atan (/ eh (* ew (tan t))))))
(if (<= ew -1e-38)
(fabs
(*
ew
(fma
(cos t_2)
(sin t)
(* eh (/ (* (cos t) (sin (atan (/ eh (* ew t))))) ew)))))
(if (<= ew 8.8e-170)
(fabs (* (* eh (cos t)) (sin t_2)))
(fabs (+ (* (* ew (sin t)) (cos t_1)) (* eh (sin t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
double t_2 = atan((eh / (ew * tan(t))));
double tmp;
if (ew <= -1e-38) {
tmp = fabs((ew * fma(cos(t_2), sin(t), (eh * ((cos(t) * sin(atan((eh / (ew * t))))) / ew)))));
} else if (ew <= 8.8e-170) {
tmp = fabs(((eh * cos(t)) * sin(t_2)));
} else {
tmp = fabs((((ew * sin(t)) * cos(t_1)) + (eh * sin(t_1))));
}
return tmp;
}
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) t_2 = atan(Float64(eh / Float64(ew * tan(t)))) tmp = 0.0 if (ew <= -1e-38) tmp = abs(Float64(ew * fma(cos(t_2), sin(t), Float64(eh * Float64(Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * t))))) / ew))))); elseif (ew <= 8.8e-170) tmp = abs(Float64(Float64(eh * cos(t)) * sin(t_2))); else tmp = abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(eh * sin(t_1)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1e-38], N[Abs[N[(ew * N[(N[Cos[t$95$2], $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(eh * N[(N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 8.8e-170], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
t_2 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\mathbf{if}\;ew \leq -1 \cdot 10^{-38}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(\cos t\_2, \sin t, eh \cdot \frac{\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)}{ew}\right)\right|\\
\mathbf{elif}\;ew \leq 8.8 \cdot 10^{-170}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin t\_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + eh \cdot \sin t\_1\right|\\
\end{array}
\end{array}
if ew < -9.9999999999999996e-39Initial program 99.6%
fma-define99.6%
associate-/l/99.6%
associate-*l*99.6%
associate-/l/99.6%
Simplified99.6%
Taylor expanded in ew around inf 99.5%
fma-define99.5%
associate-/l*99.5%
Simplified99.5%
Taylor expanded in t around 0 92.7%
if -9.9999999999999996e-39 < ew < 8.80000000000000059e-170Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 95.3%
associate-*r*95.3%
*-commutative95.3%
Simplified95.3%
if 8.80000000000000059e-170 < ew Initial program 99.8%
Taylor expanded in t around 0 89.1%
Final simplification92.2%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (/ eh ew) (tan t)))))
(if (or (<= ew -3.05e-37) (not (<= ew 3e-171)))
(fabs (+ (* (* ew (sin t)) (cos t_1)) (* eh (sin t_1))))
(fabs (* (* eh (cos t)) (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
double tmp;
if ((ew <= -3.05e-37) || !(ew <= 3e-171)) {
tmp = fabs((((ew * sin(t)) * cos(t_1)) + (eh * sin(t_1))));
} else {
tmp = fabs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = atan(((eh / ew) / tan(t)))
if ((ew <= (-3.05d-37)) .or. (.not. (ew <= 3d-171))) then
tmp = abs((((ew * sin(t)) * cos(t_1)) + (eh * sin(t_1))))
else
tmp = abs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
double tmp;
if ((ew <= -3.05e-37) || !(ew <= 3e-171)) {
tmp = Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + (eh * Math.sin(t_1))));
} else {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) tmp = 0 if (ew <= -3.05e-37) or not (ew <= 3e-171): tmp = math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + (eh * math.sin(t_1)))) else: tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan((eh / (ew * math.tan(t))))))) return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) tmp = 0.0 if ((ew <= -3.05e-37) || !(ew <= 3e-171)) tmp = abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(eh * sin(t_1)))); else tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * tan(t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = 0.0; if ((ew <= -3.05e-37) || ~((ew <= 3e-171))) tmp = abs((((ew * sin(t)) * cos(t_1)) + (eh * sin(t_1)))); else tmp = abs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[ew, -3.05e-37], N[Not[LessEqual[ew, 3e-171]], $MachinePrecision]], N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\mathbf{if}\;ew \leq -3.05 \cdot 10^{-37} \lor \neg \left(ew \leq 3 \cdot 10^{-171}\right):\\
\;\;\;\;\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + eh \cdot \sin t\_1\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\end{array}
\end{array}
if ew < -3.0500000000000002e-37 or 3e-171 < ew Initial program 99.7%
Taylor expanded in t around 0 89.1%
if -3.0500000000000002e-37 < ew < 3e-171Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 95.3%
associate-*r*95.3%
*-commutative95.3%
Simplified95.3%
Final simplification91.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.72e+50) (not (<= ew 5.5e+76))) (fabs (* ew (* (sin t) (cos (atan (/ eh (* ew t))))))) (fabs (* (* eh (cos t)) (sin (atan (/ eh (* ew (tan t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.72e+50) || !(ew <= 5.5e+76)) {
tmp = fabs((ew * (sin(t) * cos(atan((eh / (ew * t)))))));
} else {
tmp = fabs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((ew <= (-1.72d+50)) .or. (.not. (ew <= 5.5d+76))) then
tmp = abs((ew * (sin(t) * cos(atan((eh / (ew * t)))))))
else
tmp = abs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.72e+50) || !(ew <= 5.5e+76)) {
tmp = Math.abs((ew * (Math.sin(t) * Math.cos(Math.atan((eh / (ew * t)))))));
} else {
tmp = Math.abs(((eh * Math.cos(t)) * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.72e+50) or not (ew <= 5.5e+76): tmp = math.fabs((ew * (math.sin(t) * math.cos(math.atan((eh / (ew * t))))))) else: tmp = math.fabs(((eh * math.cos(t)) * math.sin(math.atan((eh / (ew * math.tan(t))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.72e+50) || !(ew <= 5.5e+76)) tmp = abs(Float64(ew * Float64(sin(t) * cos(atan(Float64(eh / Float64(ew * t))))))); else tmp = abs(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(ew * tan(t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.72e+50) || ~((ew <= 5.5e+76))) tmp = abs((ew * (sin(t) * cos(atan((eh / (ew * t))))))); else tmp = abs(((eh * cos(t)) * sin(atan((eh / (ew * tan(t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.72e+50], N[Not[LessEqual[ew, 5.5e+76]], $MachinePrecision]], N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.72 \cdot 10^{+50} \lor \neg \left(ew \leq 5.5 \cdot 10^{+76}\right):\\
\;\;\;\;\left|ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\end{array}
\end{array}
if ew < -1.72e50 or 5.5000000000000001e76 < ew Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around inf 99.7%
fma-define99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in eh around 0 81.8%
associate-/r*81.8%
Simplified81.8%
Taylor expanded in t around 0 81.9%
if -1.72e50 < ew < 5.5000000000000001e76Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in ew around 0 85.4%
associate-*r*85.4%
*-commutative85.4%
Simplified85.4%
Final simplification84.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ eh (* ew t)))))
(if (or (<= ew -3e-36) (not (<= ew 5.2e+76)))
(fabs (* ew (* (sin t) (cos t_1))))
(fabs (* eh (* (cos t) (sin t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (ew * t)));
double tmp;
if ((ew <= -3e-36) || !(ew <= 5.2e+76)) {
tmp = fabs((ew * (sin(t) * cos(t_1))));
} else {
tmp = fabs((eh * (cos(t) * sin(t_1))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = atan((eh / (ew * t)))
if ((ew <= (-3d-36)) .or. (.not. (ew <= 5.2d+76))) then
tmp = abs((ew * (sin(t) * cos(t_1))))
else
tmp = abs((eh * (cos(t) * sin(t_1))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((eh / (ew * t)));
double tmp;
if ((ew <= -3e-36) || !(ew <= 5.2e+76)) {
tmp = Math.abs((ew * (Math.sin(t) * Math.cos(t_1))));
} else {
tmp = Math.abs((eh * (Math.cos(t) * Math.sin(t_1))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan((eh / (ew * t))) tmp = 0 if (ew <= -3e-36) or not (ew <= 5.2e+76): tmp = math.fabs((ew * (math.sin(t) * math.cos(t_1)))) else: tmp = math.fabs((eh * (math.cos(t) * math.sin(t_1)))) return tmp
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(ew * t))) tmp = 0.0 if ((ew <= -3e-36) || !(ew <= 5.2e+76)) tmp = abs(Float64(ew * Float64(sin(t) * cos(t_1)))); else tmp = abs(Float64(eh * Float64(cos(t) * sin(t_1)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan((eh / (ew * t))); tmp = 0.0; if ((ew <= -3e-36) || ~((ew <= 5.2e+76))) tmp = abs((ew * (sin(t) * cos(t_1)))); else tmp = abs((eh * (cos(t) * sin(t_1)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[ew, -3e-36], N[Not[LessEqual[ew, 5.2e+76]], $MachinePrecision]], N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\\
\mathbf{if}\;ew \leq -3 \cdot 10^{-36} \lor \neg \left(ew \leq 5.2 \cdot 10^{+76}\right):\\
\;\;\;\;\left|ew \cdot \left(\sin t \cdot \cos t\_1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin t\_1\right)\right|\\
\end{array}
\end{array}
if ew < -3.0000000000000002e-36 or 5.1999999999999999e76 < ew Initial program 99.7%
fma-define99.7%
associate-/l/99.7%
associate-*l*99.7%
associate-/l/99.7%
Simplified99.7%
Taylor expanded in ew around inf 99.7%
fma-define99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in eh around 0 78.0%
associate-/r*78.0%
Simplified78.0%
Taylor expanded in t around 0 78.0%
if -3.0000000000000002e-36 < ew < 5.1999999999999999e76Initial program 99.8%
add-cube-cbrt99.7%
pow399.7%
Applied egg-rr99.7%
Taylor expanded in t around 0 88.4%
rem-cube-cbrt88.5%
add-cbrt-cube83.2%
pow383.2%
Applied egg-rr83.2%
Taylor expanded in ew around 0 77.0%
*-commutative77.0%
Simplified77.0%
Final simplification77.4%
(FPCore (eh ew t) :precision binary64 (fabs (* eh (* (cos t) (sin (atan (/ eh (* ew t))))))))
double code(double eh, double ew, double t) {
return fabs((eh * (cos(t) * sin(atan((eh / (ew * t)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((eh * (cos(t) * sin(atan((eh / (ew * t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh * (Math.cos(t) * Math.sin(Math.atan((eh / (ew * t)))))));
}
def code(eh, ew, t): return math.fabs((eh * (math.cos(t) * math.sin(math.atan((eh / (ew * t)))))))
function code(eh, ew, t) return abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * t))))))) end
function tmp = code(eh, ew, t) tmp = abs((eh * (cos(t) * sin(atan((eh / (ew * t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)\right|
\end{array}
Initial program 99.8%
add-cube-cbrt99.0%
pow399.0%
Applied egg-rr99.0%
Taylor expanded in t around 0 90.2%
rem-cube-cbrt90.9%
add-cbrt-cube64.9%
pow364.9%
Applied egg-rr64.9%
Taylor expanded in ew around 0 51.4%
*-commutative51.4%
Simplified51.4%
Final simplification51.4%
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
return fabs(eh);
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(eh)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(eh);
}
def code(eh, ew, t): return math.fabs(eh)
function code(eh, ew, t) return abs(eh) end
function tmp = code(eh, ew, t) tmp = abs(eh); end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}
\\
\left|eh\right|
\end{array}
Initial program 99.8%
fma-define99.8%
associate-/l/99.8%
associate-*l*99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in t around 0 41.8%
sin-atan11.5%
hypot-1-def19.6%
Applied egg-rr19.6%
associate-/l/19.8%
*-commutative19.8%
associate-/r*19.6%
Simplified19.6%
Taylor expanded in eh around inf 42.2%
herbie shell --seed 2024177
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))