
(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 10 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 (fabs (- (* (* ew (cos t)) (/ 1.0 (hypot 1.0 (* (/ eh ew) (tan t))))) (* (* eh (sin t)) (sin (atan (/ (* eh (- (tan t))) ew)))))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) * (1.0 / hypot(1.0, ((eh / ew) * tan(t))))) - ((eh * sin(t)) * sin(atan(((eh * -tan(t)) / ew))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) * (1.0 / Math.hypot(1.0, ((eh / ew) * Math.tan(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)) * (1.0 / math.hypot(1.0, ((eh / ew) * math.tan(t))))) - ((eh * math.sin(t)) * math.sin(math.atan(((eh * -math.tan(t)) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) * Float64(1.0 / hypot(1.0, Float64(Float64(eh / ew) * tan(t))))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * Float64(-tan(t))) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * (1.0 / hypot(1.0, ((eh / ew) * tan(t))))) - ((eh * sin(t)) * sin(atan(((eh * -tan(t)) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * (-N[Tan[t], $MachinePrecision])), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{ew} \cdot \tan t\right)} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\right|
\end{array}
Initial program 99.8%
frac-2neg99.8%
distribute-lft-neg-out99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-commutative99.8%
cos-atan99.8%
frac-2neg99.8%
metadata-eval99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/99.8%
Applied egg-rr99.8%
associate-*r/99.8%
metadata-eval99.8%
associate-*r/99.8%
associate-*l/99.8%
*-commutative99.8%
Simplified99.8%
div-inv99.8%
*-commutative99.8%
associate-/r/99.8%
hypot-udef99.8%
metadata-eval99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
sqr-neg99.8%
hypot-1-def99.8%
associate-/r/99.8%
*-commutative99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* ew (cos t)) (cos (atan (/ (* eh (- (tan t))) ew)))) (* (* eh (sin t)) (sin (atan (/ (* eh (- t)) ew)))))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) * cos(atan(((eh * -tan(t)) / ew)))) - ((eh * sin(t)) * sin(atan(((eh * -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)) * cos(atan(((eh * -tan(t)) / ew)))) - ((eh * sin(t)) * sin(atan(((eh * -t) / ew))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) * Math.cos(Math.atan(((eh * -Math.tan(t)) / ew)))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * -t) / ew))))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) * math.cos(math.atan(((eh * -math.tan(t)) / ew)))) - ((eh * math.sin(t)) * math.sin(math.atan(((eh * -t) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(atan(Float64(Float64(eh * Float64(-tan(t))) / ew)))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * Float64(-t)) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * cos(atan(((eh * -tan(t)) / ew)))) - ((eh * sin(t)) * sin(atan(((eh * -t) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh * (-N[Tan[t], $MachinePrecision])), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * (-t)), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \left(-t\right)}{ew}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 98.6%
associate-*r/98.6%
associate-*r*98.6%
neg-mul-198.6%
Simplified98.6%
Final simplification98.6%
(FPCore (eh ew t) :precision binary64 (fabs (fma eh (sin t) (* (- ew) (* (cos t) (cos (atan (* (tan t) (/ eh (- ew))))))))))
double code(double eh, double ew, double t) {
return fabs(fma(eh, sin(t), (-ew * (cos(t) * cos(atan((tan(t) * (eh / -ew))))))));
}
function code(eh, ew, t) return abs(fma(eh, sin(t), Float64(Float64(-ew) * Float64(cos(t) * cos(atan(Float64(tan(t) * Float64(eh / Float64(-ew))))))))) end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[Sin[t], $MachinePrecision] + N[((-ew) * N[(N[Cos[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[(eh / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(eh, \sin t, \left(-ew\right) \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\tan t \cdot \frac{eh}{-ew}\right)\right)\right)\right|
\end{array}
Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
sin-atan78.0%
associate-/l*77.9%
associate-*l/75.0%
div-inv75.0%
clear-num75.0%
Applied egg-rr85.4%
Taylor expanded in eh around -inf 97.4%
Final simplification97.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (* (tan t) (/ eh (- ew))))))
(if (<= ew -2.2e+22)
(fabs
(fma eh t (/ (- ew) (/ (hypot 1.0 (* eh (/ (- (tan t)) ew))) (cos t)))))
(if (<= ew 2.4e+82)
(fabs (fma eh (* (sin t) (sin t_1)) (- ew)))
(fabs (fma eh t (* ew (* (cos t) (- (cos t_1))))))))))
double code(double eh, double ew, double t) {
double t_1 = atan((tan(t) * (eh / -ew)));
double tmp;
if (ew <= -2.2e+22) {
tmp = fabs(fma(eh, t, (-ew / (hypot(1.0, (eh * (-tan(t) / ew))) / cos(t)))));
} else if (ew <= 2.4e+82) {
tmp = fabs(fma(eh, (sin(t) * sin(t_1)), -ew));
} else {
tmp = fabs(fma(eh, t, (ew * (cos(t) * -cos(t_1)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = atan(Float64(tan(t) * Float64(eh / Float64(-ew)))) tmp = 0.0 if (ew <= -2.2e+22) tmp = abs(fma(eh, t, Float64(Float64(-ew) / Float64(hypot(1.0, Float64(eh * Float64(Float64(-tan(t)) / ew))) / cos(t))))); elseif (ew <= 2.4e+82) tmp = abs(fma(eh, Float64(sin(t) * sin(t_1)), Float64(-ew))); else tmp = abs(fma(eh, t, Float64(ew * Float64(cos(t) * Float64(-cos(t_1)))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[(eh / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -2.2e+22], N[Abs[N[(eh * t + N[((-ew) / N[(N[Sqrt[1.0 ^ 2 + N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 2.4e+82], N[Abs[N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] + (-ew)), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * t + N[(ew * N[(N[Cos[t], $MachinePrecision] * (-N[Cos[t$95$1], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\tan t \cdot \frac{eh}{-ew}\right)\\
\mathbf{if}\;ew \leq -2.2 \cdot 10^{+22}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, t, \frac{-ew}{\frac{\mathsf{hypot}\left(1, eh \cdot \frac{-\tan t}{ew}\right)}{\cos t}}\right)\right|\\
\mathbf{elif}\;ew \leq 2.4 \cdot 10^{+82}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, \sin t \cdot \sin t_1, -ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, t, ew \cdot \left(\cos t \cdot \left(-\cos t_1\right)\right)\right)\right|\\
\end{array}
\end{array}
if ew < -2.2e22Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.7%
Simplified99.7%
*-commutative99.7%
sin-atan98.3%
associate-/l*98.3%
associate-*l/98.3%
div-inv98.2%
clear-num98.2%
Applied egg-rr99.7%
Taylor expanded in eh around -inf 97.9%
associate-*r*97.9%
cos-atan97.9%
un-div-inv97.9%
distribute-rgt-neg-out97.9%
distribute-lft-neg-in97.9%
associate-/l*97.9%
Applied egg-rr97.9%
Taylor expanded in t around 0 80.4%
if -2.2e22 < ew < 2.39999999999999998e82Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
associate-*r*99.8%
neg-sub099.8%
flip--99.8%
+-lft-identity99.8%
associate-*r/99.8%
Applied egg-rr99.8%
*-commutative99.8%
associate-/l*99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 87.8%
mul-1-neg87.8%
Simplified87.8%
if 2.39999999999999998e82 < ew Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
sin-atan99.8%
associate-/l*99.8%
associate-*l/99.8%
div-inv99.8%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in eh around -inf 99.8%
Taylor expanded in t around 0 88.7%
Final simplification86.0%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -2.35e+22) (not (<= ew 4.4e+84)))
(fabs
(fma eh t (/ (- ew) (/ (hypot 1.0 (* eh (/ (- (tan t)) ew))) (cos t)))))
(fabs (fma eh (* (sin t) (sin (atan (* (tan t) (/ eh (- ew)))))) (- ew)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.35e+22) || !(ew <= 4.4e+84)) {
tmp = fabs(fma(eh, t, (-ew / (hypot(1.0, (eh * (-tan(t) / ew))) / cos(t)))));
} else {
tmp = fabs(fma(eh, (sin(t) * sin(atan((tan(t) * (eh / -ew))))), -ew));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.35e+22) || !(ew <= 4.4e+84)) tmp = abs(fma(eh, t, Float64(Float64(-ew) / Float64(hypot(1.0, Float64(eh * Float64(Float64(-tan(t)) / ew))) / cos(t))))); else tmp = abs(fma(eh, Float64(sin(t) * sin(atan(Float64(tan(t) * Float64(eh / Float64(-ew)))))), Float64(-ew))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.35e+22], N[Not[LessEqual[ew, 4.4e+84]], $MachinePrecision]], N[Abs[N[(eh * t + N[((-ew) / N[(N[Sqrt[1.0 ^ 2 + N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[(eh / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + (-ew)), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.35 \cdot 10^{+22} \lor \neg \left(ew \leq 4.4 \cdot 10^{+84}\right):\\
\;\;\;\;\left|\mathsf{fma}\left(eh, t, \frac{-ew}{\frac{\mathsf{hypot}\left(1, eh \cdot \frac{-\tan t}{ew}\right)}{\cos t}}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, \sin t \cdot \sin \tan^{-1} \left(\tan t \cdot \frac{eh}{-ew}\right), -ew\right)\right|\\
\end{array}
\end{array}
if ew < -2.3500000000000001e22 or 4.3999999999999997e84 < ew Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
sin-atan98.9%
associate-/l*98.9%
associate-*l/98.9%
div-inv98.9%
clear-num98.9%
Applied egg-rr99.8%
Taylor expanded in eh around -inf 98.7%
associate-*r*98.7%
cos-atan98.7%
un-div-inv98.7%
distribute-rgt-neg-out98.7%
distribute-lft-neg-in98.7%
associate-/l*98.7%
Applied egg-rr98.7%
Taylor expanded in t around 0 83.7%
if -2.3500000000000001e22 < ew < 4.3999999999999997e84Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
associate-*r*99.8%
neg-sub099.8%
flip--99.8%
+-lft-identity99.8%
associate-*r/99.8%
Applied egg-rr99.8%
*-commutative99.8%
associate-/l*99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 87.8%
mul-1-neg87.8%
Simplified87.8%
Final simplification86.0%
(FPCore (eh ew t) :precision binary64 (fabs (fma eh (sin t) (/ (- ew) (/ (hypot 1.0 (* eh (/ (- (tan t)) ew))) (cos t))))))
double code(double eh, double ew, double t) {
return fabs(fma(eh, sin(t), (-ew / (hypot(1.0, (eh * (-tan(t) / ew))) / cos(t)))));
}
function code(eh, ew, t) return abs(fma(eh, sin(t), Float64(Float64(-ew) / Float64(hypot(1.0, Float64(eh * Float64(Float64(-tan(t)) / ew))) / cos(t))))) end
code[eh_, ew_, t_] := N[Abs[N[(eh * N[Sin[t], $MachinePrecision] + N[((-ew) / N[(N[Sqrt[1.0 ^ 2 + N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(eh, \sin t, \frac{-ew}{\frac{\mathsf{hypot}\left(1, eh \cdot \frac{-\tan t}{ew}\right)}{\cos t}}\right)\right|
\end{array}
Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
sin-atan78.0%
associate-/l*77.9%
associate-*l/75.0%
div-inv75.0%
clear-num75.0%
Applied egg-rr85.4%
Taylor expanded in eh around -inf 93.5%
associate-*r*93.5%
cos-atan93.4%
un-div-inv93.4%
distribute-rgt-neg-out93.4%
distribute-lft-neg-in93.4%
associate-/l*93.4%
Applied egg-rr93.4%
Taylor expanded in t around inf 97.4%
Final simplification97.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (- (tan t))))
(if (or (<= t -4.5e+220)
(and (not (<= t -2.5e+75)) (or (<= t -1.0) (not (<= t 1.6e+160)))))
(fabs (* (* eh (sin t)) (sin (atan (/ (* eh t_1) ew)))))
(fabs (fma eh t (/ (- ew) (/ (hypot 1.0 (* eh (/ t_1 ew))) (cos t))))))))
double code(double eh, double ew, double t) {
double t_1 = -tan(t);
double tmp;
if ((t <= -4.5e+220) || (!(t <= -2.5e+75) && ((t <= -1.0) || !(t <= 1.6e+160)))) {
tmp = fabs(((eh * sin(t)) * sin(atan(((eh * t_1) / ew)))));
} else {
tmp = fabs(fma(eh, t, (-ew / (hypot(1.0, (eh * (t_1 / ew))) / cos(t)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(-tan(t)) tmp = 0.0 if ((t <= -4.5e+220) || (!(t <= -2.5e+75) && ((t <= -1.0) || !(t <= 1.6e+160)))) tmp = abs(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * t_1) / ew))))); else tmp = abs(fma(eh, t, Float64(Float64(-ew) / Float64(hypot(1.0, Float64(eh * Float64(t_1 / ew))) / cos(t))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = (-N[Tan[t], $MachinePrecision])}, If[Or[LessEqual[t, -4.5e+220], And[N[Not[LessEqual[t, -2.5e+75]], $MachinePrecision], Or[LessEqual[t, -1.0], N[Not[LessEqual[t, 1.6e+160]], $MachinePrecision]]]], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * t$95$1), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * t + N[((-ew) / N[(N[Sqrt[1.0 ^ 2 + N[(eh * N[(t$95$1 / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\tan t\\
\mathbf{if}\;t \leq -4.5 \cdot 10^{+220} \lor \neg \left(t \leq -2.5 \cdot 10^{+75}\right) \land \left(t \leq -1 \lor \neg \left(t \leq 1.6 \cdot 10^{+160}\right)\right):\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot t_1}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, t, \frac{-ew}{\frac{\mathsf{hypot}\left(1, eh \cdot \frac{t_1}{ew}\right)}{\cos t}}\right)\right|\\
\end{array}
\end{array}
if t < -4.50000000000000011e220 or -2.5000000000000001e75 < t < -1 or 1.5999999999999999e160 < t Initial program 99.6%
fabs-sub99.6%
associate-*l*99.6%
cancel-sign-sub-inv99.6%
associate-*l*99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
associate-*r*99.6%
neg-sub099.6%
flip--99.6%
+-lft-identity99.6%
associate-*r/99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-/l*99.7%
associate-*r/99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 72.4%
mul-1-neg72.4%
Simplified72.4%
Taylor expanded in eh around inf 68.0%
associate-*r*68.0%
associate-*r/68.0%
mul-1-neg68.0%
distribute-lft-neg-out68.0%
*-commutative68.0%
Simplified68.0%
if -4.50000000000000011e220 < t < -2.5000000000000001e75 or -1 < t < 1.5999999999999999e160Initial program 99.9%
fabs-sub99.9%
associate-*l*99.9%
cancel-sign-sub-inv99.9%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
*-commutative99.9%
sin-atan84.0%
associate-/l*84.0%
associate-*l/80.0%
div-inv80.0%
clear-num80.0%
Applied egg-rr87.7%
Taylor expanded in eh around -inf 92.5%
associate-*r*92.5%
cos-atan92.4%
un-div-inv92.4%
distribute-rgt-neg-out92.4%
distribute-lft-neg-in92.4%
associate-/l*92.4%
Applied egg-rr92.4%
Taylor expanded in t around 0 84.4%
Final simplification79.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (sin (atan (/ (* eh (- (tan t))) ew)))))
(if (or (<= t -0.0037) (not (<= t 0.02)))
(fabs (* (* eh (sin t)) t_1))
(fabs (- (* t_1 (* t eh)) ew)))))
double code(double eh, double ew, double t) {
double t_1 = sin(atan(((eh * -tan(t)) / ew)));
double tmp;
if ((t <= -0.0037) || !(t <= 0.02)) {
tmp = fabs(((eh * sin(t)) * t_1));
} else {
tmp = fabs(((t_1 * (t * eh)) - 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) :: t_1
real(8) :: tmp
t_1 = sin(atan(((eh * -tan(t)) / ew)))
if ((t <= (-0.0037d0)) .or. (.not. (t <= 0.02d0))) then
tmp = abs(((eh * sin(t)) * t_1))
else
tmp = abs(((t_1 * (t * eh)) - ew))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.sin(Math.atan(((eh * -Math.tan(t)) / ew)));
double tmp;
if ((t <= -0.0037) || !(t <= 0.02)) {
tmp = Math.abs(((eh * Math.sin(t)) * t_1));
} else {
tmp = Math.abs(((t_1 * (t * eh)) - ew));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.sin(math.atan(((eh * -math.tan(t)) / ew))) tmp = 0 if (t <= -0.0037) or not (t <= 0.02): tmp = math.fabs(((eh * math.sin(t)) * t_1)) else: tmp = math.fabs(((t_1 * (t * eh)) - ew)) return tmp
function code(eh, ew, t) t_1 = sin(atan(Float64(Float64(eh * Float64(-tan(t))) / ew))) tmp = 0.0 if ((t <= -0.0037) || !(t <= 0.02)) tmp = abs(Float64(Float64(eh * sin(t)) * t_1)); else tmp = abs(Float64(Float64(t_1 * Float64(t * eh)) - ew)); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = sin(atan(((eh * -tan(t)) / ew))); tmp = 0.0; if ((t <= -0.0037) || ~((t <= 0.02))) tmp = abs(((eh * sin(t)) * t_1)); else tmp = abs(((t_1 * (t * eh)) - ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Sin[N[ArcTan[N[(N[(eh * (-N[Tan[t], $MachinePrecision])), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t, -0.0037], N[Not[LessEqual[t, 0.02]], $MachinePrecision]], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(t$95$1 * N[(t * eh), $MachinePrecision]), $MachinePrecision] - ew), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\\
\mathbf{if}\;t \leq -0.0037 \lor \neg \left(t \leq 0.02\right):\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot t_1\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t_1 \cdot \left(t \cdot eh\right) - ew\right|\\
\end{array}
\end{array}
if t < -0.0037000000000000002 or 0.0200000000000000004 < t Initial program 99.6%
fabs-sub99.6%
associate-*l*99.6%
cancel-sign-sub-inv99.6%
associate-*l*99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
associate-*r*99.6%
neg-sub099.6%
flip--99.6%
+-lft-identity99.6%
associate-*r/99.5%
Applied egg-rr99.5%
*-commutative99.5%
associate-/l*99.6%
associate-*r/99.6%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in t around 0 59.2%
mul-1-neg59.2%
Simplified59.2%
Taylor expanded in eh around inf 51.4%
associate-*r*51.4%
associate-*r/51.4%
mul-1-neg51.4%
distribute-lft-neg-out51.4%
*-commutative51.4%
Simplified51.4%
if -0.0037000000000000002 < t < 0.0200000000000000004Initial program 100.0%
fabs-sub100.0%
associate-*l*100.0%
cancel-sign-sub-inv100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
*-commutative100.0%
associate-*r*100.0%
neg-sub0100.0%
flip--100.0%
+-lft-identity100.0%
associate-*r/100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/l*99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 97.4%
mul-1-neg97.4%
Simplified97.4%
Taylor expanded in t around 0 97.4%
mul-1-neg97.4%
+-commutative97.4%
unsub-neg97.4%
associate-*r*97.4%
associate-*r/97.4%
mul-1-neg97.4%
distribute-lft-neg-out97.4%
*-commutative97.4%
Simplified97.4%
Final simplification74.2%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (sin (atan (/ (* eh (- (tan t))) ew))) (* t eh)) ew)))
double code(double eh, double ew, double t) {
return fabs(((sin(atan(((eh * -tan(t)) / ew))) * (t * eh)) - 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(((sin(atan(((eh * -tan(t)) / ew))) * (t * eh)) - ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.sin(Math.atan(((eh * -Math.tan(t)) / ew))) * (t * eh)) - ew));
}
def code(eh, ew, t): return math.fabs(((math.sin(math.atan(((eh * -math.tan(t)) / ew))) * (t * eh)) - ew))
function code(eh, ew, t) return abs(Float64(Float64(sin(atan(Float64(Float64(eh * Float64(-tan(t))) / ew))) * Float64(t * eh)) - ew)) end
function tmp = code(eh, ew, t) tmp = abs(((sin(atan(((eh * -tan(t)) / ew))) * (t * eh)) - ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[N[ArcTan[N[(N[(eh * (-N[Tan[t], $MachinePrecision])), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(t * eh), $MachinePrecision]), $MachinePrecision] - ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right) \cdot \left(t \cdot eh\right) - ew\right|
\end{array}
Initial program 99.8%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
associate-*r*99.8%
neg-sub099.8%
flip--99.8%
+-lft-identity99.8%
associate-*r/99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.7%
associate-*r/99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 78.2%
mul-1-neg78.2%
Simplified78.2%
Taylor expanded in t around 0 54.6%
mul-1-neg54.6%
+-commutative54.6%
unsub-neg54.6%
associate-*r*54.5%
associate-*r/54.5%
mul-1-neg54.5%
distribute-lft-neg-out54.5%
*-commutative54.5%
Simplified54.5%
Final simplification54.5%
(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%
fabs-sub99.8%
associate-*l*99.8%
cancel-sign-sub-inv99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
*-commutative99.8%
associate-*r*99.8%
neg-sub099.8%
flip--99.8%
+-lft-identity99.8%
associate-*r/99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.7%
associate-*r/99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in t around 0 78.2%
mul-1-neg78.2%
Simplified78.2%
Taylor expanded in eh around 0 42.5%
mul-1-neg42.5%
Simplified42.5%
Final simplification42.5%
herbie shell --seed 2023297
(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)))))))