
(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 (let* ((t_1 (atan (/ (* eh (tan t)) (- 0.0 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)) / (0.0 - 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)) / (0.0d0 - 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)) / (0.0 - 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)) / (0.0 - 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(eh * tan(t)) / Float64(0.0 - 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)) / (0.0 - 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] / N[(0.0 - ew), $MachinePrecision]), $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{eh \cdot \tan t}{0 - ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (eh ew t) :precision binary64 (fabs (- (/ (* ew (cos t)) (hypot 1.0 (/ eh (/ ew (tan t))))) (* (* eh (sin t)) (sin (atan (/ (* eh (tan t)) (- 0.0 ew))))))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) / hypot(1.0, (eh / (ew / tan(t))))) - ((eh * sin(t)) * sin(atan(((eh * tan(t)) / (0.0 - ew)))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) / Math.hypot(1.0, (eh / (ew / Math.tan(t))))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * Math.tan(t)) / (0.0 - ew)))))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) / math.hypot(1.0, (eh / (ew / math.tan(t))))) - ((eh * math.sin(t)) * math.sin(math.atan(((eh * math.tan(t)) / (0.0 - ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) / hypot(1.0, Float64(eh / Float64(ew / tan(t))))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * tan(t)) / Float64(0.0 - ew))))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) / hypot(1.0, (eh / (ew / tan(t))))) - ((eh * sin(t)) * sin(atan(((eh * tan(t)) / (0.0 - 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[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / N[(0.0 - ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{0 - ew}\right)\right|
\end{array}
Initial program 99.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (/ ew (/ (hypot 1.0 (/ eh (/ ew (tan t)))) (cos t))) (* (* eh (sin t)) (sin (atan (/ (* eh (tan t)) (- 0.0 ew))))))))
double code(double eh, double ew, double t) {
return fabs(((ew / (hypot(1.0, (eh / (ew / tan(t)))) / cos(t))) - ((eh * sin(t)) * sin(atan(((eh * tan(t)) / (0.0 - ew)))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((ew / (Math.hypot(1.0, (eh / (ew / Math.tan(t)))) / Math.cos(t))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * Math.tan(t)) / (0.0 - ew)))))));
}
def code(eh, ew, t): return math.fabs(((ew / (math.hypot(1.0, (eh / (ew / math.tan(t)))) / math.cos(t))) - ((eh * math.sin(t)) * math.sin(math.atan(((eh * math.tan(t)) / (0.0 - ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(ew / Float64(hypot(1.0, Float64(eh / Float64(ew / tan(t)))) / cos(t))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * tan(t)) / Float64(0.0 - ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew / (hypot(1.0, (eh / (ew / tan(t)))) / cos(t))) - ((eh * sin(t)) * sin(atan(((eh * tan(t)) / (0.0 - ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew / N[(N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / N[(0.0 - ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew}{\frac{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)}{\cos t}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{0 - ew}\right)\right|
\end{array}
Initial program 99.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.8%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
tan-lowering-tan.f64N/A
cos-lowering-cos.f6499.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)) (- 0.0 ew))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) - ((eh * sin(t)) * sin(atan(((eh * tan(t)) / (0.0 - 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)) / (0.0d0 - 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)) / (0.0 - 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)) / (0.0 - 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(0.0 - ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) - ((eh * sin(t)) * sin(atan(((eh * tan(t)) / (0.0 - 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] / N[(0.0 - ew), $MachinePrecision]), $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}{0 - ew}\right)\right|
\end{array}
Initial program 99.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6498.3%
Simplified98.3%
Final simplification98.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (fabs t_1)))
(if (<= ew -1.6e-70)
t_2
(if (<= ew 1.15e-160)
(fabs (* eh (sin t)))
(if (<= ew 35000000.0)
(fabs
(/
(+ t_1 (/ (* eh (* t eh)) (/ ew t)))
(hypot 1.0 (/ eh (/ ew (tan t))))))
t_2)))))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double t_2 = fabs(t_1);
double tmp;
if (ew <= -1.6e-70) {
tmp = t_2;
} else if (ew <= 1.15e-160) {
tmp = fabs((eh * sin(t)));
} else if (ew <= 35000000.0) {
tmp = fabs(((t_1 + ((eh * (t * eh)) / (ew / t))) / hypot(1.0, (eh / (ew / tan(t))))));
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.cos(t);
double t_2 = Math.abs(t_1);
double tmp;
if (ew <= -1.6e-70) {
tmp = t_2;
} else if (ew <= 1.15e-160) {
tmp = Math.abs((eh * Math.sin(t)));
} else if (ew <= 35000000.0) {
tmp = Math.abs(((t_1 + ((eh * (t * eh)) / (ew / t))) / Math.hypot(1.0, (eh / (ew / Math.tan(t))))));
} else {
tmp = t_2;
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.cos(t) t_2 = math.fabs(t_1) tmp = 0 if ew <= -1.6e-70: tmp = t_2 elif ew <= 1.15e-160: tmp = math.fabs((eh * math.sin(t))) elif ew <= 35000000.0: tmp = math.fabs(((t_1 + ((eh * (t * eh)) / (ew / t))) / math.hypot(1.0, (eh / (ew / math.tan(t)))))) else: tmp = t_2 return tmp
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) t_2 = abs(t_1) tmp = 0.0 if (ew <= -1.6e-70) tmp = t_2; elseif (ew <= 1.15e-160) tmp = abs(Float64(eh * sin(t))); elseif (ew <= 35000000.0) tmp = abs(Float64(Float64(t_1 + Float64(Float64(eh * Float64(t * eh)) / Float64(ew / t))) / hypot(1.0, Float64(eh / Float64(ew / tan(t)))))); else tmp = t_2; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * cos(t); t_2 = abs(t_1); tmp = 0.0; if (ew <= -1.6e-70) tmp = t_2; elseif (ew <= 1.15e-160) tmp = abs((eh * sin(t))); elseif (ew <= 35000000.0) tmp = abs(((t_1 + ((eh * (t * eh)) / (ew / t))) / hypot(1.0, (eh / (ew / tan(t)))))); else tmp = t_2; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Abs[t$95$1], $MachinePrecision]}, If[LessEqual[ew, -1.6e-70], t$95$2, If[LessEqual[ew, 1.15e-160], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 35000000.0], N[Abs[N[(N[(t$95$1 + N[(N[(eh * N[(t * eh), $MachinePrecision]), $MachinePrecision] / N[(ew / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := \left|t\_1\right|\\
\mathbf{if}\;ew \leq -1.6 \cdot 10^{-70}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;ew \leq 1.15 \cdot 10^{-160}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{elif}\;ew \leq 35000000:\\
\;\;\;\;\left|\frac{t\_1 + \frac{eh \cdot \left(t \cdot eh\right)}{\frac{ew}{t}}}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if ew < -1.5999999999999999e-70 or 3.5e7 < ew Initial program 99.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.9%
Taylor expanded in ew around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6483.9%
Simplified83.9%
if -1.5999999999999999e-70 < ew < 1.14999999999999992e-160Initial program 99.8%
Applied egg-rr52.3%
Taylor expanded in ew around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6486.6%
Simplified86.6%
if 1.14999999999999992e-160 < ew < 3.5e7Initial program 99.9%
Applied egg-rr74.0%
Taylor expanded in t around 0
associate-/l*N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6466.7%
Simplified66.7%
associate-/l*N/A
associate-*r*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6476.3%
Applied egg-rr76.3%
Final simplification83.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* ew (cos t)))))
(if (<= ew -8.2e-73)
t_1
(if (<= ew 2.55e-163)
(fabs (* eh (sin t)))
(if (<= ew 3.7e-58)
(fabs
(/
(+ ew (/ (* eh (* t eh)) (/ ew t)))
(hypot 1.0 (/ eh (/ ew (tan t))))))
t_1)))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -8.2e-73) {
tmp = t_1;
} else if (ew <= 2.55e-163) {
tmp = fabs((eh * sin(t)));
} else if (ew <= 3.7e-58) {
tmp = fabs(((ew + ((eh * (t * eh)) / (ew / t))) / hypot(1.0, (eh / (ew / tan(t))))));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((ew * Math.cos(t)));
double tmp;
if (ew <= -8.2e-73) {
tmp = t_1;
} else if (ew <= 2.55e-163) {
tmp = Math.abs((eh * Math.sin(t)));
} else if (ew <= 3.7e-58) {
tmp = Math.abs(((ew + ((eh * (t * eh)) / (ew / t))) / Math.hypot(1.0, (eh / (ew / Math.tan(t))))));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.cos(t))) tmp = 0 if ew <= -8.2e-73: tmp = t_1 elif ew <= 2.55e-163: tmp = math.fabs((eh * math.sin(t))) elif ew <= 3.7e-58: tmp = math.fabs(((ew + ((eh * (t * eh)) / (ew / t))) / math.hypot(1.0, (eh / (ew / math.tan(t)))))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -8.2e-73) tmp = t_1; elseif (ew <= 2.55e-163) tmp = abs(Float64(eh * sin(t))); elseif (ew <= 3.7e-58) tmp = abs(Float64(Float64(ew + Float64(Float64(eh * Float64(t * eh)) / Float64(ew / t))) / hypot(1.0, Float64(eh / Float64(ew / tan(t)))))); 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 <= -8.2e-73) tmp = t_1; elseif (ew <= 2.55e-163) tmp = abs((eh * sin(t))); elseif (ew <= 3.7e-58) tmp = abs(((ew + ((eh * (t * eh)) / (ew / t))) / hypot(1.0, (eh / (ew / tan(t)))))); 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, -8.2e-73], t$95$1, If[LessEqual[ew, 2.55e-163], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 3.7e-58], N[Abs[N[(N[(ew + N[(N[(eh * N[(t * eh), $MachinePrecision]), $MachinePrecision] / N[(ew / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -8.2 \cdot 10^{-73}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 2.55 \cdot 10^{-163}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{elif}\;ew \leq 3.7 \cdot 10^{-58}:\\
\;\;\;\;\left|\frac{ew + \frac{eh \cdot \left(t \cdot eh\right)}{\frac{ew}{t}}}{\mathsf{hypot}\left(1, \frac{eh}{\frac{ew}{\tan t}}\right)}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -8.20000000000000032e-73 or 3.7000000000000003e-58 < ew Initial program 99.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.9%
Taylor expanded in ew around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6482.0%
Simplified82.0%
if -8.20000000000000032e-73 < ew < 2.54999999999999995e-163Initial program 99.8%
Applied egg-rr52.3%
Taylor expanded in ew around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6486.6%
Simplified86.6%
if 2.54999999999999995e-163 < ew < 3.7000000000000003e-58Initial program 99.9%
Applied egg-rr70.5%
Taylor expanded in t around 0
associate-/l*N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6470.1%
Simplified70.1%
associate-/l*N/A
associate-*r*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6478.8%
Applied egg-rr78.8%
Taylor expanded in t around 0
Simplified78.8%
Final simplification83.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* ew (cos t)))))
(if (<= ew -2.25e-72)
t_1
(if (<= ew 1.22e-160) (fabs (* eh (sin t))) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((ew * cos(t)));
double tmp;
if (ew <= -2.25e-72) {
tmp = t_1;
} else if (ew <= 1.22e-160) {
tmp = fabs((eh * sin(t)));
} 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 <= (-2.25d-72)) then
tmp = t_1
else if (ew <= 1.22d-160) then
tmp = abs((eh * sin(t)))
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 <= -2.25e-72) {
tmp = t_1;
} else if (ew <= 1.22e-160) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((ew * math.cos(t))) tmp = 0 if ew <= -2.25e-72: tmp = t_1 elif ew <= 1.22e-160: tmp = math.fabs((eh * math.sin(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(ew * cos(t))) tmp = 0.0 if (ew <= -2.25e-72) tmp = t_1; elseif (ew <= 1.22e-160) tmp = abs(Float64(eh * sin(t))); 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 <= -2.25e-72) tmp = t_1; elseif (ew <= 1.22e-160) tmp = abs((eh * sin(t))); 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, -2.25e-72], t$95$1, If[LessEqual[ew, 1.22e-160], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|ew \cdot \cos t\right|\\
\mathbf{if}\;ew \leq -2.25 \cdot 10^{-72}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 1.22 \cdot 10^{-160}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -2.25e-72 or 1.22000000000000003e-160 < ew Initial program 99.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.9%
Taylor expanded in ew around inf
*-lowering-*.f64N/A
cos-lowering-cos.f6479.0%
Simplified79.0%
if -2.25e-72 < ew < 1.22000000000000003e-160Initial program 99.8%
Applied egg-rr52.3%
Taylor expanded in ew around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6486.6%
Simplified86.6%
(FPCore (eh ew t) :precision binary64 (if (<= ew -6.5e-33) (fabs ew) (if (<= ew 1.32e-160) (fabs (* eh (sin t))) (fabs ew))))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= -6.5e-33) {
tmp = fabs(ew);
} else if (ew <= 1.32e-160) {
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 (ew <= (-6.5d-33)) then
tmp = abs(ew)
else if (ew <= 1.32d-160) 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 (ew <= -6.5e-33) {
tmp = Math.abs(ew);
} else if (ew <= 1.32e-160) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = Math.abs(ew);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if ew <= -6.5e-33: tmp = math.fabs(ew) elif ew <= 1.32e-160: tmp = math.fabs((eh * math.sin(t))) else: tmp = math.fabs(ew) return tmp
function code(eh, ew, t) tmp = 0.0 if (ew <= -6.5e-33) tmp = abs(ew); elseif (ew <= 1.32e-160) 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 (ew <= -6.5e-33) tmp = abs(ew); elseif (ew <= 1.32e-160) tmp = abs((eh * sin(t))); else tmp = abs(ew); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[ew, -6.5e-33], N[Abs[ew], $MachinePrecision], If[LessEqual[ew, 1.32e-160], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[ew], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -6.5 \cdot 10^{-33}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{elif}\;ew \leq 1.32 \cdot 10^{-160}:\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew\right|\\
\end{array}
\end{array}
if ew < -6.4999999999999993e-33 or 1.3199999999999999e-160 < ew Initial program 99.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.9%
Taylor expanded in t around 0
Simplified57.9%
if -6.4999999999999993e-33 < ew < 1.3199999999999999e-160Initial program 99.8%
Applied egg-rr54.5%
Taylor expanded in ew around 0
*-lowering-*.f64N/A
sin-lowering-sin.f6482.4%
Simplified82.4%
(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.9%
cos-atanN/A
un-div-invN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f64N/A
frac-2negN/A
distribute-frac-neg2N/A
frac-2negN/A
distribute-frac-neg2N/A
sqr-negN/A
hypot-1-defN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.8%
Taylor expanded in t around 0
Simplified43.2%
herbie shell --seed 2024164
(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)))))))