
(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) (/ ew (tan t)))))) (fabs (- (* (* eh (sin t)) (sin t_1)) (* (cos t) (* ew (cos t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = atan((-eh / (ew / tan(t))));
return fabs((((eh * sin(t)) * sin(t_1)) - (cos(t) * (ew * cos(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 / (ew / tan(t))))
code = abs((((eh * sin(t)) * sin(t_1)) - (cos(t) * (ew * cos(t_1)))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((-eh / (ew / Math.tan(t))));
return Math.abs((((eh * Math.sin(t)) * Math.sin(t_1)) - (Math.cos(t) * (ew * Math.cos(t_1)))));
}
def code(eh, ew, t): t_1 = math.atan((-eh / (ew / math.tan(t)))) return math.fabs((((eh * math.sin(t)) * math.sin(t_1)) - (math.cos(t) * (ew * math.cos(t_1)))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(-eh) / Float64(ew / tan(t)))) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(t_1)) - Float64(cos(t) * Float64(ew * cos(t_1))))) end
function tmp = code(eh, ew, t) t_1 = atan((-eh / (ew / tan(t)))); tmp = abs((((eh * sin(t)) * sin(t_1)) - (cos(t) * (ew * cos(t_1))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[t], $MachinePrecision] * N[(ew * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\\
\left|\left(eh \cdot \sin t\right) \cdot \sin t_1 - \cos t \cdot \left(ew \cdot \cos t_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (/ ew (/ (hypot 1.0 (* (tan t) (/ eh ew))) (cos t))) (* (* eh (sin t)) (sin (atan (/ (- eh) (/ ew (tan t)))))))))
double code(double eh, double ew, double t) {
return fabs(((ew / (hypot(1.0, (tan(t) * (eh / ew))) / cos(t))) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t))))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((ew / (Math.hypot(1.0, (Math.tan(t) * (eh / ew))) / Math.cos(t))) - ((eh * Math.sin(t)) * Math.sin(Math.atan((-eh / (ew / Math.tan(t))))))));
}
def code(eh, ew, t): return math.fabs(((ew / (math.hypot(1.0, (math.tan(t) * (eh / ew))) / math.cos(t))) - ((eh * math.sin(t)) * math.sin(math.atan((-eh / (ew / math.tan(t))))))))
function code(eh, ew, t) return abs(Float64(Float64(ew / Float64(hypot(1.0, Float64(tan(t) * Float64(eh / ew))) / cos(t))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew / (hypot(1.0, (tan(t) * (eh / ew))) / cos(t))) - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t)))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew / N[(N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Cos[t], $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|\frac{ew}{\frac{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}{\cos t}} - \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%
associate-/l*99.8%
*-commutative99.8%
associate-*l/99.8%
associate-*r/99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* eh (* (sin t) (sin (atan (* (tan t) (/ (- eh) ew)))))) (* ew (/ (cos t) (hypot 1.0 (* eh (/ (tan t) ew))))))))
double code(double eh, double ew, double t) {
return fabs(((eh * (sin(t) * sin(atan((tan(t) * (-eh / ew)))))) - (ew * (cos(t) / hypot(1.0, (eh * (tan(t) / ew)))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((eh * (Math.sin(t) * Math.sin(Math.atan((Math.tan(t) * (-eh / ew)))))) - (ew * (Math.cos(t) / Math.hypot(1.0, (eh * (Math.tan(t) / ew)))))));
}
def code(eh, ew, t): return math.fabs(((eh * (math.sin(t) * math.sin(math.atan((math.tan(t) * (-eh / ew)))))) - (ew * (math.cos(t) / math.hypot(1.0, (eh * (math.tan(t) / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(eh * Float64(sin(t) * sin(atan(Float64(tan(t) * Float64(Float64(-eh) / ew)))))) - Float64(ew * Float64(cos(t) / hypot(1.0, Float64(eh * Float64(tan(t) / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((eh * (sin(t) * sin(atan((tan(t) * (-eh / ew)))))) - (ew * (cos(t) / hypot(1.0, (eh * (tan(t) / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[((-eh) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(ew * N[(N[Cos[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\tan t \cdot \frac{-eh}{ew}\right)\right) - ew \cdot \frac{\cos t}{\mathsf{hypot}\left(1, eh \cdot \frac{\tan t}{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%
associate-*r/99.8%
*-commutative99.8%
add-sqr-sqrt51.1%
sqrt-unprod99.8%
sqr-neg99.8%
sqrt-unprod48.7%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
Simplified99.8%
fma-udef99.8%
associate-*l/99.8%
*-un-lft-identity99.8%
associate-*l/99.8%
associate-*r/99.8%
*-commutative99.8%
Applied egg-rr99.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%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
Taylor expanded in eh around 0 98.5%
pow-base-198.5%
*-rgt-identity98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* (cos t) ew)))
(t_2 (fabs (* (sin t) (* eh (sin (atan (* (tan t) (/ (- eh) ew)))))))))
(if (<= t -5.6e+178)
t_2
(if (<= t -1.66e-7)
t_1
(if (<= t 18500000.0)
(fabs (- (* (* t eh) (sin (atan (* eh (/ (- (tan t)) ew))))) ew))
(if (<= t 3.6e+68) t_1 t_2))))))
double code(double eh, double ew, double t) {
double t_1 = fabs((cos(t) * ew));
double t_2 = fabs((sin(t) * (eh * sin(atan((tan(t) * (-eh / ew)))))));
double tmp;
if (t <= -5.6e+178) {
tmp = t_2;
} else if (t <= -1.66e-7) {
tmp = t_1;
} else if (t <= 18500000.0) {
tmp = fabs((((t * eh) * sin(atan((eh * (-tan(t) / ew))))) - ew));
} else if (t <= 3.6e+68) {
tmp = t_1;
} else {
tmp = t_2;
}
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((cos(t) * ew))
t_2 = abs((sin(t) * (eh * sin(atan((tan(t) * (-eh / ew)))))))
if (t <= (-5.6d+178)) then
tmp = t_2
else if (t <= (-1.66d-7)) then
tmp = t_1
else if (t <= 18500000.0d0) then
tmp = abs((((t * eh) * sin(atan((eh * (-tan(t) / ew))))) - ew))
else if (t <= 3.6d+68) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.abs((Math.cos(t) * ew));
double t_2 = Math.abs((Math.sin(t) * (eh * Math.sin(Math.atan((Math.tan(t) * (-eh / ew)))))));
double tmp;
if (t <= -5.6e+178) {
tmp = t_2;
} else if (t <= -1.66e-7) {
tmp = t_1;
} else if (t <= 18500000.0) {
tmp = Math.abs((((t * eh) * Math.sin(Math.atan((eh * (-Math.tan(t) / ew))))) - ew));
} else if (t <= 3.6e+68) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((math.cos(t) * ew)) t_2 = math.fabs((math.sin(t) * (eh * math.sin(math.atan((math.tan(t) * (-eh / ew))))))) tmp = 0 if t <= -5.6e+178: tmp = t_2 elif t <= -1.66e-7: tmp = t_1 elif t <= 18500000.0: tmp = math.fabs((((t * eh) * math.sin(math.atan((eh * (-math.tan(t) / ew))))) - ew)) elif t <= 3.6e+68: tmp = t_1 else: tmp = t_2 return tmp
function code(eh, ew, t) t_1 = abs(Float64(cos(t) * ew)) t_2 = abs(Float64(sin(t) * Float64(eh * sin(atan(Float64(tan(t) * Float64(Float64(-eh) / ew))))))) tmp = 0.0 if (t <= -5.6e+178) tmp = t_2; elseif (t <= -1.66e-7) tmp = t_1; elseif (t <= 18500000.0) tmp = abs(Float64(Float64(Float64(t * eh) * sin(atan(Float64(eh * Float64(Float64(-tan(t)) / ew))))) - ew)); elseif (t <= 3.6e+68) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((cos(t) * ew)); t_2 = abs((sin(t) * (eh * sin(atan((tan(t) * (-eh / ew))))))); tmp = 0.0; if (t <= -5.6e+178) tmp = t_2; elseif (t <= -1.66e-7) tmp = t_1; elseif (t <= 18500000.0) tmp = abs((((t * eh) * sin(atan((eh * (-tan(t) / ew))))) - ew)); elseif (t <= 3.6e+68) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Sin[t], $MachinePrecision] * N[(eh * N[Sin[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[((-eh) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -5.6e+178], t$95$2, If[LessEqual[t, -1.66e-7], t$95$1, If[LessEqual[t, 18500000.0], N[Abs[N[(N[(N[(t * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - ew), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 3.6e+68], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\cos t \cdot ew\right|\\
t_2 := \left|\sin t \cdot \left(eh \cdot \sin \tan^{-1} \left(\tan t \cdot \frac{-eh}{ew}\right)\right)\right|\\
\mathbf{if}\;t \leq -5.6 \cdot 10^{+178}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t \leq -1.66 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq 18500000:\\
\;\;\;\;\left|\left(t \cdot eh\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right) - ew\right|\\
\mathbf{elif}\;t \leq 3.6 \cdot 10^{+68}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if t < -5.59999999999999986e178 or 3.5999999999999999e68 < 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%
associate-*r/99.6%
*-commutative99.6%
add-sqr-sqrt48.0%
sqrt-unprod99.6%
sqr-neg99.6%
sqrt-unprod51.6%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
associate-*r/99.6%
cos-atan99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
associate-*r/99.6%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in ew around 0 63.6%
*-commutative63.6%
mul-1-neg63.6%
*-commutative63.6%
associate-*l/63.6%
distribute-rgt-neg-out63.6%
Simplified63.6%
if -5.59999999999999986e178 < t < -1.66000000000000004e-7 or 1.85e7 < t < 3.5999999999999999e68Initial 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%
associate-*r/99.6%
*-commutative99.6%
add-sqr-sqrt59.0%
sqrt-unprod99.6%
sqr-neg99.6%
sqrt-unprod40.7%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
associate-*r/99.6%
cos-atan99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
associate-*r/99.6%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in ew around inf 70.8%
associate-*r*70.8%
neg-mul-170.8%
Simplified70.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%
associate-*r/100.0%
*-commutative100.0%
add-sqr-sqrt50.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod50.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
associate-*r/100.0%
cos-atan100.0%
hypot-1-def100.0%
Applied egg-rr100.0%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in t around 0 96.7%
+-commutative96.7%
mul-1-neg96.7%
unsub-neg96.7%
*-commutative96.7%
mul-1-neg96.7%
*-commutative96.7%
associate-*r/96.7%
distribute-rgt-neg-in96.7%
Simplified96.7%
Final simplification81.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -3e-20) (not (<= eh 1.95e-32))) (fabs (- ew (* (* eh (sin t)) (sin (atan (/ (- eh) (/ ew (tan t)))))))) (fabs (* (cos t) ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3e-20) || !(eh <= 1.95e-32)) {
tmp = fabs((ew - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t))))))));
} else {
tmp = fabs((cos(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) :: tmp
if ((eh <= (-3d-20)) .or. (.not. (eh <= 1.95d-32))) then
tmp = abs((ew - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t))))))))
else
tmp = abs((cos(t) * ew))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3e-20) || !(eh <= 1.95e-32)) {
tmp = Math.abs((ew - ((eh * Math.sin(t)) * Math.sin(Math.atan((-eh / (ew / Math.tan(t))))))));
} else {
tmp = Math.abs((Math.cos(t) * ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -3e-20) or not (eh <= 1.95e-32): tmp = math.fabs((ew - ((eh * math.sin(t)) * math.sin(math.atan((-eh / (ew / math.tan(t)))))))) else: tmp = math.fabs((math.cos(t) * ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -3e-20) || !(eh <= 1.95e-32)) tmp = abs(Float64(ew - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t)))))))); else tmp = abs(Float64(cos(t) * ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -3e-20) || ~((eh <= 1.95e-32))) tmp = abs((ew - ((eh * sin(t)) * sin(atan((-eh / (ew / tan(t)))))))); else tmp = abs((cos(t) * ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -3e-20], N[Not[LessEqual[eh, 1.95e-32]], $MachinePrecision]], N[Abs[N[(ew - 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], N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3 \cdot 10^{-20} \lor \neg \left(eh \leq 1.95 \cdot 10^{-32}\right):\\
\;\;\;\;\left|ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos t \cdot ew\right|\\
\end{array}
\end{array}
if eh < -3.00000000000000029e-20 or 1.9500000000000001e-32 < eh Initial program 99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
cancel-sign-sub99.8%
Simplified99.8%
add-cube-cbrt99.1%
pow399.2%
Applied egg-rr99.2%
Taylor expanded in t around 0 91.1%
pow-base-191.1%
*-lft-identity91.1%
Simplified91.1%
if -3.00000000000000029e-20 < eh < 1.9500000000000001e-32Initial program 99.7%
fabs-sub99.7%
sub-neg99.7%
+-commutative99.7%
associate-*l*99.7%
distribute-rgt-neg-in99.7%
fma-def99.8%
Simplified99.7%
associate-*r/99.7%
*-commutative99.7%
add-sqr-sqrt52.9%
sqrt-unprod99.7%
sqr-neg99.7%
sqrt-unprod46.8%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
associate-*r/99.7%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in ew around inf 85.3%
associate-*r*85.3%
neg-mul-185.3%
Simplified85.3%
Final simplification88.5%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -1.66e-7) (not (<= t 18500000.0))) (fabs (* (cos t) ew)) (fabs (- (* (* t eh) (sin (atan (* eh (/ (- (tan t)) ew))))) ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.66e-7) || !(t <= 18500000.0)) {
tmp = fabs((cos(t) * ew));
} else {
tmp = fabs((((t * eh) * sin(atan((eh * (-tan(t) / ew))))) - 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 <= (-1.66d-7)) .or. (.not. (t <= 18500000.0d0))) then
tmp = abs((cos(t) * ew))
else
tmp = abs((((t * eh) * sin(atan((eh * (-tan(t) / ew))))) - ew))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.66e-7) || !(t <= 18500000.0)) {
tmp = Math.abs((Math.cos(t) * ew));
} else {
tmp = Math.abs((((t * eh) * Math.sin(Math.atan((eh * (-Math.tan(t) / ew))))) - ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -1.66e-7) or not (t <= 18500000.0): tmp = math.fabs((math.cos(t) * ew)) else: tmp = math.fabs((((t * eh) * math.sin(math.atan((eh * (-math.tan(t) / ew))))) - ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -1.66e-7) || !(t <= 18500000.0)) tmp = abs(Float64(cos(t) * ew)); else tmp = abs(Float64(Float64(Float64(t * eh) * sin(atan(Float64(eh * Float64(Float64(-tan(t)) / ew))))) - ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -1.66e-7) || ~((t <= 18500000.0))) tmp = abs((cos(t) * ew)); else tmp = abs((((t * eh) * sin(atan((eh * (-tan(t) / ew))))) - ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -1.66e-7], N[Not[LessEqual[t, 18500000.0]], $MachinePrecision]], N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(t * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[((-N[Tan[t], $MachinePrecision]) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.66 \cdot 10^{-7} \lor \neg \left(t \leq 18500000\right):\\
\;\;\;\;\left|\cos t \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(t \cdot eh\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{-\tan t}{ew}\right) - ew\right|\\
\end{array}
\end{array}
if t < -1.66000000000000004e-7 or 1.85e7 < 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%
associate-*r/99.6%
*-commutative99.6%
add-sqr-sqrt52.1%
sqrt-unprod99.6%
sqr-neg99.6%
sqrt-unprod47.5%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
associate-*r/99.6%
cos-atan99.6%
hypot-1-def99.6%
Applied egg-rr99.6%
associate-*r/99.6%
associate-*l/99.6%
Simplified99.6%
Taylor expanded in ew around inf 51.0%
associate-*r*51.0%
neg-mul-151.0%
Simplified51.0%
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%
associate-*r/100.0%
*-commutative100.0%
add-sqr-sqrt50.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod50.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
associate-*r/100.0%
cos-atan100.0%
hypot-1-def100.0%
Applied egg-rr100.0%
associate-*r/100.0%
associate-*l/100.0%
Simplified100.0%
Taylor expanded in t around 0 96.7%
+-commutative96.7%
mul-1-neg96.7%
unsub-neg96.7%
*-commutative96.7%
mul-1-neg96.7%
*-commutative96.7%
associate-*r/96.7%
distribute-rgt-neg-in96.7%
Simplified96.7%
Final simplification73.2%
(FPCore (eh ew t) :precision binary64 (fabs (* (cos t) ew)))
double code(double eh, double ew, double t) {
return fabs((cos(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((cos(t) * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.cos(t) * ew));
}
def code(eh, ew, t): return math.fabs((math.cos(t) * ew))
function code(eh, ew, t) return abs(Float64(cos(t) * ew)) end
function tmp = code(eh, ew, t) tmp = abs((cos(t) * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\cos t \cdot 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%
associate-*r/99.8%
*-commutative99.8%
add-sqr-sqrt51.1%
sqrt-unprod99.8%
sqr-neg99.8%
sqrt-unprod48.7%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in ew around inf 58.0%
associate-*r*58.0%
neg-mul-158.0%
Simplified58.0%
Final simplification58.0%
(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%
associate-*r/99.8%
*-commutative99.8%
add-sqr-sqrt51.1%
sqrt-unprod99.8%
sqr-neg99.8%
sqrt-unprod48.7%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*r/99.8%
cos-atan99.8%
hypot-1-def99.8%
Applied egg-rr99.8%
associate-*r/99.8%
associate-*l/99.8%
Simplified99.8%
Taylor expanded in t around 0 38.8%
mul-1-neg38.8%
Simplified38.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)))))))