
(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 (* (cos t_1) (cos t)) ew (* (* (sin t) eh) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((tan(t) / ew) * eh));
return fabs(fma((cos(t_1) * cos(t)), ew, ((sin(t) * eh) * sin(t_1))));
}
function code(eh, ew, t) t_1 = atan(Float64(Float64(tan(t) / ew) * eh)) return abs(fma(Float64(cos(t_1) * cos(t)), ew, Float64(Float64(sin(t) * eh) * sin(t_1)))) 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[Cos[t$95$1], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew + 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(\frac{\tan t}{ew} \cdot eh\right)\\
\left|\mathsf{fma}\left(\cos t\_1 \cdot \cos t, ew, \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
(let* ((t_1 (* (/ (tan t) ew) eh)) (t_2 (* (sin t) eh)))
(if (or (<= ew -1.9e+19) (not (<= ew 1.02e-91)))
(fabs (/ (+ (* t_2 t_1) (* (cos t) ew)) (pow (cos (atan t_1)) -1.0)))
(fabs (* (sin (atan (* (/ eh (cos t)) (/ (sin t) ew)))) t_2)))))
double code(double eh, double ew, double t) {
double t_1 = (tan(t) / ew) * eh;
double t_2 = sin(t) * eh;
double tmp;
if ((ew <= -1.9e+19) || !(ew <= 1.02e-91)) {
tmp = fabs((((t_2 * t_1) + (cos(t) * ew)) / pow(cos(atan(t_1)), -1.0)));
} else {
tmp = fabs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * 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 = (tan(t) / ew) * eh
t_2 = sin(t) * eh
if ((ew <= (-1.9d+19)) .or. (.not. (ew <= 1.02d-91))) then
tmp = abs((((t_2 * t_1) + (cos(t) * ew)) / (cos(atan(t_1)) ** (-1.0d0))))
else
tmp = abs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * t_2))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = (Math.tan(t) / ew) * eh;
double t_2 = Math.sin(t) * eh;
double tmp;
if ((ew <= -1.9e+19) || !(ew <= 1.02e-91)) {
tmp = Math.abs((((t_2 * t_1) + (Math.cos(t) * ew)) / Math.pow(Math.cos(Math.atan(t_1)), -1.0)));
} else {
tmp = Math.abs((Math.sin(Math.atan(((eh / Math.cos(t)) * (Math.sin(t) / ew)))) * t_2));
}
return tmp;
}
def code(eh, ew, t): t_1 = (math.tan(t) / ew) * eh t_2 = math.sin(t) * eh tmp = 0 if (ew <= -1.9e+19) or not (ew <= 1.02e-91): tmp = math.fabs((((t_2 * t_1) + (math.cos(t) * ew)) / math.pow(math.cos(math.atan(t_1)), -1.0))) else: tmp = math.fabs((math.sin(math.atan(((eh / math.cos(t)) * (math.sin(t) / ew)))) * t_2)) return tmp
function code(eh, ew, t) t_1 = Float64(Float64(tan(t) / ew) * eh) t_2 = Float64(sin(t) * eh) tmp = 0.0 if ((ew <= -1.9e+19) || !(ew <= 1.02e-91)) tmp = abs(Float64(Float64(Float64(t_2 * t_1) + Float64(cos(t) * ew)) / (cos(atan(t_1)) ^ -1.0))); else tmp = abs(Float64(sin(atan(Float64(Float64(eh / cos(t)) * Float64(sin(t) / ew)))) * t_2)); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = (tan(t) / ew) * eh; t_2 = sin(t) * eh; tmp = 0.0; if ((ew <= -1.9e+19) || ~((ew <= 1.02e-91))) tmp = abs((((t_2 * t_1) + (cos(t) * ew)) / (cos(atan(t_1)) ^ -1.0))); else tmp = abs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * t_2)); end tmp_2 = 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[Sin[t], $MachinePrecision] * eh), $MachinePrecision]}, If[Or[LessEqual[ew, -1.9e+19], N[Not[LessEqual[ew, 1.02e-91]], $MachinePrecision]], N[Abs[N[(N[(N[(t$95$2 * t$95$1), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew} \cdot eh\\
t_2 := \sin t \cdot eh\\
\mathbf{if}\;ew \leq -1.9 \cdot 10^{+19} \lor \neg \left(ew \leq 1.02 \cdot 10^{-91}\right):\\
\;\;\;\;\left|\frac{t\_2 \cdot t\_1 + \cos t \cdot ew}{{\cos \tan^{-1} t\_1}^{-1}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{eh}{\cos t} \cdot \frac{\sin t}{ew}\right) \cdot t\_2\right|\\
\end{array}
\end{array}
if ew < -1.9e19 or 1.01999999999999994e-91 < ew Initial program 99.8%
Applied rewrites87.4%
if -1.9e19 < ew < 1.01999999999999994e-91Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in ew around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in eh around inf
Applied rewrites77.8%
Final simplification83.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (sin t) eh)) (t_2 (* (/ (tan t) ew) eh)) (t_3 (atan t_2)))
(if (<= ew 7.5e+48)
(fabs (fma (* (cos (atan (* (/ t ew) eh))) (cos t)) ew (* t_1 (sin t_3))))
(fabs (/ (+ (* t_1 t_2) (* (cos t) ew)) (pow (cos t_3) -1.0))))))
double code(double eh, double ew, double t) {
double t_1 = sin(t) * eh;
double t_2 = (tan(t) / ew) * eh;
double t_3 = atan(t_2);
double tmp;
if (ew <= 7.5e+48) {
tmp = fabs(fma((cos(atan(((t / ew) * eh))) * cos(t)), ew, (t_1 * sin(t_3))));
} else {
tmp = fabs((((t_1 * t_2) + (cos(t) * ew)) / pow(cos(t_3), -1.0)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(sin(t) * eh) t_2 = Float64(Float64(tan(t) / ew) * eh) t_3 = atan(t_2) tmp = 0.0 if (ew <= 7.5e+48) tmp = abs(fma(Float64(cos(atan(Float64(Float64(t / ew) * eh))) * cos(t)), ew, Float64(t_1 * sin(t_3)))); else tmp = abs(Float64(Float64(Float64(t_1 * t_2) + Float64(cos(t) * ew)) / (cos(t_3) ^ -1.0))); 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[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[t$95$2], $MachinePrecision]}, If[LessEqual[ew, 7.5e+48], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(N[(t / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew + N[(t$95$1 * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(t$95$1 * t$95$2), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[t$95$3], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sin t \cdot eh\\
t_2 := \frac{\tan t}{ew} \cdot eh\\
t_3 := \tan^{-1} t\_2\\
\mathbf{if}\;ew \leq 7.5 \cdot 10^{+48}:\\
\;\;\;\;\left|\mathsf{fma}\left(\cos \tan^{-1} \left(\frac{t}{ew} \cdot eh\right) \cdot \cos t, ew, t\_1 \cdot \sin t\_3\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{t\_1 \cdot t\_2 + \cos t \cdot ew}{{\cos t\_3}^{-1}}\right|\\
\end{array}
\end{array}
if ew < 7.5000000000000006e48Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in t around 0
lower-/.f6494.8
Applied rewrites94.8%
if 7.5000000000000006e48 < ew Initial program 99.8%
Applied rewrites95.7%
Final simplification95.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (tan t) ew))
(t_2 (* (sin t) eh))
(t_3 (* t_1 eh))
(t_4 (cos (atan t_3))))
(if (<= ew -1.9e+19)
(fabs (/ (+ (* t_2 t_3) (* (cos t) ew)) (pow t_4 -1.0)))
(if (<= ew 1.02e-91)
(fabs (* (sin (atan (* (/ eh (cos t)) (/ (sin t) ew)))) t_2))
(fabs
(/
(fma (* t_1 (* (- eh) (sin t))) eh (* (- (cos t)) ew))
(/ -1.0 t_4)))))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) / ew;
double t_2 = sin(t) * eh;
double t_3 = t_1 * eh;
double t_4 = cos(atan(t_3));
double tmp;
if (ew <= -1.9e+19) {
tmp = fabs((((t_2 * t_3) + (cos(t) * ew)) / pow(t_4, -1.0)));
} else if (ew <= 1.02e-91) {
tmp = fabs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * t_2));
} else {
tmp = fabs((fma((t_1 * (-eh * sin(t))), eh, (-cos(t) * ew)) / (-1.0 / t_4)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(tan(t) / ew) t_2 = Float64(sin(t) * eh) t_3 = Float64(t_1 * eh) t_4 = cos(atan(t_3)) tmp = 0.0 if (ew <= -1.9e+19) tmp = abs(Float64(Float64(Float64(t_2 * t_3) + Float64(cos(t) * ew)) / (t_4 ^ -1.0))); elseif (ew <= 1.02e-91) tmp = abs(Float64(sin(atan(Float64(Float64(eh / cos(t)) * Float64(sin(t) / ew)))) * t_2)); else tmp = abs(Float64(fma(Float64(t_1 * Float64(Float64(-eh) * sin(t))), eh, Float64(Float64(-cos(t)) * ew)) / Float64(-1.0 / t_4))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * eh), $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[ArcTan[t$95$3], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -1.9e+19], N[Abs[N[(N[(N[(t$95$2 * t$95$3), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Power[t$95$4, -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 1.02e-91], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(t$95$1 * N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eh + N[((-N[Cos[t], $MachinePrecision]) * ew), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew}\\
t_2 := \sin t \cdot eh\\
t_3 := t\_1 \cdot eh\\
t_4 := \cos \tan^{-1} t\_3\\
\mathbf{if}\;ew \leq -1.9 \cdot 10^{+19}:\\
\;\;\;\;\left|\frac{t\_2 \cdot t\_3 + \cos t \cdot ew}{{t\_4}^{-1}}\right|\\
\mathbf{elif}\;ew \leq 1.02 \cdot 10^{-91}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{eh}{\cos t} \cdot \frac{\sin t}{ew}\right) \cdot t\_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(t\_1 \cdot \left(\left(-eh\right) \cdot \sin t\right), eh, \left(-\cos t\right) \cdot ew\right)}{\frac{-1}{t\_4}}\right|\\
\end{array}
\end{array}
if ew < -1.9e19Initial program 99.9%
Applied rewrites92.9%
if -1.9e19 < ew < 1.01999999999999994e-91Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in ew around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in eh around inf
Applied rewrites77.8%
if 1.01999999999999994e-91 < ew Initial program 99.8%
Applied rewrites85.2%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6485.2
Applied rewrites85.2%
Final simplification83.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (tan t) ew) eh)))
(if (or (<= ew -1.9e+19) (not (<= ew 1.02e-91)))
(* (fabs (+ (* (* t_1 eh) (sin t)) (* (cos t) ew))) (cos (atan t_1)))
(fabs
(* (sin (atan (* (/ eh (cos t)) (/ (sin t) ew)))) (* (sin t) eh))))))
double code(double eh, double ew, double t) {
double t_1 = (tan(t) / ew) * eh;
double tmp;
if ((ew <= -1.9e+19) || !(ew <= 1.02e-91)) {
tmp = fabs((((t_1 * eh) * sin(t)) + (cos(t) * ew))) * cos(atan(t_1));
} else {
tmp = fabs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * (sin(t) * eh)));
}
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 = (tan(t) / ew) * eh
if ((ew <= (-1.9d+19)) .or. (.not. (ew <= 1.02d-91))) then
tmp = abs((((t_1 * eh) * sin(t)) + (cos(t) * ew))) * cos(atan(t_1))
else
tmp = abs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * (sin(t) * eh)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = (Math.tan(t) / ew) * eh;
double tmp;
if ((ew <= -1.9e+19) || !(ew <= 1.02e-91)) {
tmp = Math.abs((((t_1 * eh) * Math.sin(t)) + (Math.cos(t) * ew))) * Math.cos(Math.atan(t_1));
} else {
tmp = Math.abs((Math.sin(Math.atan(((eh / Math.cos(t)) * (Math.sin(t) / ew)))) * (Math.sin(t) * eh)));
}
return tmp;
}
def code(eh, ew, t): t_1 = (math.tan(t) / ew) * eh tmp = 0 if (ew <= -1.9e+19) or not (ew <= 1.02e-91): tmp = math.fabs((((t_1 * eh) * math.sin(t)) + (math.cos(t) * ew))) * math.cos(math.atan(t_1)) else: tmp = math.fabs((math.sin(math.atan(((eh / math.cos(t)) * (math.sin(t) / ew)))) * (math.sin(t) * eh))) return tmp
function code(eh, ew, t) t_1 = Float64(Float64(tan(t) / ew) * eh) tmp = 0.0 if ((ew <= -1.9e+19) || !(ew <= 1.02e-91)) tmp = Float64(abs(Float64(Float64(Float64(t_1 * eh) * sin(t)) + Float64(cos(t) * ew))) * cos(atan(t_1))); else tmp = abs(Float64(sin(atan(Float64(Float64(eh / cos(t)) * Float64(sin(t) / ew)))) * Float64(sin(t) * eh))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = (tan(t) / ew) * eh; tmp = 0.0; if ((ew <= -1.9e+19) || ~((ew <= 1.02e-91))) tmp = abs((((t_1 * eh) * sin(t)) + (cos(t) * ew))) * cos(atan(t_1)); else tmp = abs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * (sin(t) * eh))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]}, If[Or[LessEqual[ew, -1.9e+19], N[Not[LessEqual[ew, 1.02e-91]], $MachinePrecision]], N[(N[Abs[N[(N[(N[(t$95$1 * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew} \cdot eh\\
\mathbf{if}\;ew \leq -1.9 \cdot 10^{+19} \lor \neg \left(ew \leq 1.02 \cdot 10^{-91}\right):\\
\;\;\;\;\left|\left(t\_1 \cdot eh\right) \cdot \sin t + \cos t \cdot ew\right| \cdot \cos \tan^{-1} t\_1\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{eh}{\cos t} \cdot \frac{\sin t}{ew}\right) \cdot \left(\sin t \cdot eh\right)\right|\\
\end{array}
\end{array}
if ew < -1.9e19 or 1.01999999999999994e-91 < ew Initial program 99.8%
Applied rewrites99.8%
Applied rewrites87.4%
if -1.9e19 < ew < 1.01999999999999994e-91Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in ew around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in eh around inf
Applied rewrites77.8%
Final simplification83.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.9e+19) (not (<= ew 2.45e-83))) (* (fabs (* (- (cos t)) ew)) (cos (atan (* (/ (tan t) ew) eh)))) (fabs (* (sin (atan (* (/ eh (cos t)) (/ (sin t) ew)))) (* (sin t) eh)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.9e+19) || !(ew <= 2.45e-83)) {
tmp = fabs((-cos(t) * ew)) * cos(atan(((tan(t) / ew) * eh)));
} else {
tmp = fabs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * (sin(t) * eh)));
}
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) :: tmp
if ((ew <= (-1.9d+19)) .or. (.not. (ew <= 2.45d-83))) then
tmp = abs((-cos(t) * ew)) * cos(atan(((tan(t) / ew) * eh)))
else
tmp = abs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * (sin(t) * eh)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.9e+19) || !(ew <= 2.45e-83)) {
tmp = Math.abs((-Math.cos(t) * ew)) * Math.cos(Math.atan(((Math.tan(t) / ew) * eh)));
} else {
tmp = Math.abs((Math.sin(Math.atan(((eh / Math.cos(t)) * (Math.sin(t) / ew)))) * (Math.sin(t) * eh)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.9e+19) or not (ew <= 2.45e-83): tmp = math.fabs((-math.cos(t) * ew)) * math.cos(math.atan(((math.tan(t) / ew) * eh))) else: tmp = math.fabs((math.sin(math.atan(((eh / math.cos(t)) * (math.sin(t) / ew)))) * (math.sin(t) * eh))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.9e+19) || !(ew <= 2.45e-83)) tmp = Float64(abs(Float64(Float64(-cos(t)) * ew)) * cos(atan(Float64(Float64(tan(t) / ew) * eh)))); else tmp = abs(Float64(sin(atan(Float64(Float64(eh / cos(t)) * Float64(sin(t) / ew)))) * Float64(sin(t) * eh))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.9e+19) || ~((ew <= 2.45e-83))) tmp = abs((-cos(t) * ew)) * cos(atan(((tan(t) / ew) * eh))); else tmp = abs((sin(atan(((eh / cos(t)) * (sin(t) / ew)))) * (sin(t) * eh))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.9e+19], N[Not[LessEqual[ew, 2.45e-83]], $MachinePrecision]], 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], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.9 \cdot 10^{+19} \lor \neg \left(ew \leq 2.45 \cdot 10^{-83}\right):\\
\;\;\;\;\left|\left(-\cos t\right) \cdot ew\right| \cdot \cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{eh}{\cos t} \cdot \frac{\sin t}{ew}\right) \cdot \left(\sin t \cdot eh\right)\right|\\
\end{array}
\end{array}
if ew < -1.9e19 or 2.45e-83 < ew Initial program 99.8%
Applied rewrites87.9%
Taylor expanded in eh around 0
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6486.2
Applied rewrites86.2%
lift-fabs.f64N/A
lift-/.f64N/A
div-invN/A
fabs-mulN/A
fabs-divN/A
metadata-evalN/A
lift-/.f64N/A
Applied rewrites86.2%
if -1.9e19 < ew < 2.45e-83Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in ew around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.3%
Taylor expanded in eh around inf
Applied rewrites77.3%
Final simplification82.3%
(FPCore (eh ew t) :precision binary64 (* (fabs (* (- (cos t)) ew)) (cos (atan (* (/ (tan t) ew) eh)))))
double code(double eh, double ew, double t) {
return fabs((-cos(t) * ew)) * cos(atan(((tan(t) / ew) * 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((-cos(t) * ew)) * cos(atan(((tan(t) / ew) * eh)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((-Math.cos(t) * ew)) * Math.cos(Math.atan(((Math.tan(t) / ew) * eh)));
}
def code(eh, ew, t): return math.fabs((-math.cos(t) * ew)) * math.cos(math.atan(((math.tan(t) / ew) * eh)))
function code(eh, ew, t) return Float64(abs(Float64(Float64(-cos(t)) * ew)) * cos(atan(Float64(Float64(tan(t) / ew) * eh)))) end
function tmp = code(eh, ew, t) tmp = abs((-cos(t) * ew)) * cos(atan(((tan(t) / ew) * eh))); end
code[eh_, ew_, t_] := 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]
\begin{array}{l}
\\
\left|\left(-\cos t\right) \cdot ew\right| \cdot \cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)
\end{array}
Initial program 99.8%
Applied rewrites61.9%
Taylor expanded in eh around 0
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6459.8
Applied rewrites59.8%
lift-fabs.f64N/A
lift-/.f64N/A
div-invN/A
fabs-mulN/A
fabs-divN/A
metadata-evalN/A
lift-/.f64N/A
Applied rewrites59.8%
(FPCore (eh ew t) :precision binary64 (fabs (/ (* (- ew) (cos t)) (/ -1.0 (cos (atan (* (/ eh ew) t)))))))
double code(double eh, double ew, double t) {
return fabs(((-ew * cos(t)) / (-1.0 / cos(atan(((eh / ew) * 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(((-ew * cos(t)) / ((-1.0d0) / cos(atan(((eh / ew) * t))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((-ew * Math.cos(t)) / (-1.0 / Math.cos(Math.atan(((eh / ew) * t))))));
}
def code(eh, ew, t): return math.fabs(((-ew * math.cos(t)) / (-1.0 / math.cos(math.atan(((eh / ew) * t))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(-ew) * cos(t)) / Float64(-1.0 / cos(atan(Float64(Float64(eh / ew) * t)))))) end
function tmp = code(eh, ew, t) tmp = abs(((-ew * cos(t)) / (-1.0 / cos(atan(((eh / ew) * t)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[((-ew) * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[(-1.0 / N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\left(-ew\right) \cdot \cos t}{\frac{-1}{\cos \tan^{-1} \left(\frac{eh}{ew} \cdot t\right)}}\right|
\end{array}
Initial program 99.8%
Applied rewrites61.9%
Taylor expanded in eh around 0
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6459.8
Applied rewrites59.8%
Taylor expanded in t around 0
*-commutativeN/A
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.9%
Taylor expanded in t around 0
Applied rewrites50.6%
Final simplification50.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 rewrites40.0%
Taylor expanded in t around 0
Applied rewrites38.8%
Applied rewrites37.9%
Taylor expanded in eh around 0
Applied rewrites40.1%
herbie shell --seed 2024318
(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)))))))