
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (tan t) (/ eh ew))))
(fabs
(fma ew (/ (cos t) (hypot 1.0 t_1)) (* eh (* (sin t) (sin (atan t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) * (eh / ew);
return fabs(fma(ew, (cos(t) / hypot(1.0, t_1)), (eh * (sin(t) * sin(atan(t_1))))));
}
function code(eh, ew, t) t_1 = Float64(tan(t) * Float64(eh / ew)) return abs(fma(ew, Float64(cos(t) / hypot(1.0, t_1)), Float64(eh * Float64(sin(t) * sin(atan(t_1)))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan t \cdot \frac{eh}{ew}\\
\left|\mathsf{fma}\left(ew, \frac{\cos t}{\mathsf{hypot}\left(1, t\_1\right)}, eh \cdot \left(\sin t \cdot \sin \tan^{-1} t\_1\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.1%
sqrt-unprod76.6%
sqr-neg76.6%
sqrt-unprod52.2%
add-sqr-sqrt99.3%
associate-*l*99.3%
Applied egg-rr99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (tan t) (/ eh ew))))
(fabs
(+
(* eh (* (sin t) (sin (atan t_1))))
(/ (* ew (cos t)) (hypot 1.0 t_1))))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) * (eh / ew);
return fabs(((eh * (sin(t) * sin(atan(t_1)))) + ((ew * cos(t)) / hypot(1.0, t_1))));
}
public static double code(double eh, double ew, double t) {
double t_1 = Math.tan(t) * (eh / ew);
return Math.abs(((eh * (Math.sin(t) * Math.sin(Math.atan(t_1)))) + ((ew * Math.cos(t)) / Math.hypot(1.0, t_1))));
}
def code(eh, ew, t): t_1 = math.tan(t) * (eh / ew) return math.fabs(((eh * (math.sin(t) * math.sin(math.atan(t_1)))) + ((ew * math.cos(t)) / math.hypot(1.0, t_1))))
function code(eh, ew, t) t_1 = Float64(tan(t) * Float64(eh / ew)) return abs(Float64(Float64(eh * Float64(sin(t) * sin(atan(t_1)))) + Float64(Float64(ew * cos(t)) / hypot(1.0, t_1)))) end
function tmp = code(eh, ew, t) t_1 = tan(t) * (eh / ew); tmp = abs(((eh * (sin(t) * sin(atan(t_1)))) + ((ew * cos(t)) / hypot(1.0, t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan t \cdot \frac{eh}{ew}\\
\left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} t\_1\right) + \frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, t\_1\right)}\right|
\end{array}
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.1%
sqrt-unprod76.6%
sqr-neg76.6%
sqrt-unprod52.2%
add-sqr-sqrt99.3%
associate-*l*99.3%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* ew (cos t)) (* eh (* (sin t) (sin (atan (/ (* eh (tan t)) ew))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) + (eh * (sin(t) * sin(atan(((eh * tan(t)) / ew)))))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((ew * cos(t)) + (eh * (sin(t) * sin(atan(((eh * tan(t)) / ew)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.cos(t)) + (eh * (Math.sin(t) * Math.sin(Math.atan(((eh * Math.tan(t)) / ew)))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.cos(t)) + (eh * (math.sin(t) * math.sin(math.atan(((eh * math.tan(t)) / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * cos(t)) + Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(eh * tan(t)) / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) + (eh * (sin(t) * sin(atan(((eh * tan(t)) / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \cos t + eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.1%
sqrt-unprod76.6%
sqr-neg76.6%
sqrt-unprod52.2%
add-sqr-sqrt99.3%
associate-*l*99.3%
Applied egg-rr99.8%
Taylor expanded in eh around 0 99.2%
Final simplification99.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -3.8e+88) (not (<= eh 5.5e-40))) (fabs (* eh (* (sin t) (sin (atan (* eh (/ t (- ew)))))))) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3.8e+88) || !(eh <= 5.5e-40)) {
tmp = fabs((eh * (sin(t) * sin(atan((eh * (t / -ew)))))));
} else {
tmp = fabs((ew * cos(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 ((eh <= (-3.8d+88)) .or. (.not. (eh <= 5.5d-40))) then
tmp = abs((eh * (sin(t) * sin(atan((eh * (t / -ew)))))))
else
tmp = abs((ew * cos(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3.8e+88) || !(eh <= 5.5e-40)) {
tmp = Math.abs((eh * (Math.sin(t) * Math.sin(Math.atan((eh * (t / -ew)))))));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -3.8e+88) or not (eh <= 5.5e-40): tmp = math.fabs((eh * (math.sin(t) * math.sin(math.atan((eh * (t / -ew))))))) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -3.8e+88) || !(eh <= 5.5e-40)) tmp = abs(Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(t / Float64(-ew)))))))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -3.8e+88) || ~((eh <= 5.5e-40))) tmp = abs((eh * (sin(t) * sin(atan((eh * (t / -ew))))))); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -3.8e+88], N[Not[LessEqual[eh, 5.5e-40]], $MachinePrecision]], N[Abs[N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(t / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3.8 \cdot 10^{+88} \lor \neg \left(eh \leq 5.5 \cdot 10^{-40}\right):\\
\;\;\;\;\left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{t}{-ew}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -3.7999999999999997e88 or 5.50000000000000002e-40 < eh Initial program 99.7%
Taylor expanded in eh around inf 99.7%
associate-/l*99.7%
fma-neg99.7%
Simplified99.7%
Taylor expanded in t around 0 99.7%
associate-*r/99.7%
associate-*r*99.7%
neg-mul-199.7%
Simplified99.7%
Taylor expanded in eh around inf 77.1%
associate-*r*77.1%
neg-mul-177.1%
mul-1-neg77.1%
associate-/l*77.1%
distribute-lft-neg-out77.1%
Simplified77.1%
if -3.7999999999999997e88 < eh < 5.50000000000000002e-40Initial program 99.9%
associate-*l*99.9%
fma-neg99.9%
associate-*l*99.9%
distribute-lft-neg-in99.9%
add-sqr-sqrt55.4%
sqrt-unprod95.9%
sqr-neg95.9%
sqrt-unprod44.0%
add-sqr-sqrt99.1%
associate-*l*99.1%
Applied egg-rr99.8%
Taylor expanded in ew around inf 82.2%
Final simplification80.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2.9e-200) (not (<= ew 2.4e-49))) (fabs (* ew (cos t))) (* (sin t) (* eh (sin (atan (/ eh (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.9e-200) || !(ew <= 2.4e-49)) {
tmp = fabs((ew * cos(t)));
} else {
tmp = sin(t) * (eh * 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 <= (-2.9d-200)) .or. (.not. (ew <= 2.4d-49))) then
tmp = abs((ew * cos(t)))
else
tmp = sin(t) * (eh * 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 <= -2.9e-200) || !(ew <= 2.4e-49)) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.sin(t) * (eh * Math.sin(Math.atan((eh / (ew / Math.tan(t))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.9e-200) or not (ew <= 2.4e-49): tmp = math.fabs((ew * math.cos(t))) else: tmp = math.sin(t) * (eh * math.sin(math.atan((eh / (ew / math.tan(t)))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.9e-200) || !(ew <= 2.4e-49)) tmp = abs(Float64(ew * cos(t))); else tmp = Float64(sin(t) * Float64(eh * sin(atan(Float64(eh / Float64(ew / tan(t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.9e-200) || ~((ew <= 2.4e-49))) tmp = abs((ew * cos(t))); else tmp = sin(t) * (eh * sin(atan((eh / (ew / tan(t)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.9e-200], N[Not[LessEqual[ew, 2.4e-49]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Sin[t], $MachinePrecision] * N[(eh * 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 -2.9 \cdot 10^{-200} \lor \neg \left(ew \leq 2.4 \cdot 10^{-49}\right):\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\sin t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{\frac{ew}{\tan t}}\right)\right)\\
\end{array}
\end{array}
if ew < -2.9e-200 or 2.39999999999999992e-49 < ew Initial program 99.8%
associate-*l*99.8%
fma-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.7%
sqrt-unprod78.9%
sqr-neg78.9%
sqrt-unprod51.6%
add-sqr-sqrt99.4%
associate-*l*99.4%
Applied egg-rr99.8%
Taylor expanded in ew around inf 75.7%
if -2.9e-200 < ew < 2.39999999999999992e-49Initial program 99.8%
add-sqr-sqrt58.2%
pow258.2%
Applied egg-rr58.2%
Taylor expanded in ew around 0 47.7%
associate-*r*47.7%
*-commutative47.7%
associate-*r/47.7%
*-commutative47.7%
associate-*r/47.7%
*-commutative47.7%
associate-/l*47.7%
Simplified47.7%
unpow247.7%
fabs-sqr47.7%
add-sqr-sqrt48.7%
associate-*r*48.7%
clear-num48.7%
un-div-inv48.7%
Applied egg-rr48.7%
Final simplification68.3%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -7.5e+178) (not (<= eh 4e+198))) (fabs (* (* t eh) (sin (atan (* eh (/ (tan t) ew)))))) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -7.5e+178) || !(eh <= 4e+198)) {
tmp = fabs(((t * eh) * sin(atan((eh * (tan(t) / ew))))));
} else {
tmp = fabs((ew * cos(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 ((eh <= (-7.5d+178)) .or. (.not. (eh <= 4d+198))) then
tmp = abs(((t * eh) * sin(atan((eh * (tan(t) / ew))))))
else
tmp = abs((ew * cos(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -7.5e+178) || !(eh <= 4e+198)) {
tmp = Math.abs(((t * eh) * Math.sin(Math.atan((eh * (Math.tan(t) / ew))))));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -7.5e+178) or not (eh <= 4e+198): tmp = math.fabs(((t * eh) * math.sin(math.atan((eh * (math.tan(t) / ew)))))) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -7.5e+178) || !(eh <= 4e+198)) tmp = abs(Float64(Float64(t * eh) * sin(atan(Float64(eh * Float64(tan(t) / ew)))))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -7.5e+178) || ~((eh <= 4e+198))) tmp = abs(((t * eh) * sin(atan((eh * (tan(t) / ew)))))); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -7.5e+178], N[Not[LessEqual[eh, 4e+198]], $MachinePrecision]], N[Abs[N[(N[(t * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -7.5 \cdot 10^{+178} \lor \neg \left(eh \leq 4 \cdot 10^{+198}\right):\\
\;\;\;\;\left|\left(t \cdot eh\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -7.4999999999999995e178 or 4.00000000000000007e198 < eh Initial program 99.7%
add-sqr-sqrt56.7%
pow256.7%
Applied egg-rr56.7%
Taylor expanded in ew around 0 49.9%
associate-*r*49.9%
*-commutative49.9%
associate-*r/49.9%
*-commutative49.9%
associate-*r/49.9%
*-commutative49.9%
associate-/l*49.9%
Simplified49.9%
Taylor expanded in t around 0 38.6%
associate-*r*38.6%
associate-/l*38.6%
Simplified38.6%
if -7.4999999999999995e178 < eh < 4.00000000000000007e198Initial program 99.8%
associate-*l*99.8%
fma-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.5%
sqrt-unprod90.3%
sqr-neg90.3%
sqrt-unprod51.8%
add-sqr-sqrt99.3%
associate-*l*99.3%
Applied egg-rr99.8%
Taylor expanded in ew around inf 70.2%
Final simplification65.0%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (cos t))))
double code(double eh, double ew, double t) {
return fabs((ew * cos(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((ew * cos(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.cos(t)))
function code(eh, ew, t) return abs(Float64(ew * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \cos t\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.1%
sqrt-unprod76.6%
sqr-neg76.6%
sqrt-unprod52.2%
add-sqr-sqrt99.3%
associate-*l*99.3%
Applied egg-rr99.8%
Taylor expanded in ew around inf 60.6%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -0.035) (not (<= t 4.2e-7))) (* ew (cos t)) (fabs ew)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.035) || !(t <= 4.2e-7)) {
tmp = ew * cos(t);
} else {
tmp = fabs(ew);
}
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 ((t <= (-0.035d0)) .or. (.not. (t <= 4.2d-7))) then
tmp = ew * cos(t)
else
tmp = abs(ew)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.035) || !(t <= 4.2e-7)) {
tmp = ew * Math.cos(t);
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.035) or not (t <= 4.2e-7): tmp = ew * math.cos(t) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.035) || !(t <= 4.2e-7)) tmp = Float64(ew * cos(t)); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.035) || ~((t <= 4.2e-7))) tmp = ew * cos(t); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.035], N[Not[LessEqual[t, 4.2e-7]], $MachinePrecision]], N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision], N[Abs[ew], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.035 \lor \neg \left(t \leq 4.2 \cdot 10^{-7}\right):\\
\;\;\;\;ew \cdot \cos t\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if t < -0.035000000000000003 or 4.2e-7 < t Initial program 99.6%
associate-*l*99.6%
fma-neg99.6%
associate-*l*99.6%
distribute-lft-neg-in99.6%
add-sqr-sqrt41.7%
sqrt-unprod69.4%
sqr-neg69.4%
sqrt-unprod57.6%
add-sqr-sqrt99.2%
associate-*l*99.2%
Applied egg-rr99.6%
Taylor expanded in ew around inf 44.3%
add-sqr-sqrt25.7%
fabs-sqr25.7%
add-sqr-sqrt26.7%
*-commutative26.7%
Applied egg-rr26.7%
if -0.035000000000000003 < t < 4.2e-7Initial program 100.0%
associate-*l*100.0%
fma-neg100.0%
associate-*l*100.0%
distribute-lft-neg-in100.0%
add-sqr-sqrt52.7%
sqrt-unprod84.1%
sqr-neg84.1%
sqrt-unprod46.6%
add-sqr-sqrt99.5%
associate-*l*99.5%
Applied egg-rr100.0%
Taylor expanded in t around 0 77.0%
Final simplification51.3%
(FPCore (eh ew t) :precision binary64 (fabs ew))
double code(double eh, double ew, double t) {
return fabs(ew);
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(ew)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(ew);
}
def code(eh, ew, t): return math.fabs(ew)
function code(eh, ew, t) return abs(ew) end
function tmp = code(eh, ew, t) tmp = abs(ew); end
code[eh_, ew_, t_] := N[Abs[ew], $MachinePrecision]
\begin{array}{l}
\\
\left|ew\right|
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.1%
sqrt-unprod76.6%
sqr-neg76.6%
sqrt-unprod52.2%
add-sqr-sqrt99.3%
associate-*l*99.3%
Applied egg-rr99.8%
Taylor expanded in t around 0 43.6%
(FPCore (eh ew t) :precision binary64 ew)
double code(double eh, double ew, double t) {
return ew;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = ew
end function
public static double code(double eh, double ew, double t) {
return ew;
}
def code(eh, ew, t): return ew
function code(eh, ew, t) return ew end
function tmp = code(eh, ew, t) tmp = ew; end
code[eh_, ew_, t_] := ew
\begin{array}{l}
\\
ew
\end{array}
Initial program 99.8%
associate-*l*99.8%
fma-neg99.8%
associate-*l*99.8%
distribute-lft-neg-in99.8%
add-sqr-sqrt47.1%
sqrt-unprod76.6%
sqr-neg76.6%
sqrt-unprod52.2%
add-sqr-sqrt99.3%
associate-*l*99.3%
Applied egg-rr99.8%
Taylor expanded in t around 0 43.6%
add-cbrt-cube17.2%
pow1/316.4%
pow316.4%
Applied egg-rr16.4%
unpow1/317.2%
rem-cbrt-cube43.6%
add-sqr-sqrt22.7%
fabs-sqr22.7%
*-un-lft-identity22.7%
add-sqr-sqrt23.5%
Applied egg-rr23.5%
Final simplification23.5%
herbie shell --seed 2024129
(FPCore (eh ew t)
:name "Example 2 from Robby"
:precision binary64
(fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))