
(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 13 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 (fabs (+ (* (sin (atan (/ eh (* (tan t) ew)))) (* (cos t) eh)) (* (* (sin t) ew) (cos (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs(((sin(atan((eh / (tan(t) * ew)))) * (cos(t) * eh)) + ((sin(t) * ew) * cos(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(((sin(atan((eh / (tan(t) * ew)))) * (cos(t) * eh)) + ((sin(t) * ew) * cos(atan(((eh / ew) / tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.sin(Math.atan((eh / (Math.tan(t) * ew)))) * (Math.cos(t) * eh)) + ((Math.sin(t) * ew) * Math.cos(Math.atan(((eh / ew) / Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs(((math.sin(math.atan((eh / (math.tan(t) * ew)))) * (math.cos(t) * eh)) + ((math.sin(t) * ew) * math.cos(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(sin(atan(Float64(eh / Float64(tan(t) * ew)))) * Float64(cos(t) * eh)) + Float64(Float64(sin(t) * ew) * cos(atan(Float64(Float64(eh / ew) / tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs(((sin(atan((eh / (tan(t) * ew)))) * (cos(t) * eh)) + ((sin(t) * ew) * cos(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right) \cdot \left(\cos t \cdot eh\right) + \left(\sin t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(fabs
(+
(*
(sin (atan (/ (* (fma -0.3333333333333333 (* t t) 1.0) (/ eh ew)) t)))
(* (cos t) eh))
(* (* (sin t) ew) (cos (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs(((sin(atan(((fma(-0.3333333333333333, (t * t), 1.0) * (eh / ew)) / t))) * (cos(t) * eh)) + ((sin(t) * ew) * cos(atan(((eh / ew) / tan(t)))))));
}
function code(eh, ew, t) return abs(Float64(Float64(sin(atan(Float64(Float64(fma(-0.3333333333333333, Float64(t * t), 1.0) * Float64(eh / ew)) / t))) * Float64(cos(t) * eh)) + Float64(Float64(sin(t) * ew) * cos(atan(Float64(Float64(eh / ew) / tan(t))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[N[ArcTan[N[(N[(N[(-0.3333333333333333 * N[(t * t), $MachinePrecision] + 1.0), $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, t \cdot t, 1\right) \cdot \frac{eh}{ew}}{t}\right) \cdot \left(\cos t \cdot eh\right) + \left(\sin t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
associate-/l*N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-/.f64N/A
Applied rewrites96.6%
Final simplification96.6%
(FPCore (eh ew t)
:precision binary64
(fabs
(+
(/ (* (sin t) ew) (sqrt (+ (pow (/ ew (/ eh (tan t))) -2.0) 1.0)))
(*
(sin (atan (/ (* (fma -0.3333333333333333 (* t t) 1.0) (/ eh ew)) t)))
(* (cos t) eh)))))
double code(double eh, double ew, double t) {
return fabs((((sin(t) * ew) / sqrt((pow((ew / (eh / tan(t))), -2.0) + 1.0))) + (sin(atan(((fma(-0.3333333333333333, (t * t), 1.0) * (eh / ew)) / t))) * (cos(t) * eh))));
}
function code(eh, ew, t) return abs(Float64(Float64(Float64(sin(t) * ew) / sqrt(Float64((Float64(ew / Float64(eh / tan(t))) ^ -2.0) + 1.0))) + Float64(sin(atan(Float64(Float64(fma(-0.3333333333333333, Float64(t * t), 1.0) * Float64(eh / ew)) / t))) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] / N[Sqrt[N[(N[Power[N[(ew / N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[ArcTan[N[(N[(N[(-0.3333333333333333 * N[(t * t), $MachinePrecision] + 1.0), $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\sin t \cdot ew}{\sqrt{{\left(\frac{ew}{\frac{eh}{\tan t}}\right)}^{-2} + 1}} + \sin \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.3333333333333333, t \cdot t, 1\right) \cdot \frac{eh}{ew}}{t}\right) \cdot \left(\cos t \cdot eh\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
associate-/l*N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-/.f64N/A
Applied rewrites96.6%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lower-/.f64N/A
lower-sqrt.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites96.6%
Final simplification96.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (* (/ (/ eh (sin t)) ew) (cos t)))) (t_2 (* (cos t) eh)))
(if (<= t -1.25e+59)
(fabs (* (cos t_1) (* (sin t) ew)))
(if (<= t 1.2e+38)
(fabs
(+
(* (sin (atan (/ eh (* t ew)))) t_2)
(* (* t ew) (cos (atan (/ (/ eh ew) (tan t)))))))
(fabs (* (sin t_1) t_2))))))
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 (t <= -1.25e+59) {
tmp = fabs((cos(t_1) * (sin(t) * ew)));
} else if (t <= 1.2e+38) {
tmp = fabs(((sin(atan((eh / (t * ew)))) * t_2) + ((t * ew) * cos(atan(((eh / ew) / tan(t)))))));
} else {
tmp = fabs((sin(t_1) * 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 = cos(t) * eh
if (t <= (-1.25d+59)) then
tmp = abs((cos(t_1) * (sin(t) * ew)))
else if (t <= 1.2d+38) then
tmp = abs(((sin(atan((eh / (t * ew)))) * t_2) + ((t * ew) * cos(atan(((eh / ew) / tan(t)))))))
else
tmp = abs((sin(t_1) * 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.cos(t) * eh;
double tmp;
if (t <= -1.25e+59) {
tmp = Math.abs((Math.cos(t_1) * (Math.sin(t) * ew)));
} else if (t <= 1.2e+38) {
tmp = Math.abs(((Math.sin(Math.atan((eh / (t * ew)))) * t_2) + ((t * ew) * Math.cos(Math.atan(((eh / ew) / Math.tan(t)))))));
} else {
tmp = Math.abs((Math.sin(t_1) * t_2));
}
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 t <= -1.25e+59: tmp = math.fabs((math.cos(t_1) * (math.sin(t) * ew))) elif t <= 1.2e+38: tmp = math.fabs(((math.sin(math.atan((eh / (t * ew)))) * t_2) + ((t * ew) * math.cos(math.atan(((eh / ew) / math.tan(t))))))) else: tmp = math.fabs((math.sin(t_1) * t_2)) 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 (t <= -1.25e+59) tmp = abs(Float64(cos(t_1) * Float64(sin(t) * ew))); elseif (t <= 1.2e+38) tmp = abs(Float64(Float64(sin(atan(Float64(eh / Float64(t * ew)))) * t_2) + Float64(Float64(t * ew) * cos(atan(Float64(Float64(eh / ew) / tan(t))))))); else tmp = abs(Float64(sin(t_1) * t_2)); 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 (t <= -1.25e+59) tmp = abs((cos(t_1) * (sin(t) * ew))); elseif (t <= 1.2e+38) tmp = abs(((sin(atan((eh / (t * ew)))) * t_2) + ((t * ew) * cos(atan(((eh / ew) / tan(t))))))); else tmp = abs((sin(t_1) * 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[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]}, If[LessEqual[t, -1.25e+59], N[Abs[N[(N[Cos[t$95$1], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 1.2e+38], N[Abs[N[(N[(N[Sin[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision] + N[(N[(t * ew), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sin[t$95$1], $MachinePrecision] * t$95$2), $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}\;t \leq -1.25 \cdot 10^{+59}:\\
\;\;\;\;\left|\cos t\_1 \cdot \left(\sin t \cdot ew\right)\right|\\
\mathbf{elif}\;t \leq 1.2 \cdot 10^{+38}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) \cdot t\_2 + \left(t \cdot ew\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin t\_1 \cdot t\_2\right|\\
\end{array}
\end{array}
if t < -1.2499999999999999e59Initial program 99.6%
Taylor expanded in eh around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites60.1%
if -1.2499999999999999e59 < t < 1.20000000000000009e38Initial program 99.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6494.0
Applied rewrites94.0%
if 1.20000000000000009e38 < t Initial program 99.6%
Taylor expanded in eh around inf
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 rewrites57.4%
Final simplification80.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (* (/ (/ eh (sin t)) ew) (cos t))))
(t_2 (fabs (* (sin t_1) (* (cos t) eh)))))
(if (<= eh -1.42e-24)
t_2
(if (<= eh 6.7e-171) (fabs (* (cos t_1) (* (sin t) ew))) t_2))))
double code(double eh, double ew, double t) {
double t_1 = atan((((eh / sin(t)) / ew) * cos(t)));
double t_2 = fabs((sin(t_1) * (cos(t) * eh)));
double tmp;
if (eh <= -1.42e-24) {
tmp = t_2;
} else if (eh <= 6.7e-171) {
tmp = fabs((cos(t_1) * (sin(t) * ew)));
} 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((sin(t_1) * (cos(t) * eh)))
if (eh <= (-1.42d-24)) then
tmp = t_2
else if (eh <= 6.7d-171) then
tmp = abs((cos(t_1) * (sin(t) * ew)))
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.sin(t_1) * (Math.cos(t) * eh)));
double tmp;
if (eh <= -1.42e-24) {
tmp = t_2;
} else if (eh <= 6.7e-171) {
tmp = Math.abs((Math.cos(t_1) * (Math.sin(t) * ew)));
} 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.sin(t_1) * (math.cos(t) * eh))) tmp = 0 if eh <= -1.42e-24: tmp = t_2 elif eh <= 6.7e-171: tmp = math.fabs((math.cos(t_1) * (math.sin(t) * ew))) 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(sin(t_1) * Float64(cos(t) * eh))) tmp = 0.0 if (eh <= -1.42e-24) tmp = t_2; elseif (eh <= 6.7e-171) tmp = abs(Float64(cos(t_1) * Float64(sin(t) * ew))); 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((sin(t_1) * (cos(t) * eh))); tmp = 0.0; if (eh <= -1.42e-24) tmp = t_2; elseif (eh <= 6.7e-171) tmp = abs((cos(t_1) * (sin(t) * ew))); 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[Sin[t$95$1], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.42e-24], t$95$2, If[LessEqual[eh, 6.7e-171], N[Abs[N[(N[Cos[t$95$1], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * ew), $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|\sin t\_1 \cdot \left(\cos t \cdot eh\right)\right|\\
\mathbf{if}\;eh \leq -1.42 \cdot 10^{-24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;eh \leq 6.7 \cdot 10^{-171}:\\
\;\;\;\;\left|\cos t\_1 \cdot \left(\sin t \cdot ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if eh < -1.42e-24 or 6.69999999999999961e-171 < eh Initial program 99.8%
Taylor expanded in eh around inf
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 rewrites80.6%
if -1.42e-24 < eh < 6.69999999999999961e-171Initial program 99.9%
Taylor expanded in eh around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(sin
(atan
(*
(/
(/
(fma
(fma
(-
(fma
(*
(fma
eh
0.0011904761904761906
(* -0.0032407407407407406 eh))
t)
t
(* -0.019444444444444445 eh)))
(* t t)
(* 0.16666666666666666 eh))
(* t t)
eh)
t)
ew)
(cos t))))
eh))))
(if (<= eh -2.8e-24)
t_1
(if (<= eh 4.4e-21)
(fabs (* (cos (atan (* (/ (/ eh (sin t)) ew) (cos t)))) (* (sin t) ew)))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((sin(atan((((fma(fma(-fma((fma(eh, 0.0011904761904761906, (-0.0032407407407407406 * eh)) * t), t, (-0.019444444444444445 * eh)), (t * t), (0.16666666666666666 * eh)), (t * t), eh) / t) / ew) * cos(t)))) * eh));
double tmp;
if (eh <= -2.8e-24) {
tmp = t_1;
} else if (eh <= 4.4e-21) {
tmp = fabs((cos(atan((((eh / sin(t)) / ew) * cos(t)))) * (sin(t) * ew)));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(sin(atan(Float64(Float64(Float64(fma(fma(Float64(-fma(Float64(fma(eh, 0.0011904761904761906, Float64(-0.0032407407407407406 * eh)) * t), t, Float64(-0.019444444444444445 * eh))), Float64(t * t), Float64(0.16666666666666666 * eh)), Float64(t * t), eh) / t) / ew) * cos(t)))) * eh)) tmp = 0.0 if (eh <= -2.8e-24) tmp = t_1; elseif (eh <= 4.4e-21) tmp = abs(Float64(cos(atan(Float64(Float64(Float64(eh / sin(t)) / ew) * cos(t)))) * Float64(sin(t) * ew))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(N[(N[((-N[(N[(N[(eh * 0.0011904761904761906 + N[(-0.0032407407407407406 * eh), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] * t + N[(-0.019444444444444445 * eh), $MachinePrecision]), $MachinePrecision]) * N[(t * t), $MachinePrecision] + N[(0.16666666666666666 * eh), $MachinePrecision]), $MachinePrecision] * N[(t * t), $MachinePrecision] + eh), $MachinePrecision] / t), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.8e-24], t$95$1, If[LessEqual[eh, 4.4e-21], 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[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\sin \tan^{-1} \left(\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(-\mathsf{fma}\left(\mathsf{fma}\left(eh, 0.0011904761904761906, -0.0032407407407407406 \cdot eh\right) \cdot t, t, -0.019444444444444445 \cdot eh\right), t \cdot t, 0.16666666666666666 \cdot eh\right), t \cdot t, eh\right)}{t}}{ew} \cdot \cos t\right) \cdot eh\right|\\
\mathbf{if}\;eh \leq -2.8 \cdot 10^{-24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 4.4 \cdot 10^{-21}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{\frac{eh}{\sin t}}{ew} \cdot \cos t\right) \cdot \left(\sin t \cdot ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2.8000000000000002e-24 or 4.4000000000000001e-21 < eh 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.f6459.7
Applied rewrites59.7%
Taylor expanded in t around 0
Applied rewrites59.9%
if -2.8000000000000002e-24 < eh < 4.4000000000000001e-21Initial program 99.8%
Taylor expanded in eh around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.5%
Final simplification64.1%
(FPCore (eh ew t)
:precision binary64
(fabs
(*
(sin
(atan
(*
(/
(/
(fma
(fma
(-
(fma
(* (fma eh 0.0011904761904761906 (* -0.0032407407407407406 eh)) t)
t
(* -0.019444444444444445 eh)))
(* t t)
(* 0.16666666666666666 eh))
(* t t)
eh)
t)
ew)
(cos t))))
eh)))
double code(double eh, double ew, double t) {
return fabs((sin(atan((((fma(fma(-fma((fma(eh, 0.0011904761904761906, (-0.0032407407407407406 * eh)) * t), t, (-0.019444444444444445 * eh)), (t * t), (0.16666666666666666 * eh)), (t * t), eh) / t) / ew) * cos(t)))) * eh));
}
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(Float64(Float64(fma(fma(Float64(-fma(Float64(fma(eh, 0.0011904761904761906, Float64(-0.0032407407407407406 * eh)) * t), t, Float64(-0.019444444444444445 * eh))), Float64(t * t), Float64(0.16666666666666666 * eh)), Float64(t * t), eh) / t) / ew) * cos(t)))) * eh)) end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(N[(N[((-N[(N[(N[(eh * 0.0011904761904761906 + N[(-0.0032407407407407406 * eh), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] * t + N[(-0.019444444444444445 * eh), $MachinePrecision]), $MachinePrecision]) * N[(t * t), $MachinePrecision] + N[(0.16666666666666666 * eh), $MachinePrecision]), $MachinePrecision] * N[(t * t), $MachinePrecision] + eh), $MachinePrecision] / t), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(-\mathsf{fma}\left(\mathsf{fma}\left(eh, 0.0011904761904761906, -0.0032407407407407406 \cdot eh\right) \cdot t, t, -0.019444444444444445 \cdot eh\right), t \cdot t, 0.16666666666666666 \cdot eh\right), t \cdot t, eh\right)}{t}}{ew} \cdot \cos t\right) \cdot 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.f6444.8
Applied rewrites44.8%
Taylor expanded in t around 0
Applied rewrites45.0%
Final simplification45.0%
(FPCore (eh ew t)
:precision binary64
(fabs
(*
(sin
(atan
(*
(/
(/
(fma
(fma (* 0.019444444444444445 eh) (* t t) (* 0.16666666666666666 eh))
(* t t)
eh)
t)
ew)
(cos t))))
eh)))
double code(double eh, double ew, double t) {
return fabs((sin(atan((((fma(fma((0.019444444444444445 * eh), (t * t), (0.16666666666666666 * eh)), (t * t), eh) / t) / ew) * cos(t)))) * eh));
}
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(Float64(Float64(fma(fma(Float64(0.019444444444444445 * eh), Float64(t * t), Float64(0.16666666666666666 * eh)), Float64(t * t), eh) / t) / ew) * cos(t)))) * eh)) end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(N[(N[(N[(0.019444444444444445 * eh), $MachinePrecision] * N[(t * t), $MachinePrecision] + N[(0.16666666666666666 * eh), $MachinePrecision]), $MachinePrecision] * N[(t * t), $MachinePrecision] + eh), $MachinePrecision] / t), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.019444444444444445 \cdot eh, t \cdot t, 0.16666666666666666 \cdot eh\right), t \cdot t, eh\right)}{t}}{ew} \cdot \cos t\right) \cdot 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.f6444.8
Applied rewrites44.8%
Taylor expanded in t around 0
Applied rewrites45.0%
Final simplification45.0%
(FPCore (eh ew t)
:precision binary64
(fabs
(*
(sin
(atan
(* (/ (/ (fma 0.16666666666666666 (* (* t t) eh) eh) t) ew) (cos t))))
eh)))
double code(double eh, double ew, double t) {
return fabs((sin(atan((((fma(0.16666666666666666, ((t * t) * eh), eh) / t) / ew) * cos(t)))) * eh));
}
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(Float64(Float64(fma(0.16666666666666666, Float64(Float64(t * t) * eh), eh) / t) / ew) * cos(t)))) * eh)) end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(N[(0.16666666666666666 * N[(N[(t * t), $MachinePrecision] * eh), $MachinePrecision] + eh), $MachinePrecision] / t), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\frac{\mathsf{fma}\left(0.16666666666666666, \left(t \cdot t\right) \cdot eh, eh\right)}{t}}{ew} \cdot \cos t\right) \cdot 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.f6444.8
Applied rewrites44.8%
Taylor expanded in t around 0
Applied rewrites45.0%
(FPCore (eh ew t)
:precision binary64
(fabs
(*
(sin
(atan (/ (* (fma (/ (* t t) ew) -0.3333333333333333 (/ 1.0 ew)) eh) t)))
eh)))
double code(double eh, double ew, double t) {
return fabs((sin(atan(((fma(((t * t) / ew), -0.3333333333333333, (1.0 / ew)) * eh) / t))) * eh));
}
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(Float64(fma(Float64(Float64(t * t) / ew), -0.3333333333333333, Float64(1.0 / ew)) * eh) / t))) * eh)) end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(N[(N[(t * t), $MachinePrecision] / ew), $MachinePrecision] * -0.3333333333333333 + N[(1.0 / ew), $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(\frac{t \cdot t}{ew}, -0.3333333333333333, \frac{1}{ew}\right) \cdot eh}{t}\right) \cdot 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.f6444.8
Applied rewrites44.8%
Taylor expanded in t around 0
Applied rewrites38.2%
Taylor expanded in eh around 0
Applied rewrites45.0%
(FPCore (eh ew t) :precision binary64 (fabs (* (sin (atan (* (/ eh t) (/ (fma (* t t) -0.3333333333333333 1.0) ew)))) eh)))
double code(double eh, double ew, double t) {
return fabs((sin(atan(((eh / t) * (fma((t * t), -0.3333333333333333, 1.0) / ew)))) * eh));
}
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(Float64(eh / t) * Float64(fma(Float64(t * t), -0.3333333333333333, 1.0) / ew)))) * eh)) end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[N[ArcTan[N[(N[(eh / t), $MachinePrecision] * N[(N[(N[(t * t), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{eh}{t} \cdot \frac{\mathsf{fma}\left(t \cdot t, -0.3333333333333333, 1\right)}{ew}\right) \cdot 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.f6444.8
Applied rewrites44.8%
Taylor expanded in t around 0
Applied rewrites38.2%
Taylor expanded in t around 0
Applied rewrites42.9%
Taylor expanded in ew around 0
Applied rewrites44.1%
Final simplification44.1%
(FPCore (eh ew t) :precision binary64 (fabs (* (sin (atan (/ (/ eh ew) t))) eh)))
double code(double eh, double ew, double t) {
return fabs((sin(atan(((eh / ew) / t))) * eh));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((sin(atan(((eh / ew) / t))) * eh))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.sin(Math.atan(((eh / ew) / t))) * eh));
}
def code(eh, ew, t): return math.fabs((math.sin(math.atan(((eh / ew) / t))) * eh))
function code(eh, ew, t) return abs(Float64(sin(atan(Float64(Float64(eh / ew) / t))) * eh)) end
function tmp = code(eh, ew, t) tmp = abs((sin(atan(((eh / ew) / t))) * eh)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{t}\right) \cdot 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.f6444.8
Applied rewrites44.8%
Taylor expanded in t around 0
Applied rewrites38.2%
Taylor expanded in t around 0
Applied rewrites42.9%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (/ (/ eh ew) t))) (fabs (* (/ t_1 (sqrt (+ (pow t_1 2.0) 1.0))) eh))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / t;
return fabs(((t_1 / sqrt((pow(t_1, 2.0) + 1.0))) * eh));
}
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 = (eh / ew) / t
code = abs(((t_1 / sqrt(((t_1 ** 2.0d0) + 1.0d0))) * eh))
end function
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / t;
return Math.abs(((t_1 / Math.sqrt((Math.pow(t_1, 2.0) + 1.0))) * eh));
}
def code(eh, ew, t): t_1 = (eh / ew) / t return math.fabs(((t_1 / math.sqrt((math.pow(t_1, 2.0) + 1.0))) * eh))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / t) return abs(Float64(Float64(t_1 / sqrt(Float64((t_1 ^ 2.0) + 1.0))) * eh)) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / t; tmp = abs(((t_1 / sqrt(((t_1 ^ 2.0) + 1.0))) * eh)); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / t), $MachinePrecision]}, N[Abs[N[(N[(t$95$1 / N[Sqrt[N[(N[Power[t$95$1, 2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{t}\\
\left|\frac{t\_1}{\sqrt{{t\_1}^{2} + 1}} \cdot eh\right|
\end{array}
\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.f6444.8
Applied rewrites44.8%
Taylor expanded in t around 0
Applied rewrites38.2%
Taylor expanded in t around 0
Applied rewrites42.9%
Applied rewrites15.6%
herbie shell --seed 2024331
(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))))))))