
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (fabs (- (* (cos t) (* ew (/ 1.0 (hypot 1.0 (/ (tan t) (/ ew eh)))))) (* (* eh (sin t)) (sin (atan (/ (- eh) (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((cos(t) * (ew * (1.0 / hypot(1.0, (tan(t) / (ew / eh)))))) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t))))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.cos(t) * (ew * (1.0 / Math.hypot(1.0, (Math.tan(t) / (ew / eh)))))) - ((eh * Math.sin(t)) * Math.sin(Math.atan((-eh / (ew / Math.tan(t))))))));
}
def code(eh, ew, t): return math.fabs(((math.cos(t) * (ew * (1.0 / math.hypot(1.0, (math.tan(t) / (ew / eh)))))) - ((eh * math.sin(t)) * math.sin(math.atan((-eh / (ew / math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(Float64(cos(t) * Float64(ew * Float64(1.0 / hypot(1.0, Float64(tan(t) / Float64(ew / eh)))))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((cos(t) * (ew * (1.0 / hypot(1.0, (tan(t) / (ew / eh)))))) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * N[(ew * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] / N[(ew / eh), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\cos t \cdot \left(ew \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{\tan t}{\frac{ew}{eh}}\right)}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
div-inv99.8%
clear-num99.8%
add-sqr-sqrt52.6%
sqrt-unprod94.0%
sqr-neg94.0%
sqrt-unprod47.2%
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 (- (/ (* (cos t) ew) (hypot 1.0 (/ (tan t) (/ ew eh)))) (* (* eh (sin t)) (sin (atan (/ (- eh) (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs((((cos(t) * ew) / hypot(1.0, (tan(t) / (ew / eh)))) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t))))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((Math.cos(t) * ew) / Math.hypot(1.0, (Math.tan(t) / (ew / eh)))) - ((eh * Math.sin(t)) * Math.sin(Math.atan((-eh / (ew / Math.tan(t))))))));
}
def code(eh, ew, t): return math.fabs((((math.cos(t) * ew) / math.hypot(1.0, (math.tan(t) / (ew / eh)))) - ((eh * math.sin(t)) * math.sin(math.atan((-eh / (ew / math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(cos(t) * ew) / hypot(1.0, Float64(tan(t) / Float64(ew / eh)))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs((((cos(t) * ew) / hypot(1.0, (tan(t) / (ew / eh)))) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] / N[(ew / eh), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\cos t \cdot ew}{\mathsf{hypot}\left(1, \frac{\tan t}{\frac{ew}{eh}}\right)} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
Simplified99.8%
expm1-log1p-u74.3%
expm1-udef58.1%
Applied egg-rr59.7%
expm1-def75.8%
expm1-log1p99.8%
*-commutative99.8%
associate-/r/99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (cos t) ew) (* (* eh (sin t)) (sin (atan (/ (- eh) (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((cos(t) * ew) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(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(((cos(t) * ew) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t))))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.cos(t) * ew) - ((eh * Math.sin(t)) * Math.sin(Math.atan((-eh / (ew / Math.tan(t))))))));
}
def code(eh, ew, t): return math.fabs(((math.cos(t) * ew) - ((eh * math.sin(t)) * math.sin(math.atan((-eh / (ew / math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(Float64(cos(t) * ew) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((cos(t) * ew) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\cos t \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right|
\end{array}
Initial program 99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
Simplified99.8%
cos-atan99.8%
hypot-1-def99.8%
div-inv99.8%
clear-num99.8%
add-sqr-sqrt52.6%
sqrt-unprod94.0%
sqr-neg94.0%
sqrt-unprod47.2%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
*-commutative99.8%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in t around 0 98.5%
Final simplification98.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* eh (sin t)))) (t_2 (fabs (* (cos t) ew))))
(if (<= t -1.8e+179)
t_1
(if (<= t -1.66e-7)
t_2
(if (<= t 18500000.0)
(fabs (fma t eh (* ew (cos (atan (* (tan t) (/ (- eh) ew)))))))
(if (<= t 9.8e+69) t_2 t_1))))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * sin(t)));
double t_2 = fabs((cos(t) * ew));
double tmp;
if (t <= -1.8e+179) {
tmp = t_1;
} else if (t <= -1.66e-7) {
tmp = t_2;
} else if (t <= 18500000.0) {
tmp = fabs(fma(t, eh, (ew * cos(atan((tan(t) * (-eh / ew)))))));
} else if (t <= 9.8e+69) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(eh * sin(t))) t_2 = abs(Float64(cos(t) * ew)) tmp = 0.0 if (t <= -1.8e+179) tmp = t_1; elseif (t <= -1.66e-7) tmp = t_2; elseif (t <= 18500000.0) tmp = abs(fma(t, eh, Float64(ew * cos(atan(Float64(tan(t) * Float64(Float64(-eh) / ew))))))); elseif (t <= 9.8e+69) tmp = t_2; else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1.8e+179], t$95$1, If[LessEqual[t, -1.66e-7], t$95$2, If[LessEqual[t, 18500000.0], N[Abs[N[(t * eh + N[(ew * N[Cos[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[((-eh) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 9.8e+69], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \sin t\right|\\
t_2 := \left|\cos t \cdot ew\right|\\
\mathbf{if}\;t \leq -1.8 \cdot 10^{+179}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -1.66 \cdot 10^{-7}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t \leq 18500000:\\
\;\;\;\;\left|\mathsf{fma}\left(t, eh, ew \cdot \cos \tan^{-1} \left(\tan t \cdot \frac{-eh}{ew}\right)\right)\right|\\
\mathbf{elif}\;t \leq 9.8 \cdot 10^{+69}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if t < -1.7999999999999999e179 or 9.7999999999999999e69 < t Initial program 99.6%
fabs-sub99.6%
sub-neg99.6%
+-commutative99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
sin-atan65.7%
associate-*l/65.6%
add-sqr-sqrt35.1%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod30.3%
add-sqr-sqrt64.2%
*-commutative64.2%
associate-/r/64.1%
div-inv64.1%
clear-num64.1%
hypot-1-def84.8%
*-commutative84.8%
Applied egg-rr85.0%
Taylor expanded in eh around -inf 97.5%
mul-1-neg97.5%
Simplified97.5%
Applied egg-rr46.1%
Taylor expanded in ew around 0 64.0%
if -1.7999999999999999e179 < t < -1.66000000000000004e-7 or 1.85e7 < t < 9.7999999999999999e69Initial program 99.6%
fabs-sub99.6%
sub-neg99.6%
+-commutative99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
sin-atan83.7%
associate-*l/83.7%
add-sqr-sqrt55.0%
sqrt-unprod83.7%
sqr-neg83.7%
sqrt-unprod28.6%
add-sqr-sqrt81.8%
*-commutative81.8%
associate-/r/81.7%
div-inv81.7%
clear-num81.8%
hypot-1-def89.5%
*-commutative89.5%
Applied egg-rr89.5%
Taylor expanded in eh around -inf 96.3%
mul-1-neg96.3%
Simplified96.3%
Applied egg-rr52.0%
Taylor expanded in eh around 0 70.8%
if -1.66000000000000004e-7 < t < 1.85e7Initial program 100.0%
fabs-sub100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
Simplified100.0%
*-commutative100.0%
sin-atan75.2%
associate-*l/75.2%
add-sqr-sqrt33.9%
sqrt-unprod73.6%
sqr-neg73.6%
sqrt-unprod41.0%
add-sqr-sqrt74.9%
*-commutative74.9%
associate-/r/75.4%
div-inv75.4%
clear-num75.4%
hypot-1-def80.1%
*-commutative80.1%
Applied egg-rr93.3%
Taylor expanded in eh around -inf 99.5%
mul-1-neg99.5%
Simplified99.5%
Taylor expanded in t around 0 96.7%
distribute-lft-out96.7%
mul-1-neg96.7%
*-commutative96.7%
fma-def96.7%
mul-1-neg96.7%
associate-*l/96.7%
*-commutative96.7%
distribute-rgt-neg-in96.7%
distribute-frac-neg96.7%
Simplified96.7%
Final simplification81.1%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* eh (sin t)) (* ew (/ (cos t) (hypot 1.0 (* (tan t) (/ eh ew))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * sin(t)) + (ew * (cos(t) / hypot(1.0, (tan(t) * (eh / ew)))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * Math.sin(t)) + (ew * (Math.cos(t) / Math.hypot(1.0, (Math.tan(t) * (eh / ew)))))));
}
def code(eh, ew, t): return math.fabs(((eh * math.sin(t)) + (ew * (math.cos(t) / math.hypot(1.0, (math.tan(t) * (eh / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * sin(t)) + Float64(ew * Float64(cos(t) / hypot(1.0, Float64(tan(t) * Float64(eh / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * sin(t)) + (ew * (cos(t) / hypot(1.0, (tan(t) * (eh / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(ew * N[(N[Cos[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \sin t + ew \cdot \frac{\cos t}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\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-def99.8%
Simplified99.8%
*-commutative99.8%
sin-atan73.7%
associate-*l/73.7%
add-sqr-sqrt38.3%
sqrt-unprod72.9%
sqr-neg72.9%
sqrt-unprod35.2%
add-sqr-sqrt72.8%
*-commutative72.8%
associate-/r/72.9%
div-inv72.9%
clear-num73.0%
hypot-1-def83.4%
*-commutative83.4%
Applied egg-rr89.9%
Taylor expanded in eh around -inf 98.2%
mul-1-neg98.2%
Simplified98.2%
fma-udef98.2%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* eh (sin t)))) (t_2 (fabs (* (cos t) ew))))
(if (<= t -6.5e+178)
t_1
(if (<= t -1.66e-7)
t_2
(if (<= t 18500000.0)
(fabs (+ (* t eh) (* ew (cos (atan (* (tan t) (/ (- eh) ew)))))))
(if (<= t 7.1e+68) t_2 t_1))))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * sin(t)));
double t_2 = fabs((cos(t) * ew));
double tmp;
if (t <= -6.5e+178) {
tmp = t_1;
} else if (t <= -1.66e-7) {
tmp = t_2;
} else if (t <= 18500000.0) {
tmp = fabs(((t * eh) + (ew * cos(atan((tan(t) * (-eh / ew)))))));
} else if (t <= 7.1e+68) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_1 = abs((eh * sin(t)))
t_2 = abs((cos(t) * ew))
if (t <= (-6.5d+178)) then
tmp = t_1
else if (t <= (-1.66d-7)) then
tmp = t_2
else if (t <= 18500000.0d0) then
tmp = abs(((t * eh) + (ew * cos(atan((tan(t) * (-eh / ew)))))))
else if (t <= 7.1d+68) then
tmp = t_2
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((eh * Math.sin(t)));
double t_2 = Math.abs((Math.cos(t) * ew));
double tmp;
if (t <= -6.5e+178) {
tmp = t_1;
} else if (t <= -1.66e-7) {
tmp = t_2;
} else if (t <= 18500000.0) {
tmp = Math.abs(((t * eh) + (ew * Math.cos(Math.atan((Math.tan(t) * (-eh / ew)))))));
} else if (t <= 7.1e+68) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((eh * math.sin(t))) t_2 = math.fabs((math.cos(t) * ew)) tmp = 0 if t <= -6.5e+178: tmp = t_1 elif t <= -1.66e-7: tmp = t_2 elif t <= 18500000.0: tmp = math.fabs(((t * eh) + (ew * math.cos(math.atan((math.tan(t) * (-eh / ew))))))) elif t <= 7.1e+68: tmp = t_2 else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(eh * sin(t))) t_2 = abs(Float64(cos(t) * ew)) tmp = 0.0 if (t <= -6.5e+178) tmp = t_1; elseif (t <= -1.66e-7) tmp = t_2; elseif (t <= 18500000.0) tmp = abs(Float64(Float64(t * eh) + Float64(ew * cos(atan(Float64(tan(t) * Float64(Float64(-eh) / ew))))))); elseif (t <= 7.1e+68) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((eh * sin(t))); t_2 = abs((cos(t) * ew)); tmp = 0.0; if (t <= -6.5e+178) tmp = t_1; elseif (t <= -1.66e-7) tmp = t_2; elseif (t <= 18500000.0) tmp = abs(((t * eh) + (ew * cos(atan((tan(t) * (-eh / ew))))))); elseif (t <= 7.1e+68) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -6.5e+178], t$95$1, If[LessEqual[t, -1.66e-7], t$95$2, If[LessEqual[t, 18500000.0], N[Abs[N[(N[(t * eh), $MachinePrecision] + N[(ew * N[Cos[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[((-eh) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 7.1e+68], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \sin t\right|\\
t_2 := \left|\cos t \cdot ew\right|\\
\mathbf{if}\;t \leq -6.5 \cdot 10^{+178}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -1.66 \cdot 10^{-7}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t \leq 18500000:\\
\;\;\;\;\left|t \cdot eh + ew \cdot \cos \tan^{-1} \left(\tan t \cdot \frac{-eh}{ew}\right)\right|\\
\mathbf{elif}\;t \leq 7.1 \cdot 10^{+68}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if t < -6.5000000000000005e178 or 7.1000000000000001e68 < t Initial program 99.6%
fabs-sub99.6%
sub-neg99.6%
+-commutative99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
sin-atan65.7%
associate-*l/65.6%
add-sqr-sqrt35.1%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod30.3%
add-sqr-sqrt64.2%
*-commutative64.2%
associate-/r/64.1%
div-inv64.1%
clear-num64.1%
hypot-1-def84.8%
*-commutative84.8%
Applied egg-rr85.0%
Taylor expanded in eh around -inf 97.5%
mul-1-neg97.5%
Simplified97.5%
Applied egg-rr46.1%
Taylor expanded in ew around 0 64.0%
if -6.5000000000000005e178 < t < -1.66000000000000004e-7 or 1.85e7 < t < 7.1000000000000001e68Initial program 99.6%
fabs-sub99.6%
sub-neg99.6%
+-commutative99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
sin-atan83.7%
associate-*l/83.7%
add-sqr-sqrt55.0%
sqrt-unprod83.7%
sqr-neg83.7%
sqrt-unprod28.6%
add-sqr-sqrt81.8%
*-commutative81.8%
associate-/r/81.7%
div-inv81.7%
clear-num81.8%
hypot-1-def89.5%
*-commutative89.5%
Applied egg-rr89.5%
Taylor expanded in eh around -inf 96.3%
mul-1-neg96.3%
Simplified96.3%
Applied egg-rr52.0%
Taylor expanded in eh around 0 70.8%
if -1.66000000000000004e-7 < t < 1.85e7Initial program 100.0%
fabs-sub100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
Simplified100.0%
*-commutative100.0%
sin-atan75.2%
associate-*l/75.2%
add-sqr-sqrt33.9%
sqrt-unprod73.6%
sqr-neg73.6%
sqrt-unprod41.0%
add-sqr-sqrt74.9%
*-commutative74.9%
associate-/r/75.4%
div-inv75.4%
clear-num75.4%
hypot-1-def80.1%
*-commutative80.1%
Applied egg-rr93.3%
Taylor expanded in eh around -inf 99.5%
mul-1-neg99.5%
Simplified99.5%
Taylor expanded in t around 0 96.7%
distribute-lft-out96.7%
*-commutative96.7%
mul-1-neg96.7%
associate-*l/96.7%
distribute-rgt-neg-in96.7%
Simplified96.7%
Final simplification81.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* eh (sin t)))) (t_2 (fabs (* (cos t) ew))))
(if (<= t -1.02e+180)
t_1
(if (<= t -1.66e-7)
t_2
(if (<= t 18500000.0)
(fabs (+ ew (* t eh)))
(if (<= t 1.46e+72) t_2 t_1))))))
double code(double eh, double ew, double t) {
double t_1 = fabs((eh * sin(t)));
double t_2 = fabs((cos(t) * ew));
double tmp;
if (t <= -1.02e+180) {
tmp = t_1;
} else if (t <= -1.66e-7) {
tmp = t_2;
} else if (t <= 18500000.0) {
tmp = fabs((ew + (t * eh)));
} else if (t <= 1.46e+72) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_1 = abs((eh * sin(t)))
t_2 = abs((cos(t) * ew))
if (t <= (-1.02d+180)) then
tmp = t_1
else if (t <= (-1.66d-7)) then
tmp = t_2
else if (t <= 18500000.0d0) then
tmp = abs((ew + (t * eh)))
else if (t <= 1.46d+72) then
tmp = t_2
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((eh * Math.sin(t)));
double t_2 = Math.abs((Math.cos(t) * ew));
double tmp;
if (t <= -1.02e+180) {
tmp = t_1;
} else if (t <= -1.66e-7) {
tmp = t_2;
} else if (t <= 18500000.0) {
tmp = Math.abs((ew + (t * eh)));
} else if (t <= 1.46e+72) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((eh * math.sin(t))) t_2 = math.fabs((math.cos(t) * ew)) tmp = 0 if t <= -1.02e+180: tmp = t_1 elif t <= -1.66e-7: tmp = t_2 elif t <= 18500000.0: tmp = math.fabs((ew + (t * eh))) elif t <= 1.46e+72: tmp = t_2 else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(eh * sin(t))) t_2 = abs(Float64(cos(t) * ew)) tmp = 0.0 if (t <= -1.02e+180) tmp = t_1; elseif (t <= -1.66e-7) tmp = t_2; elseif (t <= 18500000.0) tmp = abs(Float64(ew + Float64(t * eh))); elseif (t <= 1.46e+72) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((eh * sin(t))); t_2 = abs((cos(t) * ew)); tmp = 0.0; if (t <= -1.02e+180) tmp = t_1; elseif (t <= -1.66e-7) tmp = t_2; elseif (t <= 18500000.0) tmp = abs((ew + (t * eh))); elseif (t <= 1.46e+72) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1.02e+180], t$95$1, If[LessEqual[t, -1.66e-7], t$95$2, If[LessEqual[t, 18500000.0], N[Abs[N[(ew + N[(t * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 1.46e+72], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|eh \cdot \sin t\right|\\
t_2 := \left|\cos t \cdot ew\right|\\
\mathbf{if}\;t \leq -1.02 \cdot 10^{+180}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -1.66 \cdot 10^{-7}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t \leq 18500000:\\
\;\;\;\;\left|ew + t \cdot eh\right|\\
\mathbf{elif}\;t \leq 1.46 \cdot 10^{+72}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if t < -1.02e180 or 1.45999999999999999e72 < t Initial program 99.6%
fabs-sub99.6%
sub-neg99.6%
+-commutative99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
sin-atan65.7%
associate-*l/65.6%
add-sqr-sqrt35.1%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod30.3%
add-sqr-sqrt64.2%
*-commutative64.2%
associate-/r/64.1%
div-inv64.1%
clear-num64.1%
hypot-1-def84.8%
*-commutative84.8%
Applied egg-rr85.0%
Taylor expanded in eh around -inf 97.5%
mul-1-neg97.5%
Simplified97.5%
Applied egg-rr46.1%
Taylor expanded in ew around 0 64.0%
if -1.02e180 < t < -1.66000000000000004e-7 or 1.85e7 < t < 1.45999999999999999e72Initial program 99.6%
fabs-sub99.6%
sub-neg99.6%
+-commutative99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
sin-atan83.7%
associate-*l/83.7%
add-sqr-sqrt55.0%
sqrt-unprod83.7%
sqr-neg83.7%
sqrt-unprod28.6%
add-sqr-sqrt81.8%
*-commutative81.8%
associate-/r/81.7%
div-inv81.7%
clear-num81.8%
hypot-1-def89.5%
*-commutative89.5%
Applied egg-rr89.5%
Taylor expanded in eh around -inf 96.3%
mul-1-neg96.3%
Simplified96.3%
Applied egg-rr52.0%
Taylor expanded in eh around 0 70.8%
if -1.66000000000000004e-7 < t < 1.85e7Initial program 100.0%
fabs-sub100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
Simplified100.0%
*-commutative100.0%
sin-atan75.2%
associate-*l/75.2%
add-sqr-sqrt33.9%
sqrt-unprod73.6%
sqr-neg73.6%
sqrt-unprod41.0%
add-sqr-sqrt74.9%
*-commutative74.9%
associate-/r/75.4%
div-inv75.4%
clear-num75.4%
hypot-1-def80.1%
*-commutative80.1%
Applied egg-rr93.3%
Taylor expanded in eh around -inf 99.5%
mul-1-neg99.5%
Simplified99.5%
Applied egg-rr47.5%
Taylor expanded in t around 0 96.4%
Final simplification81.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -0.45) (not (<= t 8.2e-13))) (fabs (* eh (sin t))) (fabs (+ ew (* t eh)))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.45) || !(t <= 8.2e-13)) {
tmp = fabs((eh * sin(t)));
} else {
tmp = fabs((ew + (t * eh)));
}
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 <= (-0.45d0)) .or. (.not. (t <= 8.2d-13))) then
tmp = abs((eh * sin(t)))
else
tmp = abs((ew + (t * eh)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -0.45) || !(t <= 8.2e-13)) {
tmp = Math.abs((eh * Math.sin(t)));
} else {
tmp = Math.abs((ew + (t * eh)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -0.45) or not (t <= 8.2e-13): tmp = math.fabs((eh * math.sin(t))) else: tmp = math.fabs((ew + (t * eh))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -0.45) || !(t <= 8.2e-13)) tmp = abs(Float64(eh * sin(t))); else tmp = abs(Float64(ew + Float64(t * eh))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -0.45) || ~((t <= 8.2e-13))) tmp = abs((eh * sin(t))); else tmp = abs((ew + (t * eh))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -0.45], N[Not[LessEqual[t, 8.2e-13]], $MachinePrecision]], N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew + N[(t * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.45 \lor \neg \left(t \leq 8.2 \cdot 10^{-13}\right):\\
\;\;\;\;\left|eh \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew + t \cdot eh\right|\\
\end{array}
\end{array}
if t < -0.450000000000000011 or 8.2000000000000004e-13 < t Initial program 99.6%
fabs-sub99.6%
sub-neg99.6%
+-commutative99.6%
associate-*l*99.6%
distribute-rgt-neg-in99.6%
fma-def99.6%
Simplified99.6%
*-commutative99.6%
sin-atan69.6%
associate-*l/69.5%
add-sqr-sqrt39.8%
sqrt-unprod69.5%
sqr-neg69.5%
sqrt-unprod29.6%
add-sqr-sqrt68.0%
*-commutative68.0%
associate-/r/67.9%
div-inv67.9%
clear-num67.9%
hypot-1-def85.5%
*-commutative85.5%
Applied egg-rr85.6%
Taylor expanded in eh around -inf 97.1%
mul-1-neg97.1%
Simplified97.1%
Applied egg-rr49.1%
Taylor expanded in ew around 0 55.0%
if -0.450000000000000011 < t < 8.2000000000000004e-13Initial program 100.0%
fabs-sub100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
Simplified100.0%
*-commutative100.0%
sin-atan78.4%
associate-*l/78.4%
add-sqr-sqrt36.7%
sqrt-unprod76.8%
sqr-neg76.8%
sqrt-unprod41.5%
add-sqr-sqrt78.2%
*-commutative78.2%
associate-/r/78.7%
div-inv78.7%
clear-num78.7%
hypot-1-def81.1%
*-commutative81.1%
Applied egg-rr94.7%
Taylor expanded in eh around -inf 99.5%
mul-1-neg99.5%
Simplified99.5%
Applied egg-rr46.6%
Taylor expanded in t around 0 98.5%
Final simplification75.4%
(FPCore (eh ew t) :precision binary64 (fabs (+ ew (* t eh))))
double code(double eh, double ew, double t) {
return fabs((ew + (t * eh)));
}
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 + (t * eh)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew + (t * eh)));
}
def code(eh, ew, t): return math.fabs((ew + (t * eh)))
function code(eh, ew, t) return abs(Float64(ew + Float64(t * eh))) end
function tmp = code(eh, ew, t) tmp = abs((ew + (t * eh))); end
code[eh_, ew_, t_] := N[Abs[N[(ew + N[(t * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew + t \cdot eh\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-def99.8%
Simplified99.8%
*-commutative99.8%
sin-atan73.7%
associate-*l/73.7%
add-sqr-sqrt38.3%
sqrt-unprod72.9%
sqr-neg72.9%
sqrt-unprod35.2%
add-sqr-sqrt72.8%
*-commutative72.8%
associate-/r/72.9%
div-inv72.9%
clear-num73.0%
hypot-1-def83.4%
*-commutative83.4%
Applied egg-rr89.9%
Taylor expanded in eh around -inf 98.2%
mul-1-neg98.2%
Simplified98.2%
Applied egg-rr47.9%
Taylor expanded in t around 0 52.8%
Final simplification52.8%
(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-def99.8%
Simplified99.8%
Applied egg-rr57.8%
+-inverses57.8%
*-commutative57.8%
associate-/l*57.8%
div057.8%
Simplified57.8%
Taylor expanded in t around 0 38.6%
associate-*r*38.6%
neg-mul-138.6%
mul-1-neg38.6%
associate-*l/38.6%
*-commutative38.6%
distribute-rgt-neg-in38.6%
Simplified38.6%
expm1-log1p-u25.7%
expm1-udef15.0%
Applied egg-rr12.8%
expm1-def23.3%
expm1-log1p38.3%
associate-*l/38.3%
associate-*r/38.3%
Simplified38.3%
Taylor expanded in ew around inf 38.8%
Final simplification38.8%
herbie shell --seed 2023279
(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)))))))