
(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 (* (/ (tan t) ew) eh)))) (fabs (fma (* (sin t_1) eh) (sin t) (* (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) * eh), sin(t), (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) * eh), sin(t), 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] * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + 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 eh, \sin t, \cos t\_1 \cdot \left(\cos t \cdot ew\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* (sin (atan (* (/ eh ew) t))) eh) (sin t) (* (cos (atan (* (/ (tan t) ew) eh))) (* (cos t) ew)))))
double code(double eh, double ew, double t) {
return fabs(fma((sin(atan(((eh / ew) * t))) * eh), sin(t), (cos(atan(((tan(t) / ew) * eh))) * (cos(t) * ew))));
}
function code(eh, ew, t) return abs(fma(Float64(sin(atan(Float64(Float64(eh / ew) * t))) * eh), sin(t), Float64(cos(atan(Float64(Float64(tan(t) / ew) * eh))) * Float64(cos(t) * ew)))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\sin \tan^{-1} \left(\frac{eh}{ew} \cdot t\right) \cdot eh, \sin t, \cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\cos t \cdot ew\right)\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in t around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(* (sin t) eh)
(sin
(atan
(*
(fma (* (* 0.3333333333333333 (/ eh ew)) t) t (/ eh ew))
t))))))
(t_2 (* (/ t ew) eh)))
(if (<= eh -4.2e+191)
t_1
(if (<= eh 2.7e+160)
(fabs
(fma
(/ (* t_2 eh) (sqrt (+ 1.0 (pow t_2 2.0))))
(sin t)
(* (cos (atan (* (/ (tan t) ew) eh))) (* (cos t) ew))))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((sin(t) * eh) * sin(atan((fma(((0.3333333333333333 * (eh / ew)) * t), t, (eh / ew)) * t)))));
double t_2 = (t / ew) * eh;
double tmp;
if (eh <= -4.2e+191) {
tmp = t_1;
} else if (eh <= 2.7e+160) {
tmp = fabs(fma(((t_2 * eh) / sqrt((1.0 + pow(t_2, 2.0)))), sin(t), (cos(atan(((tan(t) / ew) * eh))) * (cos(t) * ew))));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(Float64(sin(t) * eh) * sin(atan(Float64(fma(Float64(Float64(0.3333333333333333 * Float64(eh / ew)) * t), t, Float64(eh / ew)) * t))))) t_2 = Float64(Float64(t / ew) * eh) tmp = 0.0 if (eh <= -4.2e+191) tmp = t_1; elseif (eh <= 2.7e+160) tmp = abs(fma(Float64(Float64(t_2 * eh) / sqrt(Float64(1.0 + (t_2 ^ 2.0)))), sin(t), Float64(cos(atan(Float64(Float64(tan(t) / ew) * eh))) * Float64(cos(t) * ew)))); else tmp = t_1; end return 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[(N[(N[(0.3333333333333333 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] * t + N[(eh / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]}, If[LessEqual[eh, -4.2e+191], t$95$1, If[LessEqual[eh, 2.7e+160], N[Abs[N[(N[(N[(t$95$2 * eh), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $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(\mathsf{fma}\left(\left(0.3333333333333333 \cdot \frac{eh}{ew}\right) \cdot t, t, \frac{eh}{ew}\right) \cdot t\right)\right|\\
t_2 := \frac{t}{ew} \cdot eh\\
\mathbf{if}\;eh \leq -4.2 \cdot 10^{+191}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 2.7 \cdot 10^{+160}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{t\_2 \cdot eh}{\sqrt{1 + {t\_2}^{2}}}, \sin t, \cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \left(\cos t \cdot ew\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -4.2000000000000001e191 or 2.7e160 < eh Initial program 99.9%
Applied rewrites99.9%
lift-fma.f64N/A
Applied rewrites99.9%
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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6488.1
Applied rewrites88.1%
Taylor expanded in t around 0
Applied rewrites88.2%
if -4.2000000000000001e191 < eh < 2.7e160Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in t around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6499.2
Applied rewrites99.2%
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites83.8%
Final simplification84.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (sin t) eh))
(t_2
(fabs
(*
t_1
(sin
(atan
(*
(fma (* (* 0.3333333333333333 (/ eh ew)) t) t (/ eh ew))
t)))))))
(if (<= eh -1.02e+135)
t_2
(if (<= eh 2.5e+30)
(fabs
(/
(+ (* (* (/ eh ew) (tan t)) t_1) (* (cos t) ew))
(/ 1.0 (cos (atan (* (/ (tan t) ew) eh))))))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = sin(t) * eh;
double t_2 = fabs((t_1 * sin(atan((fma(((0.3333333333333333 * (eh / ew)) * t), t, (eh / ew)) * t)))));
double tmp;
if (eh <= -1.02e+135) {
tmp = t_2;
} else if (eh <= 2.5e+30) {
tmp = fabs((((((eh / ew) * tan(t)) * t_1) + (cos(t) * ew)) / (1.0 / cos(atan(((tan(t) / ew) * eh))))));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(sin(t) * eh) t_2 = abs(Float64(t_1 * sin(atan(Float64(fma(Float64(Float64(0.3333333333333333 * Float64(eh / ew)) * t), t, Float64(eh / ew)) * t))))) tmp = 0.0 if (eh <= -1.02e+135) tmp = t_2; elseif (eh <= 2.5e+30) tmp = abs(Float64(Float64(Float64(Float64(Float64(eh / ew) * tan(t)) * t_1) + Float64(cos(t) * ew)) / Float64(1.0 / cos(atan(Float64(Float64(tan(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[Abs[N[(t$95$1 * 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]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.02e+135], t$95$2, If[LessEqual[eh, 2.5e+30], N[Abs[N[(N[(N[(N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin t \cdot eh\\
t_2 := \left|t\_1 \cdot \sin \tan^{-1} \left(\mathsf{fma}\left(\left(0.3333333333333333 \cdot \frac{eh}{ew}\right) \cdot t, t, \frac{eh}{ew}\right) \cdot t\right)\right|\\
\mathbf{if}\;eh \leq -1.02 \cdot 10^{+135}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;eh \leq 2.5 \cdot 10^{+30}:\\
\;\;\;\;\left|\frac{\left(\frac{eh}{ew} \cdot \tan t\right) \cdot t\_1 + \cos t \cdot ew}{\frac{1}{\cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)}}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if eh < -1.01999999999999993e135 or 2.4999999999999999e30 < eh Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6474.3
Applied rewrites74.3%
Taylor expanded in t around 0
Applied rewrites74.4%
if -1.01999999999999993e135 < eh < 2.4999999999999999e30Initial program 99.8%
Applied rewrites87.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6487.7
Applied rewrites87.7%
Final simplification83.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (tan t) ew) eh))
(t_2
(fabs
(*
(* (sin t) eh)
(sin
(atan
(*
(fma (* (* 0.3333333333333333 (/ eh ew)) t) t (/ eh ew))
t)))))))
(if (<= eh -1.02e+135)
t_2
(if (<= eh 2.5e+30)
(fabs
(* (fma (- ew) (cos t) (* (- (sin t)) (* t_1 eh))) (cos (atan t_1))))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = (tan(t) / ew) * eh;
double t_2 = fabs(((sin(t) * eh) * sin(atan((fma(((0.3333333333333333 * (eh / ew)) * t), t, (eh / ew)) * t)))));
double tmp;
if (eh <= -1.02e+135) {
tmp = t_2;
} else if (eh <= 2.5e+30) {
tmp = fabs((fma(-ew, cos(t), (-sin(t) * (t_1 * eh))) * cos(atan(t_1))));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(tan(t) / ew) * eh) t_2 = abs(Float64(Float64(sin(t) * eh) * sin(atan(Float64(fma(Float64(Float64(0.3333333333333333 * Float64(eh / ew)) * t), t, Float64(eh / ew)) * t))))) tmp = 0.0 if (eh <= -1.02e+135) tmp = t_2; elseif (eh <= 2.5e+30) tmp = abs(Float64(fma(Float64(-ew), cos(t), Float64(Float64(-sin(t)) * Float64(t_1 * eh))) * cos(atan(t_1)))); else tmp = t_2; 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[Abs[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * 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]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.02e+135], t$95$2, If[LessEqual[eh, 2.5e+30], N[Abs[N[(N[((-ew) * N[Cos[t], $MachinePrecision] + N[((-N[Sin[t], $MachinePrecision]) * N[(t$95$1 * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew} \cdot eh\\
t_2 := \left|\left(\sin t \cdot eh\right) \cdot \sin \tan^{-1} \left(\mathsf{fma}\left(\left(0.3333333333333333 \cdot \frac{eh}{ew}\right) \cdot t, t, \frac{eh}{ew}\right) \cdot t\right)\right|\\
\mathbf{if}\;eh \leq -1.02 \cdot 10^{+135}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;eh \leq 2.5 \cdot 10^{+30}:\\
\;\;\;\;\left|\mathsf{fma}\left(-ew, \cos t, \left(-\sin t\right) \cdot \left(t\_1 \cdot eh\right)\right) \cdot \cos \tan^{-1} t\_1\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if eh < -1.01999999999999993e135 or 2.4999999999999999e30 < eh Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6474.3
Applied rewrites74.3%
Taylor expanded in t around 0
Applied rewrites74.4%
if -1.01999999999999993e135 < eh < 2.4999999999999999e30Initial program 99.8%
Applied rewrites99.8%
Applied rewrites87.7%
Final simplification83.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(* (sin t) eh)
(sin
(atan
(*
(fma (* (* 0.3333333333333333 (/ eh ew)) t) t (/ eh ew))
t)))))))
(if (<= eh -1.02e+135)
t_1
(if (<= eh 1.25e+25)
(* (fabs (* (- (cos t)) ew)) (cos (atan (* (/ (tan t) ew) eh))))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((sin(t) * eh) * sin(atan((fma(((0.3333333333333333 * (eh / ew)) * t), t, (eh / ew)) * t)))));
double tmp;
if (eh <= -1.02e+135) {
tmp = t_1;
} else if (eh <= 1.25e+25) {
tmp = fabs((-cos(t) * ew)) * cos(atan(((tan(t) / ew) * eh)));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(Float64(sin(t) * eh) * sin(atan(Float64(fma(Float64(Float64(0.3333333333333333 * Float64(eh / ew)) * t), t, Float64(eh / ew)) * t))))) tmp = 0.0 if (eh <= -1.02e+135) tmp = t_1; elseif (eh <= 1.25e+25) tmp = Float64(abs(Float64(Float64(-cos(t)) * ew)) * cos(atan(Float64(Float64(tan(t) / ew) * eh)))); else tmp = t_1; end return 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[(N[(N[(0.3333333333333333 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] * t + N[(eh / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.02e+135], t$95$1, If[LessEqual[eh, 1.25e+25], N[(N[Abs[N[((-N[Cos[t], $MachinePrecision]) * ew), $MachinePrecision]], $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $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(\mathsf{fma}\left(\left(0.3333333333333333 \cdot \frac{eh}{ew}\right) \cdot t, t, \frac{eh}{ew}\right) \cdot t\right)\right|\\
\mathbf{if}\;eh \leq -1.02 \cdot 10^{+135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 1.25 \cdot 10^{+25}:\\
\;\;\;\;\left|\left(-\cos t\right) \cdot ew\right| \cdot \cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -1.01999999999999993e135 or 1.25000000000000006e25 < eh Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6474.3
Applied rewrites74.3%
Taylor expanded in t around 0
Applied rewrites74.4%
if -1.01999999999999993e135 < eh < 1.25000000000000006e25Initial program 99.8%
Applied rewrites87.7%
Taylor expanded in eh around 0
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6486.7
Applied rewrites86.7%
lift-fabs.f64N/A
lift-/.f64N/A
div-invN/A
fabs-mulN/A
fabs-divN/A
Applied rewrites86.7%
Final simplification82.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(* (sin t) eh)
(sin
(atan
(*
(fma (* (* 0.3333333333333333 (/ eh ew)) t) t (/ eh ew))
t)))))))
(if (<= eh -1.02e+135) t_1 (if (<= eh 8.6e+21) (fabs (/ ew 1.0)) t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((sin(t) * eh) * sin(atan((fma(((0.3333333333333333 * (eh / ew)) * t), t, (eh / ew)) * t)))));
double tmp;
if (eh <= -1.02e+135) {
tmp = t_1;
} else if (eh <= 8.6e+21) {
tmp = 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(fma(Float64(Float64(0.3333333333333333 * Float64(eh / ew)) * t), t, Float64(eh / ew)) * t))))) tmp = 0.0 if (eh <= -1.02e+135) tmp = t_1; elseif (eh <= 8.6e+21) tmp = abs(Float64(ew / 1.0)); else tmp = t_1; end return 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[(N[(N[(0.3333333333333333 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] * t + N[(eh / ew), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.02e+135], t$95$1, If[LessEqual[eh, 8.6e+21], 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(\mathsf{fma}\left(\left(0.3333333333333333 \cdot \frac{eh}{ew}\right) \cdot t, t, \frac{eh}{ew}\right) \cdot t\right)\right|\\
\mathbf{if}\;eh \leq -1.02 \cdot 10^{+135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 8.6 \cdot 10^{+21}:\\
\;\;\;\;\left|\frac{ew}{1}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -1.01999999999999993e135 or 8.6e21 < eh Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
Applied rewrites99.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
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f6474.3
Applied rewrites74.3%
Taylor expanded in t around 0
Applied rewrites74.4%
if -1.01999999999999993e135 < eh < 8.6e21Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites60.6%
Taylor expanded in t around 0
Applied rewrites59.3%
Applied rewrites58.7%
Taylor expanded in eh around 0
Applied rewrites60.7%
Final simplification65.6%
(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 rewrites47.7%
Taylor expanded in t around 0
Applied rewrites46.6%
Applied rewrites45.8%
Taylor expanded in eh around 0
Applied rewrites47.8%
herbie shell --seed 2024288
(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)))))))