
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (fabs (- (/ (* ew (cos t)) (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((((ew * cos(t)) / 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((((ew * Math.cos(t)) / 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((((ew * math.cos(t)) / 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(ew * cos(t)) / hypot(1.0, Float64(tan(t) / Float64(ew / eh)))) - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t))))))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) / 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[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] / N[(ew / eh), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \frac{\tan t}{\frac{ew}{eh}}\right)} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right)\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
expm1-log1p-u73.1%
expm1-udef56.6%
Applied egg-rr57.7%
expm1-def74.3%
expm1-log1p99.8%
associate-*r/99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(if (<= eh -4.7e-138)
(fabs (- ew (* eh (* (sin t) (sin (atan (/ (- eh) (/ ew (tan t)))))))))
(if (<= eh 1.35e+46)
(fabs (* ew (cos t)))
(fabs (- ew (* eh (* (sin t) (sin (atan (- (/ (* t eh) ew)))))))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -4.7e-138) {
tmp = fabs((ew - (eh * (sin(t) * sin(atan((-eh / (ew / tan(t)))))))));
} else if (eh <= 1.35e+46) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / 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 <= (-4.7d-138)) then
tmp = abs((ew - (eh * (sin(t) * sin(atan((-eh / (ew / tan(t)))))))))
else if (eh <= 1.35d+46) then
tmp = abs((ew * cos(t)))
else
tmp = abs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -4.7e-138) {
tmp = Math.abs((ew - (eh * (Math.sin(t) * Math.sin(Math.atan((-eh / (ew / Math.tan(t)))))))));
} else if (eh <= 1.35e+46) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((ew - (eh * (Math.sin(t) * Math.sin(Math.atan(-((t * eh) / ew)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -4.7e-138: tmp = math.fabs((ew - (eh * (math.sin(t) * math.sin(math.atan((-eh / (ew / math.tan(t))))))))) elif eh <= 1.35e+46: tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((ew - (eh * (math.sin(t) * math.sin(math.atan(-((t * eh) / ew))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -4.7e-138) tmp = abs(Float64(ew - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t))))))))); elseif (eh <= 1.35e+46) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(ew - Float64(eh * Float64(sin(t) * sin(atan(Float64(-Float64(Float64(t * eh) / ew)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -4.7e-138) tmp = abs((ew - (eh * (sin(t) * sin(atan((-eh / (ew / tan(t))))))))); elseif (eh <= 1.35e+46) tmp = abs((ew * cos(t))); else tmp = abs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -4.7e-138], N[Abs[N[(ew - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 1.35e+46], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[(-N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -4.7 \cdot 10^{-138}:\\
\;\;\;\;\left|ew - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right)\right|\\
\mathbf{elif}\;eh \leq 1.35 \cdot 10^{+46}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-\frac{t \cdot eh}{ew}\right)\right)\right|\\
\end{array}
\end{array}
if eh < -4.7000000000000001e-138Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
add-cbrt-cube68.3%
pow368.2%
Applied egg-rr70.9%
Taylor expanded in t around 0 91.7%
if -4.7000000000000001e-138 < eh < 1.3500000000000001e46Initial program 99.7%
fabs-neg99.7%
sub0-neg99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
Simplified99.7%
sin-mult85.6%
associate-*r/85.6%
Applied egg-rr84.3%
+-inverses84.3%
*-commutative84.3%
associate-/l*84.3%
div084.3%
Simplified84.3%
add-cube-cbrt82.7%
pow382.6%
Applied egg-rr82.5%
Taylor expanded in eh around 0 84.5%
pow-base-184.5%
*-rgt-identity84.5%
*-commutative84.5%
Simplified84.5%
if 1.3500000000000001e46 < eh Initial program 99.9%
fabs-neg99.9%
sub0-neg99.9%
sub-neg99.9%
+-commutative99.9%
associate--r+99.9%
Simplified99.8%
add-cbrt-cube70.8%
pow370.8%
Applied egg-rr70.8%
Taylor expanded in t around 0 92.1%
Taylor expanded in t around 0 92.1%
associate-*r/92.1%
mul-1-neg92.1%
distribute-rgt-neg-in92.1%
Simplified92.1%
Final simplification88.8%
(FPCore (eh ew t)
:precision binary64
(if (<= eh -3.05e-139)
(fabs (- (* ew (cos (atan (* (tan t) (/ (- eh) ew))))) (* eh (sin t))))
(if (<= eh 1.35e+46)
(fabs (* ew (cos t)))
(fabs (- ew (* eh (* (sin t) (sin (atan (- (/ (* t eh) ew)))))))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -3.05e-139) {
tmp = fabs(((ew * cos(atan((tan(t) * (-eh / ew))))) - (eh * sin(t))));
} else if (eh <= 1.35e+46) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew)))))));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if (eh <= (-3.05d-139)) then
tmp = abs(((ew * cos(atan((tan(t) * (-eh / ew))))) - (eh * sin(t))))
else if (eh <= 1.35d+46) then
tmp = abs((ew * cos(t)))
else
tmp = abs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -3.05e-139) {
tmp = Math.abs(((ew * Math.cos(Math.atan((Math.tan(t) * (-eh / ew))))) - (eh * Math.sin(t))));
} else if (eh <= 1.35e+46) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((ew - (eh * (Math.sin(t) * Math.sin(Math.atan(-((t * eh) / ew)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -3.05e-139: tmp = math.fabs(((ew * math.cos(math.atan((math.tan(t) * (-eh / ew))))) - (eh * math.sin(t)))) elif eh <= 1.35e+46: tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((ew - (eh * (math.sin(t) * math.sin(math.atan(-((t * eh) / ew))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -3.05e-139) tmp = abs(Float64(Float64(ew * cos(atan(Float64(tan(t) * Float64(Float64(-eh) / ew))))) - Float64(eh * sin(t)))); elseif (eh <= 1.35e+46) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(ew - Float64(eh * Float64(sin(t) * sin(atan(Float64(-Float64(Float64(t * eh) / ew)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -3.05e-139) tmp = abs(((ew * cos(atan((tan(t) * (-eh / ew))))) - (eh * sin(t)))); elseif (eh <= 1.35e+46) tmp = abs((ew * cos(t))); else tmp = abs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -3.05e-139], N[Abs[N[(N[(ew * N[Cos[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[((-eh) / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 1.35e+46], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[(-N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3.05 \cdot 10^{-139}:\\
\;\;\;\;\left|ew \cdot \cos \tan^{-1} \left(\tan t \cdot \frac{-eh}{ew}\right) - eh \cdot \sin t\right|\\
\mathbf{elif}\;eh \leq 1.35 \cdot 10^{+46}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-\frac{t \cdot eh}{ew}\right)\right)\right|\\
\end{array}
\end{array}
if eh < -3.0499999999999999e-139Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan70.6%
associate-*r/68.5%
associate-/r/68.3%
*-commutative68.3%
add-sqr-sqrt68.2%
sqrt-unprod55.4%
sqr-neg55.4%
sqrt-unprod0.0%
add-sqr-sqrt66.7%
hypot-1-def75.6%
associate-/r/75.6%
*-commutative75.6%
Applied egg-rr75.6%
associate-/l*83.7%
associate-/r/83.7%
associate-*r/83.7%
associate-/l*83.6%
associate-*r/83.7%
associate-/l*83.7%
Simplified83.7%
Taylor expanded in eh around inf 98.1%
Taylor expanded in t around 0 91.9%
*-commutative91.9%
mul-1-neg91.9%
associate-*r/91.9%
distribute-lft-neg-in91.9%
*-commutative91.9%
Simplified91.9%
if -3.0499999999999999e-139 < eh < 1.3500000000000001e46Initial program 99.7%
fabs-neg99.7%
sub0-neg99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
Simplified99.7%
sin-mult85.6%
associate-*r/85.6%
Applied egg-rr84.3%
+-inverses84.3%
*-commutative84.3%
associate-/l*84.3%
div084.3%
Simplified84.3%
add-cube-cbrt82.7%
pow382.6%
Applied egg-rr82.5%
Taylor expanded in eh around 0 84.5%
pow-base-184.5%
*-rgt-identity84.5%
*-commutative84.5%
Simplified84.5%
if 1.3500000000000001e46 < eh Initial program 99.9%
fabs-neg99.9%
sub0-neg99.9%
sub-neg99.9%
+-commutative99.9%
associate--r+99.9%
Simplified99.8%
add-cbrt-cube70.8%
pow370.8%
Applied egg-rr70.8%
Taylor expanded in t around 0 92.1%
Taylor expanded in t around 0 92.1%
associate-*r/92.1%
mul-1-neg92.1%
distribute-rgt-neg-in92.1%
Simplified92.1%
Final simplification88.9%
(FPCore (eh ew t) :precision binary64 (fabs (- (* ew (* (cos t) (cos (atan (- (/ (* t eh) ew)))))) (* eh (sin t)))))
double code(double eh, double ew, double t) {
return fabs(((ew * (cos(t) * cos(atan(-((t * eh) / ew))))) - (eh * sin(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(((ew * (cos(t) * cos(atan(-((t * eh) / ew))))) - (eh * sin(t))))
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))))) - (eh * Math.sin(t))));
}
def code(eh, ew, t): return math.fabs(((ew * (math.cos(t) * math.cos(math.atan(-((t * eh) / ew))))) - (eh * math.sin(t))))
function code(eh, ew, t) return abs(Float64(Float64(ew * Float64(cos(t) * cos(atan(Float64(-Float64(Float64(t * eh) / ew)))))) - Float64(eh * sin(t)))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * (cos(t) * cos(atan(-((t * eh) / ew))))) - (eh * sin(t)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[(N[Cos[t], $MachinePrecision] * N[Cos[N[ArcTan[(-N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(-\frac{t \cdot eh}{ew}\right)\right) - eh \cdot \sin t\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan80.4%
associate-*r/78.0%
associate-/r/76.4%
*-commutative76.4%
add-sqr-sqrt39.5%
sqrt-unprod66.4%
sqr-neg66.4%
sqrt-unprod36.6%
add-sqr-sqrt75.4%
hypot-1-def81.0%
associate-/r/81.0%
*-commutative81.0%
Applied egg-rr81.0%
associate-/l*87.5%
associate-/r/87.5%
associate-*r/87.6%
associate-/l*87.4%
associate-*r/87.7%
associate-/l*87.9%
Simplified87.9%
Taylor expanded in eh around inf 98.5%
Taylor expanded in t around 0 90.7%
associate-*r/80.5%
mul-1-neg80.5%
distribute-rgt-neg-in80.5%
Simplified90.7%
Final simplification90.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (/ (* ew (cos t)) (hypot 1.0 (/ (tan t) (/ ew eh)))) (* eh (sin t)))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) / hypot(1.0, (tan(t) / (ew / eh)))) + (eh * sin(t))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) / Math.hypot(1.0, (Math.tan(t) / (ew / eh)))) + (eh * Math.sin(t))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) / math.hypot(1.0, (math.tan(t) / (ew / eh)))) + (eh * math.sin(t))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) / hypot(1.0, Float64(tan(t) / Float64(ew / eh)))) + Float64(eh * sin(t)))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) / hypot(1.0, (tan(t) / (ew / eh)))) + (eh * sin(t)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] / N[(ew / eh), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \frac{\tan t}{\frac{ew}{eh}}\right)} + eh \cdot \sin t\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
expm1-log1p-u73.1%
expm1-udef56.6%
Applied egg-rr57.7%
expm1-def74.3%
expm1-log1p99.8%
associate-*r/99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan80.4%
associate-*r/78.0%
associate-/r/76.4%
*-commutative76.4%
add-sqr-sqrt39.5%
sqrt-unprod66.4%
sqr-neg66.4%
sqrt-unprod36.6%
add-sqr-sqrt75.4%
hypot-1-def81.0%
associate-/r/81.0%
*-commutative81.0%
Applied egg-rr81.0%
Taylor expanded in eh around -inf 98.5%
mul-1-neg98.5%
distribute-rgt-neg-in98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -8.2e-138) (not (<= eh 5.2e+46))) (fabs (- ew (* eh (* (sin t) (sin (atan (- (/ (* t eh) ew)))))))) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -8.2e-138) || !(eh <= 5.2e+46)) {
tmp = fabs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew)))))));
} else {
tmp = fabs((ew * cos(t)));
}
return tmp;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if ((eh <= (-8.2d-138)) .or. (.not. (eh <= 5.2d+46))) then
tmp = abs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew)))))))
else
tmp = abs((ew * cos(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -8.2e-138) || !(eh <= 5.2e+46)) {
tmp = Math.abs((ew - (eh * (Math.sin(t) * Math.sin(Math.atan(-((t * eh) / ew)))))));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -8.2e-138) or not (eh <= 5.2e+46): tmp = math.fabs((ew - (eh * (math.sin(t) * math.sin(math.atan(-((t * eh) / ew))))))) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -8.2e-138) || !(eh <= 5.2e+46)) tmp = abs(Float64(ew - Float64(eh * Float64(sin(t) * sin(atan(Float64(-Float64(Float64(t * eh) / ew)))))))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -8.2e-138) || ~((eh <= 5.2e+46))) tmp = abs((ew - (eh * (sin(t) * sin(atan(-((t * eh) / ew))))))); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -8.2e-138], N[Not[LessEqual[eh, 5.2e+46]], $MachinePrecision]], N[Abs[N[(ew - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[(-N[(N[(t * eh), $MachinePrecision] / ew), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -8.2 \cdot 10^{-138} \lor \neg \left(eh \leq 5.2 \cdot 10^{+46}\right):\\
\;\;\;\;\left|ew - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(-\frac{t \cdot eh}{ew}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -8.19999999999999998e-138 or 5.20000000000000027e46 < eh Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
add-cbrt-cube69.1%
pow369.1%
Applied egg-rr70.9%
Taylor expanded in t around 0 91.8%
Taylor expanded in t around 0 91.8%
associate-*r/91.8%
mul-1-neg91.8%
distribute-rgt-neg-in91.8%
Simplified91.8%
if -8.19999999999999998e-138 < eh < 5.20000000000000027e46Initial program 99.7%
fabs-neg99.7%
sub0-neg99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
Simplified99.7%
sin-mult85.6%
associate-*r/85.6%
Applied egg-rr84.3%
+-inverses84.3%
*-commutative84.3%
associate-/l*84.3%
div084.3%
Simplified84.3%
add-cube-cbrt82.7%
pow382.6%
Applied egg-rr82.5%
Taylor expanded in eh around 0 84.5%
pow-base-184.5%
*-rgt-identity84.5%
*-commutative84.5%
Simplified84.5%
Final simplification88.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -2.5e-6) (not (<= t 0.00029))) (fabs (* ew (cos t))) (fabs (- ew (* (sin (atan (* (tan t) (/ eh ew)))) (* t eh))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -2.5e-6) || !(t <= 0.00029)) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((ew - (sin(atan((tan(t) * (eh / 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 <= (-2.5d-6)) .or. (.not. (t <= 0.00029d0))) then
tmp = abs((ew * cos(t)))
else
tmp = abs((ew - (sin(atan((tan(t) * (eh / ew)))) * (t * eh))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -2.5e-6) || !(t <= 0.00029)) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((ew - (Math.sin(Math.atan((Math.tan(t) * (eh / ew)))) * (t * eh))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -2.5e-6) or not (t <= 0.00029): tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((ew - (math.sin(math.atan((math.tan(t) * (eh / ew)))) * (t * eh)))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -2.5e-6) || !(t <= 0.00029)) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(ew - Float64(sin(atan(Float64(tan(t) * Float64(eh / ew)))) * Float64(t * eh)))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -2.5e-6) || ~((t <= 0.00029))) tmp = abs((ew * cos(t))); else tmp = abs((ew - (sin(atan((tan(t) * (eh / ew)))) * (t * eh)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -2.5e-6], N[Not[LessEqual[t, 0.00029]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew - N[(N[Sin[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(t * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.5 \cdot 10^{-6} \lor \neg \left(t \leq 0.00029\right):\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew - \sin \tan^{-1} \left(\tan t \cdot \frac{eh}{ew}\right) \cdot \left(t \cdot eh\right)\right|\\
\end{array}
\end{array}
if t < -2.5000000000000002e-6 or 2.9e-4 < t Initial program 99.6%
fabs-neg99.6%
sub0-neg99.6%
sub-neg99.6%
+-commutative99.6%
associate--r+99.6%
Simplified99.6%
sin-mult50.6%
associate-*r/50.6%
Applied egg-rr46.9%
+-inverses46.9%
*-commutative46.9%
associate-/l*46.9%
div046.9%
Simplified46.9%
add-cube-cbrt46.2%
pow346.2%
Applied egg-rr45.8%
Taylor expanded in eh around 0 47.2%
pow-base-147.2%
*-rgt-identity47.2%
*-commutative47.2%
Simplified47.2%
if -2.5000000000000002e-6 < t < 2.9e-4Initial program 100.0%
fabs-neg100.0%
sub0-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
add-cbrt-cube59.8%
pow359.8%
Applied egg-rr59.8%
Taylor expanded in t around 0 100.0%
expm1-log1p-u90.5%
expm1-udef79.3%
Applied egg-rr77.0%
expm1-def88.2%
expm1-log1p100.0%
Simplified100.0%
Taylor expanded in t around 0 100.0%
Final simplification72.8%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (cos t))))
double code(double eh, double ew, double t) {
return fabs((ew * cos(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((ew * cos(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.cos(t)))
function code(eh, ew, t) return abs(Float64(ew * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \cos t\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
sin-mult62.0%
associate-*r/62.0%
Applied egg-rr59.6%
+-inverses59.6%
*-commutative59.6%
associate-/l*59.6%
div059.6%
Simplified59.6%
add-cube-cbrt58.5%
pow358.5%
Applied egg-rr58.2%
Taylor expanded in eh around 0 59.8%
pow-base-159.8%
*-rgt-identity59.8%
*-commutative59.8%
Simplified59.8%
Final simplification59.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-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
add-cbrt-cube63.9%
pow363.9%
Applied egg-rr65.0%
Taylor expanded in t around 0 80.5%
expm1-log1p-u65.7%
expm1-udef53.3%
Applied egg-rr51.2%
expm1-def63.7%
expm1-log1p80.5%
Simplified80.5%
Taylor expanded in ew around inf 42.0%
Final simplification42.0%
herbie shell --seed 2023189
(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)))))))