
(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 11 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 (/ (* eh (tan t)) (- ew))))
(fabs
(fma
(* (sin (atan t_1)) (- eh))
(sin t)
(/ (* ew (cos t)) (sqrt (+ (pow t_1 2.0) 1.0)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh * tan(t)) / -ew;
return fabs(fma((sin(atan(t_1)) * -eh), sin(t), ((ew * cos(t)) / sqrt((pow(t_1, 2.0) + 1.0)))));
}
function code(eh, ew, t) t_1 = Float64(Float64(eh * tan(t)) / Float64(-ew)) return abs(fma(Float64(sin(atan(t_1)) * Float64(-eh)), sin(t), Float64(Float64(ew * cos(t)) / sqrt(Float64((t_1 ^ 2.0) + 1.0))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]}, N[Abs[N[(N[(N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision] * (-eh)), $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$1, 2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh \cdot \tan t}{-ew}\\
\left|\mathsf{fma}\left(\sin \tan^{-1} t\_1 \cdot \left(-eh\right), \sin t, \frac{ew \cdot \cos t}{\sqrt{{t\_1}^{2} + 1}}\right)\right|
\end{array}
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (* eh (/ (tan t) ew))))
(if (<= ew 1.8e-268)
(fabs
(*
ew
(fma
eh
(/ (* (sin t) (sin (atan (/ (* eh t) (- ew))))) ew)
(- (cos t)))))
(if (<= ew 1.02e+42)
(fabs
(fma
(* (sin (atan (/ (* eh (tan t)) (- ew)))) (/ (sin t) ew))
(* eh (- ew))
t_1))
(/ (fabs (fma t_2 (* eh (sin t)) t_1)) (sqrt (+ (pow t_2 2.0) 1.0)))))))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double t_2 = eh * (tan(t) / ew);
double tmp;
if (ew <= 1.8e-268) {
tmp = fabs((ew * fma(eh, ((sin(t) * sin(atan(((eh * t) / -ew)))) / ew), -cos(t))));
} else if (ew <= 1.02e+42) {
tmp = fabs(fma((sin(atan(((eh * tan(t)) / -ew))) * (sin(t) / ew)), (eh * -ew), t_1));
} else {
tmp = fabs(fma(t_2, (eh * sin(t)), t_1)) / sqrt((pow(t_2, 2.0) + 1.0));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) t_2 = Float64(eh * Float64(tan(t) / ew)) tmp = 0.0 if (ew <= 1.8e-268) tmp = abs(Float64(ew * fma(eh, Float64(Float64(sin(t) * sin(atan(Float64(Float64(eh * t) / Float64(-ew))))) / ew), Float64(-cos(t))))); elseif (ew <= 1.02e+42) tmp = abs(fma(Float64(sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew)))) * Float64(sin(t) / ew)), Float64(eh * Float64(-ew)), t_1)); else tmp = Float64(abs(fma(t_2, Float64(eh * sin(t)), t_1)) / sqrt(Float64((t_2 ^ 2.0) + 1.0))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, 1.8e-268], N[Abs[N[(ew * N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * t), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 1.02e+42], N[Abs[N[(N[(N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] * N[(eh * (-ew)), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(t$95$2 * N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$2, 2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := eh \cdot \frac{\tan t}{ew}\\
\mathbf{if}\;ew \leq 1.8 \cdot 10^{-268}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot t}{-ew}\right)}{ew}, -\cos t\right)\right|\\
\mathbf{elif}\;ew \leq 1.02 \cdot 10^{+42}:\\
\;\;\;\;\left|\mathsf{fma}\left(\sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) \cdot \frac{\sin t}{ew}, eh \cdot \left(-ew\right), t\_1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\mathsf{fma}\left(t\_2, eh \cdot \sin t, t\_1\right)\right|}{\sqrt{{t\_2}^{2} + 1}}\\
\end{array}
\end{array}
if ew < 1.8000000000000001e-268Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified94.4%
Taylor expanded in t around 0
/-lowering-/.f64N/A
*-lowering-*.f6494.4
Simplified94.4%
if 1.8000000000000001e-268 < ew < 1.01999999999999996e42Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified84.6%
distribute-rgt-inN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr96.0%
if 1.01999999999999996e42 < ew Initial program 99.9%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.9%
Applied egg-rr99.8%
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
tan-lowering-tan.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
*-lowering-*.f64N/A
cos-lowering-cos.f6499.8
Applied egg-rr99.8%
Final simplification96.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (* eh (/ (tan t) ew))))
(if (<= ew 2.5e-268)
(fabs
(*
ew
(fma
eh
(/ (* (sin t) (sin (atan (/ (* eh t) (- ew))))) ew)
(- (cos t)))))
(if (<= ew 8e+41)
(fabs
(fma
(* (sin (atan (/ (* eh (tan t)) (- ew)))) (/ (sin t) ew))
(* eh (- ew))
t_1))
(/ (fabs (fma eh (* (sin t) t_2) t_1)) (sqrt (+ (pow t_2 2.0) 1.0)))))))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double t_2 = eh * (tan(t) / ew);
double tmp;
if (ew <= 2.5e-268) {
tmp = fabs((ew * fma(eh, ((sin(t) * sin(atan(((eh * t) / -ew)))) / ew), -cos(t))));
} else if (ew <= 8e+41) {
tmp = fabs(fma((sin(atan(((eh * tan(t)) / -ew))) * (sin(t) / ew)), (eh * -ew), t_1));
} else {
tmp = fabs(fma(eh, (sin(t) * t_2), t_1)) / sqrt((pow(t_2, 2.0) + 1.0));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) t_2 = Float64(eh * Float64(tan(t) / ew)) tmp = 0.0 if (ew <= 2.5e-268) tmp = abs(Float64(ew * fma(eh, Float64(Float64(sin(t) * sin(atan(Float64(Float64(eh * t) / Float64(-ew))))) / ew), Float64(-cos(t))))); elseif (ew <= 8e+41) tmp = abs(fma(Float64(sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew)))) * Float64(sin(t) / ew)), Float64(eh * Float64(-ew)), t_1)); else tmp = Float64(abs(fma(eh, Float64(sin(t) * t_2), t_1)) / sqrt(Float64((t_2 ^ 2.0) + 1.0))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, 2.5e-268], N[Abs[N[(ew * N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * t), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 8e+41], N[Abs[N[(N[(N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] * N[(eh * (-ew)), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(eh * N[(N[Sin[t], $MachinePrecision] * t$95$2), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$2, 2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := eh \cdot \frac{\tan t}{ew}\\
\mathbf{if}\;ew \leq 2.5 \cdot 10^{-268}:\\
\;\;\;\;\left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot t}{-ew}\right)}{ew}, -\cos t\right)\right|\\
\mathbf{elif}\;ew \leq 8 \cdot 10^{+41}:\\
\;\;\;\;\left|\mathsf{fma}\left(\sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) \cdot \frac{\sin t}{ew}, eh \cdot \left(-ew\right), t\_1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|\mathsf{fma}\left(eh, \sin t \cdot t\_2, t\_1\right)\right|}{\sqrt{{t\_2}^{2} + 1}}\\
\end{array}
\end{array}
if ew < 2.5e-268Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified94.4%
Taylor expanded in t around 0
/-lowering-/.f64N/A
*-lowering-*.f6494.4
Simplified94.4%
if 2.5e-268 < ew < 8.00000000000000005e41Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified84.6%
distribute-rgt-inN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr96.0%
if 8.00000000000000005e41 < ew Initial program 99.9%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.9%
Applied egg-rr99.8%
Final simplification96.1%
(FPCore (eh ew t)
:precision binary64
(fabs
(*
ew
(fma
eh
(/ 1.0 (/ ew (* (sin (atan (/ (* eh (tan t)) (- ew)))) (sin t))))
(- (cos t))))))
double code(double eh, double ew, double t) {
return fabs((ew * fma(eh, (1.0 / (ew / (sin(atan(((eh * tan(t)) / -ew))) * sin(t)))), -cos(t))));
}
function code(eh, ew, t) return abs(Float64(ew * fma(eh, Float64(1.0 / Float64(ew / Float64(sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew)))) * sin(t)))), Float64(-cos(t))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(eh * N[(1.0 / N[(ew / N[(N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \mathsf{fma}\left(eh, \frac{1}{\frac{ew}{\sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) \cdot \sin t}}, -\cos t\right)\right|
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified92.6%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
distribute-frac-neg2N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
neg-lowering-neg.f6492.6
Applied egg-rr92.6%
Final simplification92.6%
(FPCore (eh ew t)
:precision binary64
(fabs
(*
ew
(fma
eh
(* (sin t) (/ (sin (atan (/ (* eh (tan t)) (- ew)))) ew))
(- (cos t))))))
double code(double eh, double ew, double t) {
return fabs((ew * fma(eh, (sin(t) * (sin(atan(((eh * tan(t)) / -ew))) / ew)), -cos(t))));
}
function code(eh, ew, t) return abs(Float64(ew * fma(eh, Float64(sin(t) * Float64(sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew)))) / ew)), Float64(-cos(t))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(eh * N[(N[Sin[t], $MachinePrecision] * N[(N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \mathsf{fma}\left(eh, \sin t \cdot \frac{\sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)}{ew}, -\cos t\right)\right|
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified92.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
sin-lowering-sin.f64N/A
distribute-frac-neg2N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
neg-lowering-neg.f64N/A
sin-lowering-sin.f6492.6
Applied egg-rr92.6%
Final simplification92.6%
(FPCore (eh ew t)
:precision binary64
(fabs
(*
ew
(fma
eh
(/ 1.0 (/ ew (* (sin t) (sin (atan (/ (* eh t) (- ew)))))))
(- (cos t))))))
double code(double eh, double ew, double t) {
return fabs((ew * fma(eh, (1.0 / (ew / (sin(t) * sin(atan(((eh * t) / -ew)))))), -cos(t))));
}
function code(eh, ew, t) return abs(Float64(ew * fma(eh, Float64(1.0 / Float64(ew / Float64(sin(t) * sin(atan(Float64(Float64(eh * t) / Float64(-ew))))))), Float64(-cos(t))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(eh * N[(1.0 / N[(ew / N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * t), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \mathsf{fma}\left(eh, \frac{1}{\frac{ew}{\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot t}{-ew}\right)}}, -\cos t\right)\right|
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified92.6%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f64N/A
sin-lowering-sin.f64N/A
distribute-frac-neg2N/A
atan-lowering-atan.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
tan-lowering-tan.f64N/A
neg-lowering-neg.f6492.6
Applied egg-rr92.6%
Taylor expanded in t around 0
mul-1-negN/A
associate-*l/N/A
distribute-lft-neg-outN/A
mul-1-negN/A
associate-*r/N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f6492.4
Simplified92.4%
Final simplification92.4%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (fma eh (/ (* (sin t) (sin (atan (/ (* eh t) (- ew))))) ew) (- (cos t))))))
double code(double eh, double ew, double t) {
return fabs((ew * fma(eh, ((sin(t) * sin(atan(((eh * t) / -ew)))) / ew), -cos(t))));
}
function code(eh, ew, t) return abs(Float64(ew * fma(eh, Float64(Float64(sin(t) * sin(atan(Float64(Float64(eh * t) / Float64(-ew))))) / ew), Float64(-cos(t))))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(eh * N[(N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * t), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \mathsf{fma}\left(eh, \frac{\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot t}{-ew}\right)}{ew}, -\cos t\right)\right|
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in ew around -inf
associate-*r*N/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
Simplified92.6%
Taylor expanded in t around 0
/-lowering-/.f64N/A
*-lowering-*.f6492.4
Simplified92.4%
Final simplification92.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* ew (cos t)))))
(if (<= ew -2.4e-47)
t_1
(if (<= ew 0.0065) (/ -1.0 (/ -1.0 (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.4e-47) {
tmp = t_1;
} else if (ew <= 0.0065) {
tmp = -1.0 / (-1.0 / 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.4d-47)) then
tmp = t_1
else if (ew <= 0.0065d0) then
tmp = (-1.0d0) / ((-1.0d0) / 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.4e-47) {
tmp = t_1;
} else if (ew <= 0.0065) {
tmp = -1.0 / (-1.0 / 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.4e-47: tmp = t_1 elif ew <= 0.0065: tmp = -1.0 / (-1.0 / 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.4e-47) tmp = t_1; elseif (ew <= 0.0065) tmp = Float64(-1.0 / Float64(-1.0 / 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.4e-47) tmp = t_1; elseif (ew <= 0.0065) tmp = -1.0 / (-1.0 / 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.4e-47], t$95$1, If[LessEqual[ew, 0.0065], N[(-1.0 / N[(-1.0 / N[Abs[N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $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.4 \cdot 10^{-47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 0.0065:\\
\;\;\;\;\frac{-1}{\frac{-1}{\left|eh \cdot \sin t\right|}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -2.3999999999999999e-47 or 0.0064999999999999997 < ew Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
cos-lowering-cos.f6483.9
Simplified83.9%
if -2.3999999999999999e-47 < ew < 0.0064999999999999997Initial program 99.8%
Applied egg-rr57.4%
Taylor expanded in ew around 0
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sin-lowering-sin.f6471.3
Simplified71.3%
Final simplification78.3%
(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%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in eh around 0
*-lowering-*.f64N/A
cos-lowering-cos.f6461.6
Simplified61.6%
(FPCore (eh ew t) :precision binary64 (fabs ew))
double code(double eh, double ew, double t) {
return fabs(ew);
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(ew)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(ew);
}
def code(eh, ew, t): return math.fabs(ew)
function code(eh, ew, t) return abs(ew) end
function tmp = code(eh, ew, t) tmp = abs(ew); end
code[eh_, ew_, t_] := N[Abs[ew], $MachinePrecision]
\begin{array}{l}
\\
\left|ew\right|
\end{array}
Initial program 99.8%
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr99.8%
Taylor expanded in t around 0
Simplified42.4%
(FPCore (eh ew t) :precision binary64 ew)
double code(double eh, double ew, double t) {
return ew;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = ew
end function
public static double code(double eh, double ew, double t) {
return ew;
}
def code(eh, ew, t): return ew
function code(eh, ew, t) return ew end
function tmp = code(eh, ew, t) tmp = ew; end
code[eh_, ew_, t_] := ew
\begin{array}{l}
\\
ew
\end{array}
Initial program 99.8%
Applied egg-rr78.9%
Taylor expanded in t around 0
/-lowering-/.f6442.3
Simplified42.3%
inv-powN/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
inv-powN/A
clear-numN/A
/-rgt-identity25.8
Applied egg-rr25.8%
herbie shell --seed 2024199
(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)))))))