
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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 / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(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((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos 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 ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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 / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(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((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos 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
(* ew (sin t))
(/ 1.0 (sqrt (+ (pow t_1 2.0) 1.0)))
(* (* (cos t) eh) (sin (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (tan(t) * ew);
return fabs(fma((ew * sin(t)), (1.0 / sqrt((pow(t_1, 2.0) + 1.0))), ((cos(t) * eh) * sin(atan(t_1)))));
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(tan(t) * ew)) return abs(fma(Float64(ew * sin(t)), Float64(1.0 / sqrt(Float64((t_1 ^ 2.0) + 1.0))), Float64(Float64(cos(t) * eh) * sin(atan(t_1))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(N[Power[t$95$1, 2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{\tan t \cdot ew}\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\sqrt{{t\_1}^{2} + 1}}, \left(\cos t \cdot eh\right) \cdot \sin \tan^{-1} t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
+-commutativeN/A
lower-+.f64N/A
pow2N/A
lower-pow.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* ew (sin t)) (cos (atan (/ eh (* ew t)))) (* (* (cos t) eh) (sin (atan (/ eh (* (tan t) ew))))))))
double code(double eh, double ew, double t) {
return fabs(fma((ew * sin(t)), cos(atan((eh / (ew * t)))), ((cos(t) * eh) * sin(atan((eh / (tan(t) * ew)))))));
}
function code(eh, ew, t) return abs(fma(Float64(ew * sin(t)), cos(atan(Float64(eh / Float64(ew * t)))), Float64(Float64(cos(t) * eh) * sin(atan(Float64(eh / Float64(tan(t) * ew))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right), \left(\cos t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\right)\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Final simplification99.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (* (/ (/ eh (sin t)) ew) (cos t)))) (t_2 (* (cos t) eh)))
(if (<= ew -2.8e-43)
(fabs (* (* (cos (atan (/ (/ t_2 ew) (sin t)))) ew) (sin t)))
(if (<= ew 3.95e+18)
(fabs (* (sin t_1) t_2))
(fabs (* (cos t_1) (* ew (sin t))))))))
double code(double eh, double ew, double t) {
double t_1 = atan((((eh / sin(t)) / ew) * cos(t)));
double t_2 = cos(t) * eh;
double tmp;
if (ew <= -2.8e-43) {
tmp = fabs(((cos(atan(((t_2 / ew) / sin(t)))) * ew) * sin(t)));
} else if (ew <= 3.95e+18) {
tmp = fabs((sin(t_1) * t_2));
} else {
tmp = fabs((cos(t_1) * (ew * sin(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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = atan((((eh / sin(t)) / ew) * cos(t)))
t_2 = cos(t) * eh
if (ew <= (-2.8d-43)) then
tmp = abs(((cos(atan(((t_2 / ew) / sin(t)))) * ew) * sin(t)))
else if (ew <= 3.95d+18) then
tmp = abs((sin(t_1) * t_2))
else
tmp = abs((cos(t_1) * (ew * sin(t))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((((eh / Math.sin(t)) / ew) * Math.cos(t)));
double t_2 = Math.cos(t) * eh;
double tmp;
if (ew <= -2.8e-43) {
tmp = Math.abs(((Math.cos(Math.atan(((t_2 / ew) / Math.sin(t)))) * ew) * Math.sin(t)));
} else if (ew <= 3.95e+18) {
tmp = Math.abs((Math.sin(t_1) * t_2));
} else {
tmp = Math.abs((Math.cos(t_1) * (ew * Math.sin(t))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan((((eh / math.sin(t)) / ew) * math.cos(t))) t_2 = math.cos(t) * eh tmp = 0 if ew <= -2.8e-43: tmp = math.fabs(((math.cos(math.atan(((t_2 / ew) / math.sin(t)))) * ew) * math.sin(t))) elif ew <= 3.95e+18: tmp = math.fabs((math.sin(t_1) * t_2)) else: tmp = math.fabs((math.cos(t_1) * (ew * math.sin(t)))) return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(eh / sin(t)) / ew) * cos(t))) t_2 = Float64(cos(t) * eh) tmp = 0.0 if (ew <= -2.8e-43) tmp = abs(Float64(Float64(cos(atan(Float64(Float64(t_2 / ew) / sin(t)))) * ew) * sin(t))); elseif (ew <= 3.95e+18) tmp = abs(Float64(sin(t_1) * t_2)); else tmp = abs(Float64(cos(t_1) * Float64(ew * sin(t)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan((((eh / sin(t)) / ew) * cos(t))); t_2 = cos(t) * eh; tmp = 0.0; if (ew <= -2.8e-43) tmp = abs(((cos(atan(((t_2 / ew) / sin(t)))) * ew) * sin(t))); elseif (ew <= 3.95e+18) tmp = abs((sin(t_1) * t_2)); else tmp = abs((cos(t_1) * (ew * sin(t)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]}, If[LessEqual[ew, -2.8e-43], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(N[(t$95$2 / ew), $MachinePrecision] / N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 3.95e+18], N[Abs[N[(N[Sin[t$95$1], $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[t$95$1], $MachinePrecision] * N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{\sin t}}{ew} \cdot \cos t\right)\\
t_2 := \cos t \cdot eh\\
\mathbf{if}\;ew \leq -2.8 \cdot 10^{-43}:\\
\;\;\;\;\left|\left(\cos \tan^{-1} \left(\frac{\frac{t\_2}{ew}}{\sin t}\right) \cdot ew\right) \cdot \sin t\right|\\
\mathbf{elif}\;ew \leq 3.95 \cdot 10^{+18}:\\
\;\;\;\;\left|\sin t\_1 \cdot t\_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos t\_1 \cdot \left(ew \cdot \sin t\right)\right|\\
\end{array}
\end{array}
if ew < -2.7999999999999998e-43Initial program 99.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
Taylor expanded in ew around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-sin.f6470.5
Applied rewrites70.5%
if -2.7999999999999998e-43 < ew < 3.95e18Initial program 99.8%
Taylor expanded in ew around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
Applied rewrites88.4%
if 3.95e18 < ew Initial program 99.7%
Taylor expanded in ew around inf
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.7%
Final simplification79.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (* (/ (/ eh (sin t)) ew) (cos t))))
(t_2 (fabs (* (cos t_1) (* ew (sin t))))))
(if (<= ew -2.8e-43)
t_2
(if (<= ew 3.95e+18) (fabs (* (sin t_1) (* (cos t) eh))) t_2))))
double code(double eh, double ew, double t) {
double t_1 = atan((((eh / sin(t)) / ew) * cos(t)));
double t_2 = fabs((cos(t_1) * (ew * sin(t))));
double tmp;
if (ew <= -2.8e-43) {
tmp = t_2;
} else if (ew <= 3.95e+18) {
tmp = fabs((sin(t_1) * (cos(t) * eh)));
} 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 = atan((((eh / sin(t)) / ew) * cos(t)))
t_2 = abs((cos(t_1) * (ew * sin(t))))
if (ew <= (-2.8d-43)) then
tmp = t_2
else if (ew <= 3.95d+18) then
tmp = abs((sin(t_1) * (cos(t) * eh)))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((((eh / Math.sin(t)) / ew) * Math.cos(t)));
double t_2 = Math.abs((Math.cos(t_1) * (ew * Math.sin(t))));
double tmp;
if (ew <= -2.8e-43) {
tmp = t_2;
} else if (ew <= 3.95e+18) {
tmp = Math.abs((Math.sin(t_1) * (Math.cos(t) * eh)));
} else {
tmp = t_2;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan((((eh / math.sin(t)) / ew) * math.cos(t))) t_2 = math.fabs((math.cos(t_1) * (ew * math.sin(t)))) tmp = 0 if ew <= -2.8e-43: tmp = t_2 elif ew <= 3.95e+18: tmp = math.fabs((math.sin(t_1) * (math.cos(t) * eh))) else: tmp = t_2 return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(eh / sin(t)) / ew) * cos(t))) t_2 = abs(Float64(cos(t_1) * Float64(ew * sin(t)))) tmp = 0.0 if (ew <= -2.8e-43) tmp = t_2; elseif (ew <= 3.95e+18) tmp = abs(Float64(sin(t_1) * Float64(cos(t) * eh))); else tmp = t_2; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan((((eh / sin(t)) / ew) * cos(t))); t_2 = abs((cos(t_1) * (ew * sin(t)))); tmp = 0.0; if (ew <= -2.8e-43) tmp = t_2; elseif (ew <= 3.95e+18) tmp = abs((sin(t_1) * (cos(t) * eh))); else tmp = t_2; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Cos[t$95$1], $MachinePrecision] * N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -2.8e-43], t$95$2, If[LessEqual[ew, 3.95e+18], N[Abs[N[(N[Sin[t$95$1], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{\sin t}}{ew} \cdot \cos t\right)\\
t_2 := \left|\cos t\_1 \cdot \left(ew \cdot \sin t\right)\right|\\
\mathbf{if}\;ew \leq -2.8 \cdot 10^{-43}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;ew \leq 3.95 \cdot 10^{+18}:\\
\;\;\;\;\left|\sin t\_1 \cdot \left(\cos t \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if ew < -2.7999999999999998e-43 or 3.95e18 < ew Initial program 99.7%
Taylor expanded in ew around inf
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.0%
if -2.7999999999999998e-43 < ew < 3.95e18Initial program 99.8%
Taylor expanded in ew around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
Applied rewrites88.4%
Final simplification79.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(* (cos (atan (* (/ (/ eh (sin t)) ew) (cos t)))) (* ew (sin t))))))
(if (<= ew -2.8e-43)
t_1
(if (<= ew 3.95e+18)
(/
1.0
(/ 1.0 (fabs (* (* (cos t) eh) (sin (atan (/ eh (* (tan t) ew))))))))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((cos(atan((((eh / sin(t)) / ew) * cos(t)))) * (ew * sin(t))));
double tmp;
if (ew <= -2.8e-43) {
tmp = t_1;
} else if (ew <= 3.95e+18) {
tmp = 1.0 / (1.0 / fabs(((cos(t) * eh) * sin(atan((eh / (tan(t) * ew)))))));
} 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((cos(atan((((eh / sin(t)) / ew) * cos(t)))) * (ew * sin(t))))
if (ew <= (-2.8d-43)) then
tmp = t_1
else if (ew <= 3.95d+18) then
tmp = 1.0d0 / (1.0d0 / abs(((cos(t) * eh) * sin(atan((eh / (tan(t) * ew)))))))
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((Math.cos(Math.atan((((eh / Math.sin(t)) / ew) * Math.cos(t)))) * (ew * Math.sin(t))));
double tmp;
if (ew <= -2.8e-43) {
tmp = t_1;
} else if (ew <= 3.95e+18) {
tmp = 1.0 / (1.0 / Math.abs(((Math.cos(t) * eh) * Math.sin(Math.atan((eh / (Math.tan(t) * ew)))))));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((math.cos(math.atan((((eh / math.sin(t)) / ew) * math.cos(t)))) * (ew * math.sin(t)))) tmp = 0 if ew <= -2.8e-43: tmp = t_1 elif ew <= 3.95e+18: tmp = 1.0 / (1.0 / math.fabs(((math.cos(t) * eh) * math.sin(math.atan((eh / (math.tan(t) * ew))))))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(cos(atan(Float64(Float64(Float64(eh / sin(t)) / ew) * cos(t)))) * Float64(ew * sin(t)))) tmp = 0.0 if (ew <= -2.8e-43) tmp = t_1; elseif (ew <= 3.95e+18) tmp = Float64(1.0 / Float64(1.0 / abs(Float64(Float64(cos(t) * eh) * sin(atan(Float64(eh / Float64(tan(t) * ew)))))))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((cos(atan((((eh / sin(t)) / ew) * cos(t)))) * (ew * sin(t)))); tmp = 0.0; if (ew <= -2.8e-43) tmp = t_1; elseif (ew <= 3.95e+18) tmp = 1.0 / (1.0 / abs(((cos(t) * eh) * sin(atan((eh / (tan(t) * ew))))))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Cos[N[ArcTan[N[(N[(N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -2.8e-43], t$95$1, If[LessEqual[ew, 3.95e+18], N[(1.0 / N[(1.0 / N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\cos \tan^{-1} \left(\frac{\frac{eh}{\sin t}}{ew} \cdot \cos t\right) \cdot \left(ew \cdot \sin t\right)\right|\\
\mathbf{if}\;ew \leq -2.8 \cdot 10^{-43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 3.95 \cdot 10^{+18}:\\
\;\;\;\;\frac{1}{\frac{1}{\left|\left(\cos t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\right|}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -2.7999999999999998e-43 or 3.95e18 < ew Initial program 99.7%
Taylor expanded in ew around inf
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.0%
if -2.7999999999999998e-43 < ew < 3.95e18Initial program 99.8%
lift-fabs.f64N/A
lift-+.f64N/A
flip-+N/A
clear-numN/A
Applied rewrites99.7%
Taylor expanded in ew around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6488.3
Applied rewrites88.3%
Applied rewrites88.3%
Final simplification79.9%
(FPCore (eh ew t) :precision binary64 (/ 1.0 (/ 1.0 (fabs (* (* (cos t) eh) (sin (atan (/ eh (* (tan t) ew)))))))))
double code(double eh, double ew, double t) {
return 1.0 / (1.0 / fabs(((cos(t) * eh) * sin(atan((eh / (tan(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 = 1.0d0 / (1.0d0 / abs(((cos(t) * eh) * sin(atan((eh / (tan(t) * ew)))))))
end function
public static double code(double eh, double ew, double t) {
return 1.0 / (1.0 / Math.abs(((Math.cos(t) * eh) * Math.sin(Math.atan((eh / (Math.tan(t) * ew)))))));
}
def code(eh, ew, t): return 1.0 / (1.0 / math.fabs(((math.cos(t) * eh) * math.sin(math.atan((eh / (math.tan(t) * ew)))))))
function code(eh, ew, t) return Float64(1.0 / Float64(1.0 / abs(Float64(Float64(cos(t) * eh) * sin(atan(Float64(eh / Float64(tan(t) * ew)))))))) end
function tmp = code(eh, ew, t) tmp = 1.0 / (1.0 / abs(((cos(t) * eh) * sin(atan((eh / (tan(t) * ew))))))); end
code[eh_, ew_, t_] := N[(1.0 / N[(1.0 / N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{\left|\left(\cos t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\right|}}
\end{array}
Initial program 99.8%
lift-fabs.f64N/A
lift-+.f64N/A
flip-+N/A
clear-numN/A
Applied rewrites99.6%
Taylor expanded in ew around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6460.6
Applied rewrites60.6%
Applied rewrites60.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (cos t) eh))
(t_2
(fabs
(*
(sin
(atan
(/ (fma (* (* -0.3333333333333333 (/ eh ew)) t) t (/ eh ew)) t)))
t_1))))
(if (<= t -7.5e+137)
t_2
(if (<= t 4.05e+96) (fabs (* (sin (atan (/ eh (* ew t)))) t_1)) t_2))))
double code(double eh, double ew, double t) {
double t_1 = cos(t) * eh;
double t_2 = fabs((sin(atan((fma(((-0.3333333333333333 * (eh / ew)) * t), t, (eh / ew)) / t))) * t_1));
double tmp;
if (t <= -7.5e+137) {
tmp = t_2;
} else if (t <= 4.05e+96) {
tmp = fabs((sin(atan((eh / (ew * t)))) * t_1));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(cos(t) * eh) t_2 = abs(Float64(sin(atan(Float64(fma(Float64(Float64(-0.3333333333333333 * Float64(eh / ew)) * t), t, Float64(eh / ew)) / t))) * t_1)) tmp = 0.0 if (t <= -7.5e+137) tmp = t_2; elseif (t <= 4.05e+96) tmp = abs(Float64(sin(atan(Float64(eh / Float64(ew * t)))) * t_1)); else tmp = t_2; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(N[(-0.3333333333333333 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] * t + N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -7.5e+137], t$95$2, If[LessEqual[t, 4.05e+96], N[Abs[N[(N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \cos t \cdot eh\\
t_2 := \left|\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(\left(-0.3333333333333333 \cdot \frac{eh}{ew}\right) \cdot t, t, \frac{eh}{ew}\right)}{t}\right) \cdot t\_1\right|\\
\mathbf{if}\;t \leq -7.5 \cdot 10^{+137}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t \leq 4.05 \cdot 10^{+96}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot t\_1\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if t < -7.50000000000000025e137 or 4.0500000000000001e96 < t Initial program 99.5%
Taylor expanded in ew around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
Applied rewrites54.5%
Taylor expanded in t around 0
Applied rewrites47.4%
if -7.50000000000000025e137 < t < 4.0500000000000001e96Initial program 99.9%
Taylor expanded in ew around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
Applied rewrites63.4%
Taylor expanded in t around 0
Applied rewrites63.1%
Final simplification58.2%
(FPCore (eh ew t) :precision binary64 (fabs (* (sin (atan (/ eh (* ew t)))) (* (cos t) eh))))
double code(double eh, double ew, double t) {
return fabs((sin(atan((eh / (ew * t)))) * (cos(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((sin(atan((eh / (ew * t)))) * (cos(t) * eh)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.sin(Math.atan((eh / (ew * t)))) * (Math.cos(t) * eh)));
}
def code(eh, ew, t): return math.fabs((math.sin(math.atan((eh / (ew * t)))) * (math.cos(t) * eh)))
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(eh / Float64(ew * t)))) * Float64(cos(t) * eh))) end
function tmp = code(eh, ew, t) tmp = abs((sin(atan((eh / (ew * t)))) * (cos(t) * eh))); end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \left(\cos t \cdot eh\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in ew around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
Applied rewrites60.6%
Taylor expanded in t around 0
Applied rewrites50.4%
(FPCore (eh ew t) :precision binary64 (fabs (- eh)))
double code(double eh, double ew, double t) {
return fabs(-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(-eh)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(-eh);
}
def code(eh, ew, t): return math.fabs(-eh)
function code(eh, ew, t) return abs(Float64(-eh)) end
function tmp = code(eh, ew, t) tmp = abs(-eh); end
code[eh_, ew_, t_] := N[Abs[(-eh)], $MachinePrecision]
\begin{array}{l}
\\
\left|-eh\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6442.4
Applied rewrites42.4%
Taylor expanded in t around 0
Applied rewrites40.6%
Applied rewrites11.8%
Taylor expanded in eh around -inf
Applied rewrites42.8%
herbie shell --seed 2024267
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))