
(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 9 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 (+ (* eh (* (sin t) (sin (atan (* eh (/ (tan t) (- ew))))))) (* (* ew (cos t)) (/ -1.0 (hypot 1.0 (/ eh (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * (sin(t) * sin(atan((eh * (tan(t) / -ew)))))) + ((ew * cos(t)) * (-1.0 / hypot(1.0, (eh / (ew / tan(t))))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * (Math.sin(t) * Math.sin(Math.atan((eh * (Math.tan(t) / -ew)))))) + ((ew * Math.cos(t)) * (-1.0 / Math.hypot(1.0, (eh / (ew / Math.tan(t))))))));
}
def code(eh, ew, t): return math.fabs(((eh * (math.sin(t) * math.sin(math.atan((eh * (math.tan(t) / -ew)))))) + ((ew * math.cos(t)) * (-1.0 / math.hypot(1.0, (eh / (ew / math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))))) + Float64(Float64(ew * cos(t)) * Float64(-1.0 / hypot(1.0, Float64(eh / Float64(ew / tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * (sin(t) * sin(atan((eh * (tan(t) / -ew)))))) + ((ew * cos(t)) * (-1.0 / hypot(1.0, (eh / (ew / tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right) + \left(ew \cdot \cos t\right) \cdot \frac{-1}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)}\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt49.9%
sqrt-unprod94.0%
sqr-neg94.0%
sqrt-unprod49.9%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (/ (* ew (cos t)) (hypot 1.0 (* 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)) / hypot(1.0, (eh * (tan(t) / 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)) / Math.hypot(1.0, (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.hypot(1.0, (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)) / hypot(1.0, Float64(eh * Float64(tan(t) / ew)))) - Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) / hypot(1.0, (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[Sqrt[1.0 ^ 2 + N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{ew}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
un-div-inv99.8%
hypot-1-def99.8%
add-sqr-sqrt49.9%
sqrt-unprod94.0%
sqr-neg94.0%
sqrt-unprod49.9%
add-sqr-sqrt99.8%
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(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * tan(t)) / Float64(-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[(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|ew \cdot \cos t - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt49.9%
sqrt-unprod94.0%
sqr-neg94.0%
sqrt-unprod49.9%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in eh around 0 98.9%
mul-1-neg98.9%
+-commutative98.9%
unsub-neg98.9%
associate-*r*98.9%
associate-*r/98.9%
mul-1-neg98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* ew (cos t)))))
(if (<= ew -6.4e-75)
t_1
(if (<= ew 7.8e-94)
(fabs (* eh (sin t)))
(if (<= ew 1.2e-14)
(fabs (- (* eh (* t (sin (atan (* eh (/ (tan t) (- ew))))))) ew))
t_1)))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -6.4e-75) {
tmp = t_1;
} else if (ew <= 7.8e-94) {
tmp = fabs((eh * sin(t)));
} else if (ew <= 1.2e-14) {
tmp = fabs(((eh * (t * sin(atan((eh * (tan(t) / -ew)))))) - ew));
} else {
tmp = 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 = abs((ew * cos(t)))
if (ew <= (-6.4d-75)) then
tmp = t_1
else if (ew <= 7.8d-94) then
tmp = abs((eh * sin(t)))
else if (ew <= 1.2d-14) then
tmp = abs(((eh * (t * sin(atan((eh * (tan(t) / -ew)))))) - ew))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((ew * Math.cos(t)));
double tmp;
if (ew <= -6.4e-75) {
tmp = t_1;
} else if (ew <= 7.8e-94) {
tmp = Math.abs((eh * Math.sin(t)));
} else if (ew <= 1.2e-14) {
tmp = Math.abs(((eh * (t * Math.sin(Math.atan((eh * (Math.tan(t) / -ew)))))) - ew));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.cos(t))) tmp = 0 if ew <= -6.4e-75: tmp = t_1 elif ew <= 7.8e-94: tmp = math.fabs((eh * math.sin(t))) elif ew <= 1.2e-14: tmp = math.fabs(((eh * (t * math.sin(math.atan((eh * (math.tan(t) / -ew)))))) - ew)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -6.4e-75) tmp = t_1; elseif (ew <= 7.8e-94) tmp = abs(Float64(eh * sin(t))); elseif (ew <= 1.2e-14) tmp = abs(Float64(Float64(eh * Float64(t * sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))))) - ew)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((ew * cos(t))); tmp = 0.0; if (ew <= -6.4e-75) tmp = t_1; elseif (ew <= 7.8e-94) tmp = abs((eh * sin(t))); elseif (ew <= 1.2e-14) tmp = abs(((eh * (t * sin(atan((eh * (tan(t) / -ew)))))) - ew)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -6.4e-75], t$95$1, If[LessEqual[ew, 7.8e-94], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 1.2e-14], N[Abs[N[(N[(eh * N[(t * N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - ew), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -6.4 \cdot 10^{-75}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 7.8 \cdot 10^{-94}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{elif}\;ew \leq 1.2 \cdot 10^{-14}:\\
\;\;\;\;\left|eh \cdot \left(t \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right) - ew\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -6.39999999999999953e-75 or 1.2e-14 < ew Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt44.9%
sqrt-unprod89.5%
sqr-neg89.5%
sqrt-unprod54.9%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in ew around inf 87.0%
if -6.39999999999999953e-75 < ew < 7.8000000000000004e-94Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt54.5%
sqrt-unprod99.2%
sqr-neg99.2%
sqrt-unprod45.3%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan53.1%
associate-*r/52.8%
add-sqr-sqrt28.7%
sqrt-unprod48.4%
sqr-neg48.4%
sqrt-unprod24.0%
add-sqr-sqrt52.7%
hypot-1-def69.5%
add-sqr-sqrt39.6%
Applied egg-rr69.5%
associate-/l*79.3%
associate-*l*79.3%
associate-*r/79.1%
associate-/l/79.4%
associate-*r/79.5%
associate-*l/66.3%
associate-/r/79.3%
Simplified79.3%
Taylor expanded in eh around -inf 76.5%
if 7.8000000000000004e-94 < ew < 1.2e-14Initial program 99.8%
sub-neg99.8%
associate-*l*99.9%
distribute-rgt-neg-in99.9%
cancel-sign-sub99.9%
associate-/l*99.9%
Simplified99.9%
cos-atan99.9%
hypot-1-def99.9%
add-sqr-sqrt60.6%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod39.3%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
associate-*r/99.9%
associate-*l/99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in t around 0 75.2%
associate-*r*75.2%
neg-mul-175.2%
mul-1-neg75.2%
associate-*r/75.2%
Simplified75.2%
Final simplification82.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* ew (cos t)))))
(if (<= ew -1.7e-76)
t_1
(if (<= ew 3.1e-94)
(fabs (* eh (sin t)))
(if (<= ew 1e-16)
(fabs (- ew (* (sin (atan (/ (* eh (tan t)) (- ew)))) (* t eh))))
t_1)))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -1.7e-76) {
tmp = t_1;
} else if (ew <= 3.1e-94) {
tmp = fabs((eh * sin(t)));
} else if (ew <= 1e-16) {
tmp = fabs((ew - (sin(atan(((eh * tan(t)) / -ew))) * (t * eh))));
} else {
tmp = 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 = abs((ew * cos(t)))
if (ew <= (-1.7d-76)) then
tmp = t_1
else if (ew <= 3.1d-94) then
tmp = abs((eh * sin(t)))
else if (ew <= 1d-16) then
tmp = abs((ew - (sin(atan(((eh * tan(t)) / -ew))) * (t * eh))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((ew * Math.cos(t)));
double tmp;
if (ew <= -1.7e-76) {
tmp = t_1;
} else if (ew <= 3.1e-94) {
tmp = Math.abs((eh * Math.sin(t)));
} else if (ew <= 1e-16) {
tmp = Math.abs((ew - (Math.sin(Math.atan(((eh * Math.tan(t)) / -ew))) * (t * eh))));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.cos(t))) tmp = 0 if ew <= -1.7e-76: tmp = t_1 elif ew <= 3.1e-94: tmp = math.fabs((eh * math.sin(t))) elif ew <= 1e-16: tmp = math.fabs((ew - (math.sin(math.atan(((eh * math.tan(t)) / -ew))) * (t * eh)))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -1.7e-76) tmp = t_1; elseif (ew <= 3.1e-94) tmp = abs(Float64(eh * sin(t))); elseif (ew <= 1e-16) tmp = abs(Float64(ew - Float64(sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew)))) * Float64(t * eh)))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((ew * cos(t))); tmp = 0.0; if (ew <= -1.7e-76) tmp = t_1; elseif (ew <= 3.1e-94) tmp = abs((eh * sin(t))); elseif (ew <= 1e-16) tmp = abs((ew - (sin(atan(((eh * tan(t)) / -ew))) * (t * eh)))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1.7e-76], t$95$1, If[LessEqual[ew, 3.1e-94], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 1e-16], N[Abs[N[(ew - N[(N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(t * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -1.7 \cdot 10^{-76}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 3.1 \cdot 10^{-94}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{elif}\;ew \leq 10^{-16}:\\
\;\;\;\;\left|ew - \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) \cdot \left(t \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.7e-76 or 9.9999999999999998e-17 < ew Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt44.9%
sqrt-unprod89.5%
sqr-neg89.5%
sqrt-unprod54.9%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in ew around inf 87.0%
if -1.7e-76 < ew < 3.0999999999999998e-94Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt54.5%
sqrt-unprod99.2%
sqr-neg99.2%
sqrt-unprod45.3%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan53.1%
associate-*r/52.8%
add-sqr-sqrt28.7%
sqrt-unprod48.4%
sqr-neg48.4%
sqrt-unprod24.0%
add-sqr-sqrt52.7%
hypot-1-def69.5%
add-sqr-sqrt39.6%
Applied egg-rr69.5%
associate-/l*79.3%
associate-*l*79.3%
associate-*r/79.1%
associate-/l/79.4%
associate-*r/79.5%
associate-*l/66.3%
associate-/r/79.3%
Simplified79.3%
Taylor expanded in eh around -inf 76.5%
if 3.0999999999999998e-94 < ew < 9.9999999999999998e-17Initial program 99.8%
sub-neg99.8%
associate-*l*99.9%
distribute-rgt-neg-in99.9%
cancel-sign-sub99.9%
associate-/l*99.9%
Simplified99.9%
cos-atan99.9%
hypot-1-def99.9%
add-sqr-sqrt60.6%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod39.3%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
associate-*r/99.9%
associate-*l/99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in t around 0 75.2%
mul-1-neg75.2%
unsub-neg75.2%
associate-*r*75.2%
*-commutative75.2%
associate-*r/75.2%
mul-1-neg75.2%
Simplified75.2%
Final simplification82.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.9e-92) (not (<= ew 1.95e-93))) (fabs (* ew (cos t))) (fabs (* eh (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.9e-92) || !(ew <= 1.95e-93)) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((eh * sin(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.9d-92)) .or. (.not. (ew <= 1.95d-93))) then
tmp = abs((ew * cos(t)))
else
tmp = abs((eh * sin(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.9e-92) || !(ew <= 1.95e-93)) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((eh * Math.sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.9e-92) or not (ew <= 1.95e-93): tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((eh * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.9e-92) || !(ew <= 1.95e-93)) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(eh * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.9e-92) || ~((ew <= 1.95e-93))) tmp = abs((ew * cos(t))); else tmp = abs((eh * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.9e-92], N[Not[LessEqual[ew, 1.95e-93]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.9 \cdot 10^{-92} \lor \neg \left(ew \leq 1.95 \cdot 10^{-93}\right):\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\end{array}
\end{array}
if ew < -1.9e-92 or 1.95000000000000009e-93 < ew Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt47.5%
sqrt-unprod91.2%
sqr-neg91.2%
sqrt-unprod52.3%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in ew around inf 82.4%
if -1.9e-92 < ew < 1.95000000000000009e-93Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt54.5%
sqrt-unprod99.2%
sqr-neg99.2%
sqrt-unprod45.3%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan53.1%
associate-*r/52.8%
add-sqr-sqrt28.7%
sqrt-unprod48.4%
sqr-neg48.4%
sqrt-unprod24.0%
add-sqr-sqrt52.7%
hypot-1-def69.5%
add-sqr-sqrt39.6%
Applied egg-rr69.5%
associate-/l*79.3%
associate-*l*79.3%
associate-*r/79.1%
associate-/l/79.4%
associate-*r/79.5%
associate-*l/66.3%
associate-/r/79.3%
Simplified79.3%
Taylor expanded in eh around -inf 76.5%
Final simplification80.4%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -2.9e-39) (not (<= t 1.6e-5))) (fabs (* eh (sin t))) (fabs ew)))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -2.9e-39) || !(t <= 1.6e-5)) {
tmp = fabs((eh * sin(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 <= (-2.9d-39)) .or. (.not. (t <= 1.6d-5))) then
tmp = abs((eh * sin(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 <= -2.9e-39) || !(t <= 1.6e-5)) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -2.9e-39) or not (t <= 1.6e-5): tmp = math.fabs((eh * math.sin(t))) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -2.9e-39) || !(t <= 1.6e-5)) tmp = abs(Float64(eh * sin(t))); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -2.9e-39) || ~((t <= 1.6e-5))) tmp = abs((eh * sin(t))); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -2.9e-39], N[Not[LessEqual[t, 1.6e-5]], $MachinePrecision]], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{-39} \lor \neg \left(t \leq 1.6 \cdot 10^{-5}\right):\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if t < -2.89999999999999988e-39 or 1.59999999999999993e-5 < t Initial program 99.6%
sub-neg99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
cancel-sign-sub99.6%
associate-/l*99.6%
Simplified99.6%
cos-atan99.6%
hypot-1-def99.6%
add-sqr-sqrt50.9%
sqrt-unprod96.5%
sqr-neg96.5%
sqrt-unprod48.7%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
associate-*r/99.6%
associate-*l/99.6%
associate-/r/99.6%
Simplified99.6%
associate-*r*99.6%
sin-atan74.2%
associate-*r/72.6%
add-sqr-sqrt37.0%
sqrt-unprod64.1%
sqr-neg64.1%
sqrt-unprod35.1%
add-sqr-sqrt71.7%
hypot-1-def77.0%
add-sqr-sqrt39.5%
Applied egg-rr77.0%
associate-/l*85.4%
associate-*l*85.4%
associate-*r/85.3%
associate-/l/85.5%
associate-*r/85.6%
associate-*l/85.6%
associate-/r/85.5%
Simplified85.5%
Taylor expanded in eh around -inf 51.2%
if -2.89999999999999988e-39 < t < 1.59999999999999993e-5Initial program 100.0%
sub-neg100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
cancel-sign-sub100.0%
associate-/l*100.0%
Simplified100.0%
cos-atan100.0%
hypot-1-def100.0%
add-sqr-sqrt48.8%
sqrt-unprod91.2%
sqr-neg91.2%
sqrt-unprod51.2%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
associate-*r/100.0%
associate-*l/100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in t around 0 76.2%
Final simplification63.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -3.4e+147) (not (<= eh 1.02e+257))) (fabs (* t eh)) (fabs ew)))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3.4e+147) || !(eh <= 1.02e+257)) {
tmp = fabs((t * eh));
} 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 ((eh <= (-3.4d+147)) .or. (.not. (eh <= 1.02d+257))) then
tmp = abs((t * eh))
else
tmp = abs(ew)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3.4e+147) || !(eh <= 1.02e+257)) {
tmp = Math.abs((t * eh));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -3.4e+147) or not (eh <= 1.02e+257): tmp = math.fabs((t * eh)) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -3.4e+147) || !(eh <= 1.02e+257)) tmp = abs(Float64(t * eh)); else tmp = abs(ew); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -3.4e+147) || ~((eh <= 1.02e+257))) tmp = abs((t * eh)); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -3.4e+147], N[Not[LessEqual[eh, 1.02e+257]], $MachinePrecision]], N[Abs[N[(t * eh), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3.4 \cdot 10^{+147} \lor \neg \left(eh \leq 1.02 \cdot 10^{+257}\right):\\
\;\;\;\;\left|t \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if eh < -3.4e147 or 1.02e257 < eh Initial program 99.9%
sub-neg99.9%
associate-*l*99.9%
distribute-rgt-neg-in99.9%
cancel-sign-sub99.9%
associate-/l*99.9%
Simplified99.9%
cos-atan99.9%
hypot-1-def99.9%
add-sqr-sqrt71.0%
sqrt-unprod86.9%
sqr-neg86.9%
sqrt-unprod28.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
associate-*r/99.9%
associate-*l/99.9%
associate-/r/99.9%
Simplified99.9%
associate-*r*99.9%
sin-atan29.9%
associate-*r/25.2%
add-sqr-sqrt20.5%
sqrt-unprod1.1%
sqr-neg1.1%
sqrt-unprod4.7%
add-sqr-sqrt25.2%
hypot-1-def43.4%
add-sqr-sqrt36.0%
Applied egg-rr43.4%
associate-/l*66.6%
associate-*l*66.6%
associate-*r/66.4%
associate-/l/67.0%
associate-*r/67.1%
associate-*l/41.2%
associate-/r/66.9%
Simplified66.9%
Taylor expanded in eh around -inf 87.3%
Taylor expanded in t around 0 52.6%
*-commutative52.6%
Simplified52.6%
if -3.4e147 < eh < 1.02e257Initial program 99.8%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt45.4%
sqrt-unprod95.5%
sqr-neg95.5%
sqrt-unprod54.4%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in t around 0 48.9%
Final simplification49.6%
(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%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
add-sqr-sqrt49.9%
sqrt-unprod94.0%
sqr-neg94.0%
sqrt-unprod49.9%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in t around 0 43.3%
herbie shell --seed 2024145
(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)))))))