
(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 8 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 (* eh (/ (tan t) ew))))) (fabs (fma (* ew (cos t)) (cos t_1) (* (* (sin t) eh) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh * (tan(t) / ew)));
return fabs(fma((ew * cos(t)), cos(t_1), ((sin(t) * eh) * sin(t_1))));
}
function code(eh, ew, t) t_1 = atan(Float64(eh * Float64(tan(t) / ew))) return abs(fma(Float64(ew * cos(t)), cos(t_1), Float64(Float64(sin(t) * eh) * sin(t_1)))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\\
\left|\mathsf{fma}\left(ew \cdot \cos t, \cos t\_1, \left(\sin t \cdot eh\right) \cdot \sin t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* ew (cos t)) (cos (atan (* eh (/ (tan t) ew)))) (* (* (sin t) eh) (sin (atan (* (/ t ew) eh)))))))
double code(double eh, double ew, double t) {
return fabs(fma((ew * cos(t)), cos(atan((eh * (tan(t) / ew)))), ((sin(t) * eh) * sin(atan(((t / ew) * eh))))));
}
function code(eh, ew, t) return abs(fma(Float64(ew * cos(t)), cos(atan(Float64(eh * Float64(tan(t) / ew)))), Float64(Float64(sin(t) * eh) * sin(atan(Float64(Float64(t / ew) * eh)))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew \cdot \cos t, \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right), \left(\sin t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{t}{ew} \cdot eh\right)\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6498.5
Applied rewrites98.5%
Final simplification98.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (sin t) eh))
(t_2 (* ew (cos t)))
(t_3 (atan (* (/ t ew) eh)))
(t_4 (fabs (fma t_2 (cos t_3) (* t_1 (sin t_3))))))
(if (<= eh -4.2e-64)
t_4
(if (<= eh 6.4e-97)
(fabs
(/
(+ (* t_1 (* eh (/ (tan t) ew))) t_2)
(/ 1.0 (pow (+ 1.0 (pow (/ ew (* eh (tan t))) -2.0)) -0.5))))
t_4))))
double code(double eh, double ew, double t) {
double t_1 = sin(t) * eh;
double t_2 = ew * cos(t);
double t_3 = atan(((t / ew) * eh));
double t_4 = fabs(fma(t_2, cos(t_3), (t_1 * sin(t_3))));
double tmp;
if (eh <= -4.2e-64) {
tmp = t_4;
} else if (eh <= 6.4e-97) {
tmp = fabs((((t_1 * (eh * (tan(t) / ew))) + t_2) / (1.0 / pow((1.0 + pow((ew / (eh * tan(t))), -2.0)), -0.5))));
} else {
tmp = t_4;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(sin(t) * eh) t_2 = Float64(ew * cos(t)) t_3 = atan(Float64(Float64(t / ew) * eh)) t_4 = abs(fma(t_2, cos(t_3), Float64(t_1 * sin(t_3)))) tmp = 0.0 if (eh <= -4.2e-64) tmp = t_4; elseif (eh <= 6.4e-97) tmp = abs(Float64(Float64(Float64(t_1 * Float64(eh * Float64(tan(t) / ew))) + t_2) / Float64(1.0 / (Float64(1.0 + (Float64(ew / Float64(eh * tan(t))) ^ -2.0)) ^ -0.5)))); else tmp = t_4; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Abs[N[(t$95$2 * N[Cos[t$95$3], $MachinePrecision] + N[(t$95$1 * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -4.2e-64], t$95$4, If[LessEqual[eh, 6.4e-97], N[Abs[N[(N[(N[(t$95$1 * N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision] / N[(1.0 / N[Power[N[(1.0 + N[Power[N[(ew / N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin t \cdot eh\\
t_2 := ew \cdot \cos t\\
t_3 := \tan^{-1} \left(\frac{t}{ew} \cdot eh\right)\\
t_4 := \left|\mathsf{fma}\left(t\_2, \cos t\_3, t\_1 \cdot \sin t\_3\right)\right|\\
\mathbf{if}\;eh \leq -4.2 \cdot 10^{-64}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;eh \leq 6.4 \cdot 10^{-97}:\\
\;\;\;\;\left|\frac{t\_1 \cdot \left(eh \cdot \frac{\tan t}{ew}\right) + t\_2}{\frac{1}{{\left(1 + {\left(\frac{ew}{eh \cdot \tan t}\right)}^{-2}\right)}^{-0.5}}}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if eh < -4.20000000000000023e-64 or 6.39999999999999961e-97 < eh Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6498.8
Applied rewrites98.8%
Taylor expanded in t around 0
associate-/l*N/A
*-commutativeN/A
*-rgt-identityN/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6493.2
Applied rewrites93.2%
if -4.20000000000000023e-64 < eh < 6.39999999999999961e-97Initial program 99.8%
Applied rewrites89.8%
Applied rewrites98.8%
Final simplification95.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (sin t) eh))
(t_2 (* ew (cos t)))
(t_3 (atan (* (/ t ew) eh)))
(t_4 (fabs (fma t_2 (cos t_3) (* t_1 (sin t_3))))))
(if (<= eh -1e-144)
t_4
(if (<= eh 2.5e-98)
(*
(fabs (fma (/ t_1 ew) (* eh (tan t)) t_2))
(cos (atan (* eh (/ (tan t) ew)))))
t_4))))
double code(double eh, double ew, double t) {
double t_1 = sin(t) * eh;
double t_2 = ew * cos(t);
double t_3 = atan(((t / ew) * eh));
double t_4 = fabs(fma(t_2, cos(t_3), (t_1 * sin(t_3))));
double tmp;
if (eh <= -1e-144) {
tmp = t_4;
} else if (eh <= 2.5e-98) {
tmp = fabs(fma((t_1 / ew), (eh * tan(t)), t_2)) * cos(atan((eh * (tan(t) / ew))));
} else {
tmp = t_4;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(sin(t) * eh) t_2 = Float64(ew * cos(t)) t_3 = atan(Float64(Float64(t / ew) * eh)) t_4 = abs(fma(t_2, cos(t_3), Float64(t_1 * sin(t_3)))) tmp = 0.0 if (eh <= -1e-144) tmp = t_4; elseif (eh <= 2.5e-98) tmp = Float64(abs(fma(Float64(t_1 / ew), Float64(eh * tan(t)), t_2)) * cos(atan(Float64(eh * Float64(tan(t) / ew))))); else tmp = t_4; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Abs[N[(t$95$2 * N[Cos[t$95$3], $MachinePrecision] + N[(t$95$1 * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1e-144], t$95$4, If[LessEqual[eh, 2.5e-98], N[(N[Abs[N[(N[(t$95$1 / ew), $MachinePrecision] * N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin t \cdot eh\\
t_2 := ew \cdot \cos t\\
t_3 := \tan^{-1} \left(\frac{t}{ew} \cdot eh\right)\\
t_4 := \left|\mathsf{fma}\left(t\_2, \cos t\_3, t\_1 \cdot \sin t\_3\right)\right|\\
\mathbf{if}\;eh \leq -1 \cdot 10^{-144}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;eh \leq 2.5 \cdot 10^{-98}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{t\_1}{ew}, eh \cdot \tan t, t\_2\right)\right| \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if eh < -9.9999999999999995e-145 or 2.50000000000000009e-98 < eh Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6498.9
Applied rewrites98.9%
Taylor expanded in t around 0
associate-/l*N/A
*-commutativeN/A
*-rgt-identityN/A
associate-*r/N/A
lower-*.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6493.2
Applied rewrites93.2%
if -9.9999999999999995e-145 < eh < 2.50000000000000009e-98Initial program 99.8%
Applied rewrites99.8%
Applied rewrites92.5%
Final simplification93.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (sin t) eh))
(t_2
(*
(fabs (fma (/ t_1 ew) (* eh (tan t)) (* ew (cos t))))
(cos (atan (* eh (/ (tan t) ew)))))))
(if (<= ew -1.66e-217)
t_2
(if (<= ew 1.35e-71) (fabs (* t_1 (sin (atan (* (/ t ew) eh))))) t_2))))
double code(double eh, double ew, double t) {
double t_1 = sin(t) * eh;
double t_2 = fabs(fma((t_1 / ew), (eh * tan(t)), (ew * cos(t)))) * cos(atan((eh * (tan(t) / ew))));
double tmp;
if (ew <= -1.66e-217) {
tmp = t_2;
} else if (ew <= 1.35e-71) {
tmp = fabs((t_1 * sin(atan(((t / ew) * eh)))));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(sin(t) * eh) t_2 = Float64(abs(fma(Float64(t_1 / ew), Float64(eh * tan(t)), Float64(ew * cos(t)))) * cos(atan(Float64(eh * Float64(tan(t) / ew))))) tmp = 0.0 if (ew <= -1.66e-217) tmp = t_2; elseif (ew <= 1.35e-71) tmp = abs(Float64(t_1 * sin(atan(Float64(Float64(t / ew) * eh))))); else tmp = t_2; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[(N[Abs[N[(N[(t$95$1 / ew), $MachinePrecision] * N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] + N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -1.66e-217], t$95$2, If[LessEqual[ew, 1.35e-71], N[Abs[N[(t$95$1 * N[Sin[N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin t \cdot eh\\
t_2 := \left|\mathsf{fma}\left(\frac{t\_1}{ew}, eh \cdot \tan t, ew \cdot \cos t\right)\right| \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\\
\mathbf{if}\;ew \leq -1.66 \cdot 10^{-217}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;ew \leq 1.35 \cdot 10^{-71}:\\
\;\;\;\;\left|t\_1 \cdot \sin \tan^{-1} \left(\frac{t}{ew} \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if ew < -1.66e-217 or 1.3500000000000001e-71 < ew Initial program 99.8%
Applied rewrites99.8%
Applied rewrites80.4%
if -1.66e-217 < ew < 1.3500000000000001e-71Initial program 99.7%
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-sin.f6481.6
Applied rewrites81.6%
Taylor expanded in t around 0
Applied rewrites81.7%
Final simplification80.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (fabs (* (- ew) (cos t))) (cos (atan (* eh (/ (tan t) ew)))))))
(if (<= ew -1.66e-217)
t_1
(if (<= ew 2.2e-65)
(fabs (* (* (sin t) eh) (sin (atan (* (/ t ew) eh)))))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((-ew * cos(t))) * cos(atan((eh * (tan(t) / ew))));
double tmp;
if (ew <= -1.66e-217) {
tmp = t_1;
} else if (ew <= 2.2e-65) {
tmp = fabs(((sin(t) * eh) * sin(atan(((t / ew) * eh)))));
} 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))) * cos(atan((eh * (tan(t) / ew))))
if (ew <= (-1.66d-217)) then
tmp = t_1
else if (ew <= 2.2d-65) then
tmp = abs(((sin(t) * eh) * sin(atan(((t / ew) * eh)))))
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))) * Math.cos(Math.atan((eh * (Math.tan(t) / ew))));
double tmp;
if (ew <= -1.66e-217) {
tmp = t_1;
} else if (ew <= 2.2e-65) {
tmp = Math.abs(((Math.sin(t) * eh) * Math.sin(Math.atan(((t / ew) * eh)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((-ew * math.cos(t))) * math.cos(math.atan((eh * (math.tan(t) / ew)))) tmp = 0 if ew <= -1.66e-217: tmp = t_1 elif ew <= 2.2e-65: tmp = math.fabs(((math.sin(t) * eh) * math.sin(math.atan(((t / ew) * eh))))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = Float64(abs(Float64(Float64(-ew) * cos(t))) * cos(atan(Float64(eh * Float64(tan(t) / ew))))) tmp = 0.0 if (ew <= -1.66e-217) tmp = t_1; elseif (ew <= 2.2e-65) tmp = abs(Float64(Float64(sin(t) * eh) * sin(atan(Float64(Float64(t / ew) * eh))))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((-ew * cos(t))) * cos(atan((eh * (tan(t) / ew)))); tmp = 0.0; if (ew <= -1.66e-217) tmp = t_1; elseif (ew <= 2.2e-65) tmp = abs(((sin(t) * eh) * sin(atan(((t / ew) * eh))))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Abs[N[((-ew) * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -1.66e-217], t$95$1, If[LessEqual[ew, 2.2e-65], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\left(-ew\right) \cdot \cos t\right| \cdot \cos \tan^{-1} \left(eh \cdot \frac{\tan t}{ew}\right)\\
\mathbf{if}\;ew \leq -1.66 \cdot 10^{-217}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 2.2 \cdot 10^{-65}:\\
\;\;\;\;\left|\left(\sin t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{t}{ew} \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -1.66e-217 or 2.20000000000000021e-65 < ew Initial program 99.8%
Applied rewrites80.4%
Taylor expanded in t around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites39.9%
Applied rewrites39.9%
Taylor expanded in ew around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6479.2
Applied rewrites79.2%
if -1.66e-217 < ew < 2.20000000000000021e-65Initial program 99.7%
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-sin.f6481.5
Applied rewrites81.5%
Taylor expanded in t around 0
Applied rewrites81.5%
Final simplification79.9%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (fabs (* (* (sin t) eh) (sin (atan (* (/ t ew) eh))))))) (if (<= t -4.9e-14) t_1 (if (<= t 1.5e-8) (fabs (/ ew 1.0)) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((sin(t) * eh) * sin(atan(((t / ew) * eh)))));
double tmp;
if (t <= -4.9e-14) {
tmp = t_1;
} else if (t <= 1.5e-8) {
tmp = fabs((ew / 1.0));
} 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(((sin(t) * eh) * sin(atan(((t / ew) * eh)))))
if (t <= (-4.9d-14)) then
tmp = t_1
else if (t <= 1.5d-8) then
tmp = abs((ew / 1.0d0))
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.sin(t) * eh) * Math.sin(Math.atan(((t / ew) * eh)))));
double tmp;
if (t <= -4.9e-14) {
tmp = t_1;
} else if (t <= 1.5e-8) {
tmp = Math.abs((ew / 1.0));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs(((math.sin(t) * eh) * math.sin(math.atan(((t / ew) * eh))))) tmp = 0 if t <= -4.9e-14: tmp = t_1 elif t <= 1.5e-8: tmp = math.fabs((ew / 1.0)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(Float64(sin(t) * eh) * sin(atan(Float64(Float64(t / ew) * eh))))) tmp = 0.0 if (t <= -4.9e-14) tmp = t_1; elseif (t <= 1.5e-8) tmp = abs(Float64(ew / 1.0)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs(((sin(t) * eh) * sin(atan(((t / ew) * eh))))); tmp = 0.0; if (t <= -4.9e-14) tmp = t_1; elseif (t <= 1.5e-8) tmp = abs((ew / 1.0)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -4.9e-14], t$95$1, If[LessEqual[t, 1.5e-8], N[Abs[N[(ew / 1.0), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\left(\sin t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{t}{ew} \cdot eh\right)\right|\\
\mathbf{if}\;t \leq -4.9 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.5 \cdot 10^{-8}:\\
\;\;\;\;\left|\frac{ew}{1}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.89999999999999995e-14 or 1.49999999999999987e-8 < t Initial program 99.6%
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-sin.f6452.8
Applied rewrites52.8%
Taylor expanded in t around 0
Applied rewrites53.2%
if -4.89999999999999995e-14 < t < 1.49999999999999987e-8Initial program 100.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in t around 0
Applied rewrites73.1%
Applied rewrites72.9%
Taylor expanded in ew around inf
Applied rewrites73.3%
Final simplification62.5%
(FPCore (eh ew t) :precision binary64 (fabs (/ ew 1.0)))
double code(double eh, double ew, double t) {
return fabs((ew / 1.0));
}
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 / 1.0d0))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew / 1.0));
}
def code(eh, ew, t): return math.fabs((ew / 1.0))
function code(eh, ew, t) return abs(Float64(ew / 1.0)) end
function tmp = code(eh, ew, t) tmp = abs((ew / 1.0)); end
code[eh_, ew_, t_] := N[Abs[N[(ew / 1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew}{1}\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites40.6%
Taylor expanded in t around 0
Applied rewrites39.4%
Applied rewrites38.7%
Taylor expanded in ew around inf
Applied rewrites40.8%
herbie shell --seed 2024284
(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)))))))