
(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 (fabs (- (* (* ew (cos t)) (cbrt (pow (cos (atan (* eh (/ (tan t) ew)))) 3.0))) (* (* eh (sin t)) (sin (atan (/ (* eh (- (tan t))) ew)))))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) * cbrt(pow(cos(atan((eh * (tan(t) / ew)))), 3.0))) - ((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)) * Math.cbrt(Math.pow(Math.cos(Math.atan((eh * (Math.tan(t) / ew)))), 3.0))) - ((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)) * cbrt((cos(atan(Float64(eh * Float64(tan(t) / ew)))) ^ 3.0))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * Float64(-tan(t))) / ew)))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Power[N[Power[N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $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 \sqrt[3]{{\cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)}^{3}} - \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%
associate-*r/99.8%
add-cbrt-cube99.8%
pow399.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (* (cos t) (/ -1.0 (hypot 1.0 (* (tan t) (/ eh ew))))) (* (sin t) (* eh (sin (atan (* (tan t) (- (/ eh ew))))))))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, (cos(t) * (-1.0 / hypot(1.0, (tan(t) * (eh / ew))))), (sin(t) * (eh * sin(atan((tan(t) * -(eh / ew))))))));
}
function code(eh, ew, t) return abs(fma(ew, Float64(cos(t) * Float64(-1.0 / hypot(1.0, Float64(tan(t) * Float64(eh / ew))))), Float64(sin(t) * Float64(eh * sin(atan(Float64(tan(t) * Float64(-Float64(eh / ew))))))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] * N[(-1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[t], $MachinePrecision] * N[(eh * N[Sin[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(ew, \cos t \cdot \frac{-1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}, \sin t \cdot \left(eh \cdot \sin \tan^{-1} \left(\tan t \cdot \left(-\frac{eh}{ew}\right)\right)\right)\right)\right|
\end{array}
Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in eh around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*l*99.8%
mul-1-neg99.8%
distribute-frac-neg299.8%
*-commutative99.8%
associate-/l*99.8%
Simplified99.8%
add-sqr-sqrt47.5%
sqrt-unprod90.0%
sqr-neg90.0%
sqrt-unprod50.1%
add-sqr-sqrt97.6%
associate-*r/97.6%
Applied egg-rr99.8%
cos-atan99.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*r/99.8%
Applied egg-rr99.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 (- (tan 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 * -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)) * cos(atan((eh * (tan(t) / ew))))) - ((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)) * Math.cos(Math.atan((eh * (Math.tan(t) / ew))))) - ((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)) * math.cos(math.atan((eh * (math.tan(t) / ew))))) - ((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)) * cos(atan(Float64(eh * Float64(tan(t) / ew))))) - 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)) * cos(atan((eh * (tan(t) / ew))))) - ((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[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $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 \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\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%
associate-*r/99.8%
add-sqr-sqrt48.3%
sqrt-unprod91.4%
sqr-neg91.4%
sqrt-unprod51.4%
add-sqr-sqrt99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* ew (cos t)) (/ 1.0 (hypot 1.0 (* (tan t) (/ eh ew))))) (* (* 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, (tan(t) * (eh / ew))))) - ((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, (Math.tan(t) * (eh / ew))))) - ((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, (math.tan(t) * (eh / ew))))) - ((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(tan(t) * Float64(eh / ew))))) - 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, (tan(t) * (eh / ew))))) - ((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[Tan[t], $MachinePrecision] * N[(eh / ew), $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, \tan t \cdot \frac{eh}{ew}\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%
associate-*r/99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt48.3%
sqrt-unprod91.2%
sqr-neg91.2%
sqrt-unprod51.4%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-commutative99.8%
associate-*l/99.8%
associate-*r/99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* ew (cos t)) (cos (atan (/ (* (tan t) (- eh)) ew)))) (* (* eh (sin t)) (sin (atan (* t (- (/ eh ew)))))))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) * cos(atan(((tan(t) * -eh) / ew)))) - ((eh * sin(t)) * sin(atan((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((((ew * cos(t)) * cos(atan(((tan(t) * -eh) / ew)))) - ((eh * sin(t)) * sin(atan((t * -(eh / ew)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) * Math.cos(Math.atan(((Math.tan(t) * -eh) / ew)))) - ((eh * Math.sin(t)) * Math.sin(Math.atan((t * -(eh / ew)))))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) * math.cos(math.atan(((math.tan(t) * -eh) / ew)))) - ((eh * math.sin(t)) * math.sin(math.atan((t * -(eh / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(atan(Float64(Float64(tan(t) * Float64(-eh)) / ew)))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(t * Float64(-Float64(eh / ew)))))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * cos(atan(((tan(t) * -eh) / ew)))) - ((eh * sin(t)) * sin(atan((t * -(eh / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] * (-eh)), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(t * (-N[(eh / ew), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\tan t \cdot \left(-eh\right)}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(t \cdot \left(-\frac{eh}{ew}\right)\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 97.8%
associate-*r/97.8%
associate-*r*97.8%
associate-*l/97.8%
associate-*r/97.8%
*-commutative97.8%
associate-*l*97.8%
neg-mul-197.8%
Simplified97.8%
Final simplification97.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (* (cos t) (- (cos (atan (* eh (- (/ (tan t) ew))))))) (* eh (- (sin t))))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, (cos(t) * -cos(atan((eh * -(tan(t) / ew))))), (eh * -sin(t))));
}
function code(eh, ew, t) return abs(fma(ew, Float64(cos(t) * Float64(-cos(atan(Float64(eh * Float64(-Float64(tan(t) / ew))))))), Float64(eh * Float64(-sin(t))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] * (-N[Cos[N[ArcTan[N[(eh * (-N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])), $MachinePrecision] + N[(eh * (-N[Sin[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \cos t \cdot \left(-\cos \tan^{-1} \left(eh \cdot \left(-\frac{\tan t}{ew}\right)\right)\right), eh \cdot \left(-\sin t\right)\right)\right|
\end{array}
Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
sin-atan83.0%
associate-*r/82.9%
add-sqr-sqrt40.2%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod41.6%
add-sqr-sqrt81.6%
hypot-1-def90.2%
add-sqr-sqrt43.6%
sqrt-unprod75.0%
sqr-neg75.0%
sqrt-unprod46.4%
add-sqr-sqrt90.2%
Applied egg-rr90.2%
*-commutative90.2%
associate-*l*88.6%
associate-/l*86.7%
*-commutative86.7%
*-commutative86.7%
associate-*l/86.6%
associate-*r/85.8%
Simplified85.8%
Taylor expanded in eh around -inf 97.6%
mul-1-neg84.1%
Simplified97.6%
Final simplification97.6%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (* (cos t) (- (cos (atan (/ (* eh (tan t)) ew))))) (* eh (sin t)))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, (cos(t) * -cos(atan(((eh * tan(t)) / ew)))), (eh * sin(t))));
}
function code(eh, ew, t) return abs(fma(ew, Float64(cos(t) * Float64(-cos(atan(Float64(Float64(eh * tan(t)) / ew))))), Float64(eh * sin(t)))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Cos[t], $MachinePrecision] * (-N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])), $MachinePrecision] + N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \cos t \cdot \left(-\cos \tan^{-1} \left(\frac{eh \cdot \tan t}{ew}\right)\right), eh \cdot \sin t\right)\right|
\end{array}
Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
sin-atan83.0%
associate-*r/82.9%
add-sqr-sqrt40.2%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod41.6%
add-sqr-sqrt81.6%
hypot-1-def90.2%
add-sqr-sqrt43.6%
sqrt-unprod75.0%
sqr-neg75.0%
sqrt-unprod46.4%
add-sqr-sqrt90.2%
Applied egg-rr90.2%
*-commutative90.2%
associate-*l*88.6%
associate-/l*86.7%
*-commutative86.7%
*-commutative86.7%
associate-*l/86.6%
associate-*r/85.8%
Simplified85.8%
Taylor expanded in eh around inf 97.6%
add-sqr-sqrt47.5%
sqrt-unprod90.0%
sqr-neg90.0%
sqrt-unprod50.1%
add-sqr-sqrt97.6%
associate-*r/97.6%
Applied egg-rr97.6%
Final simplification97.6%
(FPCore (eh ew t)
:precision binary64
(if (<= ew 1.75e+139)
(fabs
(fma
ew
(* (- (cos t)) (cos (atan (* (- eh) (/ t ew)))))
(* eh (- (sin t)))))
(fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= 1.75e+139) {
tmp = fabs(fma(ew, (-cos(t) * cos(atan((-eh * (t / ew))))), (eh * -sin(t))));
} else {
tmp = fabs((ew * cos(t)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (ew <= 1.75e+139) tmp = abs(fma(ew, Float64(Float64(-cos(t)) * cos(atan(Float64(Float64(-eh) * Float64(t / ew))))), Float64(eh * Float64(-sin(t))))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[ew, 1.75e+139], N[Abs[N[(ew * N[((-N[Cos[t], $MachinePrecision]) * N[Cos[N[ArcTan[N[((-eh) * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(eh * (-N[Sin[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq 1.75 \cdot 10^{+139}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew, \left(-\cos t\right) \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right), eh \cdot \left(-\sin t\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if ew < 1.74999999999999989e139Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
sin-atan80.1%
associate-*r/80.0%
add-sqr-sqrt41.3%
sqrt-unprod62.2%
sqr-neg62.2%
sqrt-unprod37.8%
add-sqr-sqrt78.8%
hypot-1-def88.9%
add-sqr-sqrt45.3%
sqrt-unprod72.6%
sqr-neg72.6%
sqrt-unprod43.5%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
*-commutative88.9%
associate-*l*87.0%
associate-/l*84.8%
*-commutative84.8%
*-commutative84.8%
associate-*l/84.7%
associate-*r/83.9%
Simplified83.9%
Taylor expanded in t around 0 70.5%
Taylor expanded in eh around -inf 85.4%
mul-1-neg85.4%
Simplified85.4%
if 1.74999999999999989e139 < ew Initial program 99.7%
fabs-sub99.7%
sub-neg99.7%
+-commutative99.7%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.7%
Simplified99.7%
sin-mult96.6%
associate-*r/96.6%
Applied egg-rr96.6%
+-inverses96.6%
mul0-rgt96.6%
metadata-eval96.6%
Simplified96.6%
add-sqr-sqrt26.1%
pow226.1%
Applied egg-rr70.1%
Taylor expanded in ew around inf 96.7%
Final simplification87.0%
(FPCore (eh ew t)
:precision binary64
(if (<= ew 4.35e+139)
(fabs
(fma ew (* (- (cos t)) (cos (atan (* (- eh) (/ t ew))))) (* eh (sin t))))
(fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= 4.35e+139) {
tmp = fabs(fma(ew, (-cos(t) * cos(atan((-eh * (t / ew))))), (eh * sin(t))));
} else {
tmp = fabs((ew * cos(t)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (ew <= 4.35e+139) tmp = abs(fma(ew, Float64(Float64(-cos(t)) * cos(atan(Float64(Float64(-eh) * Float64(t / ew))))), Float64(eh * sin(t)))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[ew, 4.35e+139], N[Abs[N[(ew * N[((-N[Cos[t], $MachinePrecision]) * N[Cos[N[ArcTan[N[((-eh) * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq 4.35 \cdot 10^{+139}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew, \left(-\cos t\right) \cdot \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right), eh \cdot \sin t\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if ew < 4.3499999999999998e139Initial program 99.8%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
sin-atan80.1%
associate-*r/80.0%
add-sqr-sqrt41.3%
sqrt-unprod62.2%
sqr-neg62.2%
sqrt-unprod37.8%
add-sqr-sqrt78.8%
hypot-1-def88.9%
add-sqr-sqrt45.3%
sqrt-unprod72.6%
sqr-neg72.6%
sqrt-unprod43.5%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
*-commutative88.9%
associate-*l*87.0%
associate-/l*84.8%
*-commutative84.8%
*-commutative84.8%
associate-*l/84.7%
associate-*r/83.9%
Simplified83.9%
Taylor expanded in eh around inf 97.8%
Taylor expanded in t around 0 85.3%
if 4.3499999999999998e139 < ew Initial program 99.7%
fabs-sub99.7%
sub-neg99.7%
+-commutative99.7%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.7%
Simplified99.7%
sin-mult96.6%
associate-*r/96.6%
Applied egg-rr96.6%
+-inverses96.6%
mul0-rgt96.6%
metadata-eval96.6%
Simplified96.6%
add-sqr-sqrt26.1%
pow226.1%
Applied egg-rr70.1%
Taylor expanded in ew around inf 96.7%
Final simplification87.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%
fabs-sub99.8%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
sin-mult65.9%
associate-*r/65.9%
Applied egg-rr65.5%
+-inverses65.5%
mul0-rgt65.5%
metadata-eval65.5%
Simplified65.5%
add-sqr-sqrt30.2%
pow230.2%
Applied egg-rr35.1%
Taylor expanded in ew around inf 65.7%
Final simplification65.7%
(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%
sub-neg99.8%
+-commutative99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
Simplified99.8%
sin-mult65.9%
associate-*r/65.9%
Applied egg-rr65.5%
+-inverses65.5%
mul0-rgt65.5%
metadata-eval65.5%
Simplified65.5%
add-sqr-sqrt30.2%
pow230.2%
Applied egg-rr35.1%
Taylor expanded in t around 0 41.1%
Final simplification41.1%
herbie shell --seed 2024075
(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)))))))