
(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 (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(eh * Float64(Float64(-tan(t)) / ew))) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(eh * Float64(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[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - eh \cdot \left(\sin t \cdot \sin t\_1\right)\right|
\end{array}
\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%
Final simplification99.8%
(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(eh / Float64(ew / tan(t)))))) - Float64(eh * Float64(sin(t) * sin(atan(Float64(eh * Float64(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[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $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|\left(ew \cdot \cos t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\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%
hypot-1-def99.8%
associate-*r/99.8%
*-commutative99.8%
associate-/l*99.8%
add-sqr-sqrt49.9%
sqrt-unprod92.9%
sqr-neg92.9%
sqrt-unprod49.9%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-commutative99.8%
associate-/r/99.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 (/ (- (* t eh)) 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((-(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(((eh * -tan(t)) / 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(((eh * -Math.tan(t)) / 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(((eh * -math.tan(t)) / 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(eh * Float64(-tan(t))) / ew)))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(-Float64(t * eh)) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * cos(atan(((eh * -tan(t)) / 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[(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[(t * eh), $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{-t \cdot eh}{ew}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 99.0%
associate-*r*99.0%
mul-1-neg99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))))
(if (or (<= eh -5.8e-126) (not (<= eh 1.05e-86)))
(fabs (- (* t_1 (cos (atan (/ (- (* t eh)) ew)))) (* eh (sin t))))
(fabs (* t_1 (cos (atan (* eh (/ (- (tan t)) ew)))))))))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double tmp;
if ((eh <= -5.8e-126) || !(eh <= 1.05e-86)) {
tmp = fabs(((t_1 * cos(atan((-(t * eh) / ew)))) - (eh * sin(t))));
} else {
tmp = fabs((t_1 * cos(atan((eh * (-tan(t) / 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 = ew * cos(t)
if ((eh <= (-5.8d-126)) .or. (.not. (eh <= 1.05d-86))) then
tmp = abs(((t_1 * cos(atan((-(t * eh) / ew)))) - (eh * sin(t))))
else
tmp = abs((t_1 * cos(atan((eh * (-tan(t) / ew))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.cos(t);
double tmp;
if ((eh <= -5.8e-126) || !(eh <= 1.05e-86)) {
tmp = Math.abs(((t_1 * Math.cos(Math.atan((-(t * eh) / ew)))) - (eh * Math.sin(t))));
} else {
tmp = Math.abs((t_1 * Math.cos(Math.atan((eh * (-Math.tan(t) / ew))))));
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.cos(t) tmp = 0 if (eh <= -5.8e-126) or not (eh <= 1.05e-86): tmp = math.fabs(((t_1 * math.cos(math.atan((-(t * eh) / ew)))) - (eh * math.sin(t)))) else: tmp = math.fabs((t_1 * math.cos(math.atan((eh * (-math.tan(t) / ew)))))) return tmp
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) tmp = 0.0 if ((eh <= -5.8e-126) || !(eh <= 1.05e-86)) tmp = abs(Float64(Float64(t_1 * cos(atan(Float64(Float64(-Float64(t * eh)) / ew)))) - Float64(eh * sin(t)))); else tmp = abs(Float64(t_1 * cos(atan(Float64(eh * Float64(Float64(-tan(t)) / ew)))))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * cos(t); tmp = 0.0; if ((eh <= -5.8e-126) || ~((eh <= 1.05e-86))) tmp = abs(((t_1 * cos(atan((-(t * eh) / ew)))) - (eh * sin(t)))); else tmp = abs((t_1 * cos(atan((eh * (-tan(t) / ew)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -5.8e-126], N[Not[LessEqual[eh, 1.05e-86]], $MachinePrecision]], N[Abs[N[(N[(t$95$1 * N[Cos[N[ArcTan[N[((-N[(t * eh), $MachinePrecision]) / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 * N[Cos[N[ArcTan[N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
\mathbf{if}\;eh \leq -5.8 \cdot 10^{-126} \lor \neg \left(eh \leq 1.05 \cdot 10^{-86}\right):\\
\;\;\;\;\left|t\_1 \cdot \cos \tan^{-1} \left(\frac{-t \cdot eh}{ew}\right) - eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1 \cdot \cos \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right)\right|\\
\end{array}
\end{array}
if eh < -5.79999999999999975e-126 or 1.05e-86 < eh 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%
associate-*r*99.8%
sin-atan69.7%
associate-*r/64.8%
associate-*r/64.7%
*-commutative64.7%
associate-/l*64.6%
add-sqr-sqrt31.1%
sqrt-unprod48.8%
sqr-neg48.8%
sqrt-unprod33.0%
add-sqr-sqrt63.4%
hypot-1-def69.9%
associate-*r/69.9%
Applied egg-rr69.9%
associate-*l*69.9%
*-commutative69.9%
associate-/r/69.9%
*-commutative69.9%
associate-/r/71.7%
Simplified71.7%
Taylor expanded in eh around inf 98.1%
Taylor expanded in t around 0 91.3%
associate-*r/91.3%
associate-*r*91.3%
mul-1-neg91.3%
Simplified91.3%
if -5.79999999999999975e-126 < eh < 1.05e-86Initial 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%
Applied egg-rr96.8%
+-inverses96.8%
associate-/l*96.8%
metadata-eval96.8%
mul0-rgt96.8%
Simplified96.8%
Final simplification93.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (sin t)))
(t_2 (* ew (cos t)))
(t_3 (* t_2 (cos (atan (/ (- (* t eh)) ew))))))
(if (<= eh -1.65e-125)
(fabs (- t_3 t_1))
(if (<= eh 3.65e-87)
(fabs (* t_2 (cos (atan (* eh (/ (- (tan t)) ew))))))
(fabs (+ t_1 t_3))))))
double code(double eh, double ew, double t) {
double t_1 = eh * sin(t);
double t_2 = ew * cos(t);
double t_3 = t_2 * cos(atan((-(t * eh) / ew)));
double tmp;
if (eh <= -1.65e-125) {
tmp = fabs((t_3 - t_1));
} else if (eh <= 3.65e-87) {
tmp = fabs((t_2 * cos(atan((eh * (-tan(t) / ew))))));
} else {
tmp = fabs((t_1 + t_3));
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = eh * sin(t)
t_2 = ew * cos(t)
t_3 = t_2 * cos(atan((-(t * eh) / ew)))
if (eh <= (-1.65d-125)) then
tmp = abs((t_3 - t_1))
else if (eh <= 3.65d-87) then
tmp = abs((t_2 * cos(atan((eh * (-tan(t) / ew))))))
else
tmp = abs((t_1 + t_3))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = eh * Math.sin(t);
double t_2 = ew * Math.cos(t);
double t_3 = t_2 * Math.cos(Math.atan((-(t * eh) / ew)));
double tmp;
if (eh <= -1.65e-125) {
tmp = Math.abs((t_3 - t_1));
} else if (eh <= 3.65e-87) {
tmp = Math.abs((t_2 * Math.cos(Math.atan((eh * (-Math.tan(t) / ew))))));
} else {
tmp = Math.abs((t_1 + t_3));
}
return tmp;
}
def code(eh, ew, t): t_1 = eh * math.sin(t) t_2 = ew * math.cos(t) t_3 = t_2 * math.cos(math.atan((-(t * eh) / ew))) tmp = 0 if eh <= -1.65e-125: tmp = math.fabs((t_3 - t_1)) elif eh <= 3.65e-87: tmp = math.fabs((t_2 * math.cos(math.atan((eh * (-math.tan(t) / ew)))))) else: tmp = math.fabs((t_1 + t_3)) return tmp
function code(eh, ew, t) t_1 = Float64(eh * sin(t)) t_2 = Float64(ew * cos(t)) t_3 = Float64(t_2 * cos(atan(Float64(Float64(-Float64(t * eh)) / ew)))) tmp = 0.0 if (eh <= -1.65e-125) tmp = abs(Float64(t_3 - t_1)); elseif (eh <= 3.65e-87) tmp = abs(Float64(t_2 * cos(atan(Float64(eh * Float64(Float64(-tan(t)) / ew)))))); else tmp = abs(Float64(t_1 + t_3)); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh * sin(t); t_2 = ew * cos(t); t_3 = t_2 * cos(atan((-(t * eh) / ew))); tmp = 0.0; if (eh <= -1.65e-125) tmp = abs((t_3 - t_1)); elseif (eh <= 3.65e-87) tmp = abs((t_2 * cos(atan((eh * (-tan(t) / ew)))))); else tmp = abs((t_1 + t_3)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[Cos[N[ArcTan[N[((-N[(t * eh), $MachinePrecision]) / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eh, -1.65e-125], N[Abs[N[(t$95$3 - t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 3.65e-87], N[Abs[N[(t$95$2 * N[Cos[N[ArcTan[N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \sin t\\
t_2 := ew \cdot \cos t\\
t_3 := t\_2 \cdot \cos \tan^{-1} \left(\frac{-t \cdot eh}{ew}\right)\\
\mathbf{if}\;eh \leq -1.65 \cdot 10^{-125}:\\
\;\;\;\;\left|t\_3 - t\_1\right|\\
\mathbf{elif}\;eh \leq 3.65 \cdot 10^{-87}:\\
\;\;\;\;\left|t\_2 \cdot \cos \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1 + t\_3\right|\\
\end{array}
\end{array}
if eh < -1.65e-125Initial program 99.7%
sub-neg99.7%
associate-*l*99.7%
distribute-rgt-neg-in99.7%
cancel-sign-sub99.7%
associate-/l*99.7%
Simplified99.7%
associate-*r*99.7%
sin-atan67.1%
associate-*r/61.4%
associate-*r/61.4%
*-commutative61.4%
associate-/l*61.3%
add-sqr-sqrt61.2%
sqrt-unprod47.7%
sqr-neg47.7%
sqrt-unprod0.0%
add-sqr-sqrt59.6%
hypot-1-def68.0%
associate-*r/68.0%
Applied egg-rr68.0%
associate-*l*67.9%
*-commutative67.9%
associate-/r/68.0%
*-commutative68.0%
associate-/r/70.3%
Simplified70.3%
Taylor expanded in eh around inf 98.0%
Taylor expanded in t around 0 90.7%
associate-*r/90.7%
associate-*r*90.7%
mul-1-neg90.7%
Simplified90.7%
if -1.65e-125 < eh < 3.64999999999999984e-87Initial 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%
Applied egg-rr96.8%
+-inverses96.8%
associate-/l*96.8%
metadata-eval96.8%
mul0-rgt96.8%
Simplified96.8%
if 3.64999999999999984e-87 < eh 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%
associate-*r*99.8%
sin-atan72.2%
associate-*r/68.2%
associate-*r/68.1%
*-commutative68.1%
associate-/l*68.1%
add-sqr-sqrt0.0%
sqrt-unprod49.9%
sqr-neg49.9%
sqrt-unprod67.3%
add-sqr-sqrt67.4%
hypot-1-def71.8%
associate-*r/71.8%
Applied egg-rr71.9%
associate-*l*71.9%
*-commutative71.9%
associate-/r/71.8%
*-commutative71.8%
associate-/r/73.1%
Simplified73.1%
*-commutative73.1%
*-un-lft-identity73.1%
times-frac91.7%
*-commutative91.7%
div-inv91.5%
clear-num91.6%
associate-*l*89.3%
div-inv89.2%
clear-num89.3%
Applied egg-rr89.3%
/-rgt-identity89.3%
*-commutative89.3%
Simplified89.3%
Taylor expanded in eh around -inf 98.3%
mul-1-neg98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
Simplified98.3%
Taylor expanded in t around 0 92.0%
associate-*r/92.0%
associate-*r*92.0%
mul-1-neg92.0%
Simplified92.0%
Final simplification93.3%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (sin t)) (* (* 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)) + ((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)) + ((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)) + ((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 * sin(t)) + 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)) + ((ew * cos(t)) * (-1.0 / hypot(1.0, (eh / (ew / tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Sin[t], $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 \sin t + \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%
associate-*r*99.8%
sin-atan80.4%
associate-*r/77.3%
associate-*r/77.2%
*-commutative77.2%
associate-/l*77.2%
add-sqr-sqrt37.2%
sqrt-unprod66.2%
sqr-neg66.2%
sqrt-unprod39.5%
add-sqr-sqrt75.9%
hypot-1-def80.0%
associate-*r/80.0%
Applied egg-rr80.0%
associate-*l*80.0%
*-commutative80.0%
associate-/r/80.0%
*-commutative80.0%
associate-/r/81.2%
Simplified81.2%
Taylor expanded in eh around inf 98.0%
cos-atan99.8%
hypot-1-def99.8%
associate-*r/99.8%
*-commutative99.8%
associate-/l*99.8%
add-sqr-sqrt49.9%
sqrt-unprod92.9%
sqr-neg92.9%
sqrt-unprod49.9%
add-sqr-sqrt99.8%
Applied egg-rr98.0%
*-commutative99.8%
associate-/r/99.8%
Simplified98.0%
Final simplification98.0%
(FPCore (eh ew t) :precision binary64 (fabs (* (* ew (cos t)) (cos (atan (* eh (/ (- (tan t)) ew)))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) * cos(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))))))
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))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.cos(t)) * math.cos(math.atan((eh * (-math.tan(t) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * cos(t)) * cos(atan(Float64(eh * Float64(Float64(-tan(t)) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) * cos(atan((eh * (-tan(t) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[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]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(eh \cdot \frac{-\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%
Applied egg-rr62.9%
+-inverses62.9%
associate-/l*62.9%
metadata-eval62.9%
mul0-rgt62.9%
Simplified62.9%
Final simplification62.9%
(FPCore (eh ew t) :precision binary64 (fabs (* (* ew (cos t)) (/ 1.0 (hypot 1.0 (* (tan t) (/ eh ew)))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) * (1.0 / hypot(1.0, (tan(t) * (eh / 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))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.cos(t)) * (1.0 / math.hypot(1.0, (math.tan(t) * (eh / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * cos(t)) * Float64(1.0 / hypot(1.0, Float64(tan(t) * Float64(eh / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) * (1.0 / hypot(1.0, (tan(t) * (eh / ew)))))); end
code[eh_, ew_, t_] := N[Abs[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]], $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)}\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%
Applied egg-rr62.9%
+-inverses62.9%
associate-/l*62.9%
metadata-eval62.9%
mul0-rgt62.9%
Simplified62.9%
cos-atan99.8%
hypot-1-def99.8%
associate-*r/99.8%
*-commutative99.8%
associate-/l*99.8%
add-sqr-sqrt49.9%
sqrt-unprod92.9%
sqr-neg92.9%
sqrt-unprod49.9%
add-sqr-sqrt99.8%
Applied egg-rr62.6%
Final simplification62.6%
(FPCore (eh ew t) :precision binary64 (fabs (* (* ew (cos t)) (cos (atan (/ (- (* t eh)) ew))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) * cos(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((-(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((-(t * eh) / ew)))));
}
def code(eh, ew, t): return math.fabs(((ew * math.cos(t)) * math.cos(math.atan((-(t * eh) / ew)))))
function code(eh, ew, t) return abs(Float64(Float64(ew * cos(t)) * cos(atan(Float64(Float64(-Float64(t * eh)) / ew))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) * cos(atan((-(t * eh) / ew))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[((-N[(t * eh), $MachinePrecision]) / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{-t \cdot eh}{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%
Applied egg-rr62.9%
+-inverses62.9%
associate-/l*62.9%
metadata-eval62.9%
mul0-rgt62.9%
Simplified62.9%
Taylor expanded in t around 0 51.7%
associate-*r/87.0%
associate-*r*87.0%
mul-1-neg87.0%
Simplified51.7%
Final simplification51.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%
sub-neg99.8%
associate-*l*99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
associate-/l*99.8%
Simplified99.8%
Applied egg-rr62.9%
+-inverses62.9%
associate-/l*62.9%
metadata-eval62.9%
mul0-rgt62.9%
Simplified62.9%
Taylor expanded in t around 0 42.5%
add-cube-cbrt41.8%
pow341.8%
Applied egg-rr41.5%
Taylor expanded in ew around inf 42.7%
Final simplification42.7%
herbie shell --seed 2024085
(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)))))))