
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (* (/ (tan t) ew) eh)))) (fabs (fma (* (sin t_1) (- (sin t))) (- eh) (* (cos t_1) (* (cos t) ew))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((tan(t) / ew) * eh));
return fabs(fma((sin(t_1) * -sin(t)), -eh, (cos(t_1) * (cos(t) * ew))));
}
function code(eh, ew, t) t_1 = atan(Float64(Float64(tan(t) / ew) * eh)) return abs(fma(Float64(sin(t_1) * Float64(-sin(t))), Float64(-eh), Float64(cos(t_1) * Float64(cos(t) * ew)))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[Sin[t$95$1], $MachinePrecision] * (-N[Sin[t], $MachinePrecision])), $MachinePrecision] * (-eh) + N[(N[Cos[t$95$1], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\\
\left|\mathsf{fma}\left(\sin t\_1 \cdot \left(-\sin t\right), -eh, \cos t\_1 \cdot \left(\cos t \cdot ew\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (tan t) ew) eh)) (t_2 (* (cos t) ew)) (t_3 (atan t_1)))
(if (or (<= eh -1.8e-45) (not (<= eh 1.5e-158)))
(fabs
(fma
(* (sin t_3) (- (sin t)))
(- eh)
(* (cos (atan (* (/ t ew) eh))) t_2)))
(fabs (/ (+ (* (* (sin t) eh) t_1) t_2) (pow (cos t_3) -1.0))))))
double code(double eh, double ew, double t) {
double t_1 = (tan(t) / ew) * eh;
double t_2 = cos(t) * ew;
double t_3 = atan(t_1);
double tmp;
if ((eh <= -1.8e-45) || !(eh <= 1.5e-158)) {
tmp = fabs(fma((sin(t_3) * -sin(t)), -eh, (cos(atan(((t / ew) * eh))) * t_2)));
} else {
tmp = fabs(((((sin(t) * eh) * t_1) + t_2) / pow(cos(t_3), -1.0)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(tan(t) / ew) * eh) t_2 = Float64(cos(t) * ew) t_3 = atan(t_1) tmp = 0.0 if ((eh <= -1.8e-45) || !(eh <= 1.5e-158)) tmp = abs(fma(Float64(sin(t_3) * Float64(-sin(t))), Float64(-eh), Float64(cos(atan(Float64(Float64(t / ew) * eh))) * t_2))); else tmp = abs(Float64(Float64(Float64(Float64(sin(t) * eh) * t_1) + t_2) / (cos(t_3) ^ -1.0))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[t$95$1], $MachinePrecision]}, If[Or[LessEqual[eh, -1.8e-45], N[Not[LessEqual[eh, 1.5e-158]], $MachinePrecision]], N[Abs[N[(N[(N[Sin[t$95$3], $MachinePrecision] * (-N[Sin[t], $MachinePrecision])), $MachinePrecision] * (-eh) + N[(N[Cos[N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * t$95$1), $MachinePrecision] + t$95$2), $MachinePrecision] / N[Power[N[Cos[t$95$3], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew} \cdot eh\\
t_2 := \cos t \cdot ew\\
t_3 := \tan^{-1} t\_1\\
\mathbf{if}\;eh \leq -1.8 \cdot 10^{-45} \lor \neg \left(eh \leq 1.5 \cdot 10^{-158}\right):\\
\;\;\;\;\left|\mathsf{fma}\left(\sin t\_3 \cdot \left(-\sin t\right), -eh, \cos \tan^{-1} \left(\frac{t}{ew} \cdot eh\right) \cdot t\_2\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(\sin t \cdot eh\right) \cdot t\_1 + t\_2}{{\cos t\_3}^{-1}}\right|\\
\end{array}
\end{array}
if eh < -1.8e-45 or 1.5e-158 < eh Initial program 99.8%
Applied rewrites99.9%
Taylor expanded in t around 0
lower-/.f6494.7
Applied rewrites94.7%
if -1.8e-45 < eh < 1.5e-158Initial program 99.8%
Applied rewrites96.6%
Final simplification95.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (tan t) ew) eh)) (t_2 (* (cos t) ew)) (t_3 (atan t_1)))
(if (or (<= eh -1.8e-45) (not (<= eh 1.7e-158)))
(fabs
(fma
(* (sin t_3) (- (sin t)))
(- eh)
(/ t_2 (sqrt (+ (pow (* (/ t ew) eh) 2.0) 1.0)))))
(fabs (/ (+ (* (* (sin t) eh) t_1) t_2) (pow (cos t_3) -1.0))))))
double code(double eh, double ew, double t) {
double t_1 = (tan(t) / ew) * eh;
double t_2 = cos(t) * ew;
double t_3 = atan(t_1);
double tmp;
if ((eh <= -1.8e-45) || !(eh <= 1.7e-158)) {
tmp = fabs(fma((sin(t_3) * -sin(t)), -eh, (t_2 / sqrt((pow(((t / ew) * eh), 2.0) + 1.0)))));
} else {
tmp = fabs(((((sin(t) * eh) * t_1) + t_2) / pow(cos(t_3), -1.0)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(tan(t) / ew) * eh) t_2 = Float64(cos(t) * ew) t_3 = atan(t_1) tmp = 0.0 if ((eh <= -1.8e-45) || !(eh <= 1.7e-158)) tmp = abs(fma(Float64(sin(t_3) * Float64(-sin(t))), Float64(-eh), Float64(t_2 / sqrt(Float64((Float64(Float64(t / ew) * eh) ^ 2.0) + 1.0))))); else tmp = abs(Float64(Float64(Float64(Float64(sin(t) * eh) * t_1) + t_2) / (cos(t_3) ^ -1.0))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[t$95$1], $MachinePrecision]}, If[Or[LessEqual[eh, -1.8e-45], N[Not[LessEqual[eh, 1.7e-158]], $MachinePrecision]], N[Abs[N[(N[(N[Sin[t$95$3], $MachinePrecision] * (-N[Sin[t], $MachinePrecision])), $MachinePrecision] * (-eh) + N[(t$95$2 / N[Sqrt[N[(N[Power[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * t$95$1), $MachinePrecision] + t$95$2), $MachinePrecision] / N[Power[N[Cos[t$95$3], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew} \cdot eh\\
t_2 := \cos t \cdot ew\\
t_3 := \tan^{-1} t\_1\\
\mathbf{if}\;eh \leq -1.8 \cdot 10^{-45} \lor \neg \left(eh \leq 1.7 \cdot 10^{-158}\right):\\
\;\;\;\;\left|\mathsf{fma}\left(\sin t\_3 \cdot \left(-\sin t\right), -eh, \frac{t\_2}{\sqrt{{\left(\frac{t}{ew} \cdot eh\right)}^{2} + 1}}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(\sin t \cdot eh\right) \cdot t\_1 + t\_2}{{\cos t\_3}^{-1}}\right|\\
\end{array}
\end{array}
if eh < -1.8e-45 or 1.7e-158 < eh Initial program 99.8%
Applied rewrites99.9%
Taylor expanded in t around 0
lower-/.f6494.7
Applied rewrites94.7%
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.f6494.5
Applied rewrites94.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6494.5
Applied rewrites94.5%
if -1.8e-45 < eh < 1.7e-158Initial program 99.8%
Applied rewrites96.6%
Final simplification95.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(* (- eh) (sin t))
(sin
(atan
(*
(fma -0.3333333333333333 (/ (* (* t t) eh) ew) (/ (- eh) ew))
t))))))
(t_2 (* (/ (tan t) ew) eh)))
(if (<= eh -3.4e+53)
t_1
(if (<= eh 8.5e+17)
(fabs
(/
(+ (* (* (sin t) eh) t_2) (* (cos t) ew))
(pow (cos (atan t_2)) -1.0)))
(if (<= eh 2.6e+263)
(fabs
(-
(* (* eh (sin t)) (sin (atan (* (/ (- t) ew) eh))))
(*
(fma (* -0.5 ew) (* t t) ew)
(cos (atan (/ (* eh (tan t)) (- ew)))))))
t_1)))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((-eh * sin(t)) * sin(atan((fma(-0.3333333333333333, (((t * t) * eh) / ew), (-eh / ew)) * t)))));
double t_2 = (tan(t) / ew) * eh;
double tmp;
if (eh <= -3.4e+53) {
tmp = t_1;
} else if (eh <= 8.5e+17) {
tmp = fabs(((((sin(t) * eh) * t_2) + (cos(t) * ew)) / pow(cos(atan(t_2)), -1.0)));
} else if (eh <= 2.6e+263) {
tmp = fabs((((eh * sin(t)) * sin(atan(((-t / ew) * eh)))) - (fma((-0.5 * ew), (t * t), ew) * cos(atan(((eh * tan(t)) / -ew))))));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(Float64(Float64(-eh) * sin(t)) * sin(atan(Float64(fma(-0.3333333333333333, Float64(Float64(Float64(t * t) * eh) / ew), Float64(Float64(-eh) / ew)) * t))))) t_2 = Float64(Float64(tan(t) / ew) * eh) tmp = 0.0 if (eh <= -3.4e+53) tmp = t_1; elseif (eh <= 8.5e+17) tmp = abs(Float64(Float64(Float64(Float64(sin(t) * eh) * t_2) + Float64(cos(t) * ew)) / (cos(atan(t_2)) ^ -1.0))); elseif (eh <= 2.6e+263) tmp = abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-t) / ew) * eh)))) - Float64(fma(Float64(-0.5 * ew), Float64(t * t), ew) * cos(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(-0.3333333333333333 * N[(N[(N[(t * t), $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision] + N[((-eh) / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]}, If[LessEqual[eh, -3.4e+53], t$95$1, If[LessEqual[eh, 8.5e+17], N[Abs[N[(N[(N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * t$95$2), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[N[ArcTan[t$95$2], $MachinePrecision]], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 2.6e+263], N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-t) / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(-0.5 * ew), $MachinePrecision] * N[(t * t), $MachinePrecision] + ew), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\left(\left(-eh\right) \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\mathsf{fma}\left(-0.3333333333333333, \frac{\left(t \cdot t\right) \cdot eh}{ew}, \frac{-eh}{ew}\right) \cdot t\right)\right|\\
t_2 := \frac{\tan t}{ew} \cdot eh\\
\mathbf{if}\;eh \leq -3.4 \cdot 10^{+53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 8.5 \cdot 10^{+17}:\\
\;\;\;\;\left|\frac{\left(\sin t \cdot eh\right) \cdot t\_2 + \cos t \cdot ew}{{\cos \tan^{-1} t\_2}^{-1}}\right|\\
\mathbf{elif}\;eh \leq 2.6 \cdot 10^{+263}:\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-t}{ew} \cdot eh\right) - \mathsf{fma}\left(-0.5 \cdot ew, t \cdot t, ew\right) \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -3.39999999999999998e53 or 2.6000000000000002e263 < eh Initial program 99.9%
Taylor expanded in eh around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in t around 0
Applied rewrites80.6%
if -3.39999999999999998e53 < eh < 8.5e17Initial program 99.8%
Applied rewrites86.4%
if 8.5e17 < eh < 2.6000000000000002e263Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in t around 0
associate-*r*N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6477.3
Applied rewrites77.3%
Final simplification83.3%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* eh (sin t)) (sin (atan (* (/ (- t) ew) eh)))) (* (* ew (cos t)) (cos (atan (/ (* eh (tan t)) (- ew))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * sin(t)) * sin(atan(((-t / ew) * eh)))) - ((ew * cos(t)) * cos(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 = abs((((eh * sin(t)) * sin(atan(((-t / ew) * eh)))) - ((ew * cos(t)) * cos(atan(((eh * tan(t)) / -ew))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((-t / ew) * eh)))) - ((ew * Math.cos(t)) * Math.cos(Math.atan(((eh * Math.tan(t)) / -ew))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((-t / ew) * eh)))) - ((ew * math.cos(t)) * math.cos(math.atan(((eh * math.tan(t)) / -ew))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-t) / ew) * eh)))) - Float64(Float64(ew * cos(t)) * cos(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * sin(t)) * sin(atan(((-t / ew) * eh)))) - ((ew * cos(t)) * cos(atan(((eh * tan(t)) / -ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-t) / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-t}{ew} \cdot eh\right) - \left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(* (- eh) (sin t))
(sin
(atan
(*
(fma -0.3333333333333333 (/ (* (* t t) eh) ew) (/ (- eh) ew))
t)))))))
(if (<= eh -3.4e+53)
t_1
(if (<= eh 8.5e+17)
(fabs (* (cos t) ew))
(if (<= eh 2.6e+263)
(fabs
(-
(* (* eh (sin t)) (sin (atan (* (/ (- t) ew) eh))))
(*
(fma (* -0.5 ew) (* t t) ew)
(cos (atan (/ (* eh (tan t)) (- ew)))))))
t_1)))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((-eh * sin(t)) * sin(atan((fma(-0.3333333333333333, (((t * t) * eh) / ew), (-eh / ew)) * t)))));
double tmp;
if (eh <= -3.4e+53) {
tmp = t_1;
} else if (eh <= 8.5e+17) {
tmp = fabs((cos(t) * ew));
} else if (eh <= 2.6e+263) {
tmp = fabs((((eh * sin(t)) * sin(atan(((-t / ew) * eh)))) - (fma((-0.5 * ew), (t * t), ew) * cos(atan(((eh * tan(t)) / -ew))))));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(Float64(Float64(-eh) * sin(t)) * sin(atan(Float64(fma(-0.3333333333333333, Float64(Float64(Float64(t * t) * eh) / ew), Float64(Float64(-eh) / ew)) * t))))) tmp = 0.0 if (eh <= -3.4e+53) tmp = t_1; elseif (eh <= 8.5e+17) tmp = abs(Float64(cos(t) * ew)); elseif (eh <= 2.6e+263) tmp = abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-t) / ew) * eh)))) - Float64(fma(Float64(-0.5 * ew), Float64(t * t), ew) * cos(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(-0.3333333333333333 * N[(N[(N[(t * t), $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision] + N[((-eh) / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -3.4e+53], t$95$1, If[LessEqual[eh, 8.5e+17], N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 2.6e+263], N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-t) / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(-0.5 * ew), $MachinePrecision] * N[(t * t), $MachinePrecision] + ew), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\left(\left(-eh\right) \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\mathsf{fma}\left(-0.3333333333333333, \frac{\left(t \cdot t\right) \cdot eh}{ew}, \frac{-eh}{ew}\right) \cdot t\right)\right|\\
\mathbf{if}\;eh \leq -3.4 \cdot 10^{+53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 8.5 \cdot 10^{+17}:\\
\;\;\;\;\left|\cos t \cdot ew\right|\\
\mathbf{elif}\;eh \leq 2.6 \cdot 10^{+263}:\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{-t}{ew} \cdot eh\right) - \mathsf{fma}\left(-0.5 \cdot ew, t \cdot t, ew\right) \cdot \cos \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -3.39999999999999998e53 or 2.6000000000000002e263 < eh Initial program 99.9%
Taylor expanded in eh around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in t around 0
Applied rewrites80.6%
if -3.39999999999999998e53 < eh < 8.5e17Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6488.3
Applied rewrites88.3%
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.f6488.0
Applied rewrites88.0%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6485.1
Applied rewrites85.1%
if 8.5e17 < eh < 2.6000000000000002e263Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in t around 0
associate-*r*N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6477.3
Applied rewrites77.3%
Final simplification82.6%
(FPCore (eh ew t)
:precision binary64
(if (or (<= eh -3.4e+53) (not (<= eh 1.15e+14)))
(fabs
(*
(* (- eh) (sin t))
(sin
(atan
(* (fma -0.3333333333333333 (/ (* (* t t) eh) ew) (/ (- eh) ew)) t)))))
(fabs (* (cos t) ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -3.4e+53) || !(eh <= 1.15e+14)) {
tmp = fabs(((-eh * sin(t)) * sin(atan((fma(-0.3333333333333333, (((t * t) * eh) / ew), (-eh / ew)) * t)))));
} else {
tmp = fabs((cos(t) * ew));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((eh <= -3.4e+53) || !(eh <= 1.15e+14)) tmp = abs(Float64(Float64(Float64(-eh) * sin(t)) * sin(atan(Float64(fma(-0.3333333333333333, Float64(Float64(Float64(t * t) * eh) / ew), Float64(Float64(-eh) / ew)) * t))))); else tmp = abs(Float64(cos(t) * ew)); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -3.4e+53], N[Not[LessEqual[eh, 1.15e+14]], $MachinePrecision]], N[Abs[N[(N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(-0.3333333333333333 * N[(N[(N[(t * t), $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision] + N[((-eh) / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -3.4 \cdot 10^{+53} \lor \neg \left(eh \leq 1.15 \cdot 10^{+14}\right):\\
\;\;\;\;\left|\left(\left(-eh\right) \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\mathsf{fma}\left(-0.3333333333333333, \frac{\left(t \cdot t\right) \cdot eh}{ew}, \frac{-eh}{ew}\right) \cdot t\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos t \cdot ew\right|\\
\end{array}
\end{array}
if eh < -3.39999999999999998e53 or 1.15e14 < eh Initial program 99.8%
Taylor expanded in eh around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites72.9%
Taylor expanded in t around 0
Applied rewrites73.1%
if -3.39999999999999998e53 < eh < 1.15e14Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6488.2
Applied rewrites88.2%
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.f6488.0
Applied rewrites88.0%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6485.6
Applied rewrites85.6%
Final simplification80.2%
(FPCore (eh ew t) :precision binary64 (fabs (* (cos t) ew)))
double code(double eh, double ew, double t) {
return fabs((cos(t) * ew));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((cos(t) * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.cos(t) * ew));
}
def code(eh, ew, t): return math.fabs((math.cos(t) * ew))
function code(eh, ew, t) return abs(Float64(cos(t) * ew)) end
function tmp = code(eh, ew, t) tmp = abs((cos(t) * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\cos t \cdot ew\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6491.7
Applied rewrites91.7%
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.f6491.5
Applied rewrites91.5%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6462.1
Applied rewrites62.1%
(FPCore (eh ew t) :precision binary64 (fabs (* 1.0 ew)))
double code(double eh, double ew, double t) {
return fabs((1.0 * 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((1.0d0 * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((1.0 * ew));
}
def code(eh, ew, t): return math.fabs((1.0 * ew))
function code(eh, ew, t) return abs(Float64(1.0 * ew)) end
function tmp = code(eh, ew, t) tmp = abs((1.0 * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(1.0 * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|1 \cdot ew\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.6%
Applied rewrites42.3%
Taylor expanded in eh around 0
Applied rewrites42.8%
herbie shell --seed 2024327
(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)))))))