
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ eh (* (tan t) ew))))) (fabs (fma (* (sin t) (cos t_1)) ew (* (* (cos t) eh) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (tan(t) * ew)));
return fabs(fma((sin(t) * cos(t_1)), ew, ((cos(t) * eh) * sin(t_1))));
}
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(tan(t) * ew))) return abs(fma(Float64(sin(t) * cos(t_1)), ew, Float64(Float64(cos(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[(N[Sin[t], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] * ew + N[(N[(N[Cos[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{eh}{\tan t \cdot ew}\right)\\
\left|\mathsf{fma}\left(\sin t \cdot \cos t\_1, ew, \left(\cos t \cdot eh\right) \cdot \sin t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (/ (sin t) (sqrt (+ 1.0 (pow (/ (/ eh (tan t)) ew) 2.0)))) ew (* (* (cos t) eh) (sin (atan (/ eh (* (tan t) ew))))))))
double code(double eh, double ew, double t) {
return fabs(fma((sin(t) / sqrt((1.0 + pow(((eh / tan(t)) / ew), 2.0)))), ew, ((cos(t) * eh) * sin(atan((eh / (tan(t) * ew)))))));
}
function code(eh, ew, t) return abs(fma(Float64(sin(t) / sqrt(Float64(1.0 + (Float64(Float64(eh / tan(t)) / ew) ^ 2.0)))), ew, Float64(Float64(cos(t) * eh) * sin(atan(Float64(eh / Float64(tan(t) * ew))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[t], $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * ew + N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\frac{\sin t}{\sqrt{1 + {\left(\frac{\frac{eh}{\tan t}}{ew}\right)}^{2}}}, ew, \left(\cos t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\right)\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
un-div-invN/A
lower-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-/.f64N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* (cos (atan (/ eh (* t ew)))) (sin t)) ew (* (* (cos t) eh) (sin (atan (/ eh (* (tan t) ew))))))))
double code(double eh, double ew, double t) {
return fabs(fma((cos(atan((eh / (t * ew)))) * sin(t)), ew, ((cos(t) * eh) * sin(atan((eh / (tan(t) * ew)))))));
}
function code(eh, ew, t) return abs(fma(Float64(cos(atan(Float64(eh / Float64(t * ew)))) * sin(t)), ew, Float64(Float64(cos(t) * eh) * sin(atan(Float64(eh / Float64(tan(t) * ew))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Cos[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * ew + N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) \cdot \sin t, ew, \left(\cos t \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\right)\right|
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(+
(* (sin (atan (/ eh (* t ew)))) (fma (* -0.5 eh) (* t t) eh))
(* (cos (atan (/ (/ eh ew) (tan t)))) (* (sin t) ew))))))
(if (<= ew -5.9e-56)
t_1
(if (<= ew 8.2e+18)
(fabs (* (sin (atan (* (/ (/ eh (sin t)) ew) (cos t)))) (* (cos t) eh)))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((sin(atan((eh / (t * ew)))) * fma((-0.5 * eh), (t * t), eh)) + (cos(atan(((eh / ew) / tan(t)))) * (sin(t) * ew))));
double tmp;
if (ew <= -5.9e-56) {
tmp = t_1;
} else if (ew <= 8.2e+18) {
tmp = fabs((sin(atan((((eh / sin(t)) / ew) * cos(t)))) * (cos(t) * eh)));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(Float64(sin(atan(Float64(eh / Float64(t * ew)))) * fma(Float64(-0.5 * eh), Float64(t * t), eh)) + Float64(cos(atan(Float64(Float64(eh / ew) / tan(t)))) * Float64(sin(t) * ew)))) tmp = 0.0 if (ew <= -5.9e-56) tmp = t_1; elseif (ew <= 8.2e+18) tmp = abs(Float64(sin(atan(Float64(Float64(Float64(eh / sin(t)) / ew) * cos(t)))) * Float64(cos(t) * eh))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[(N[Sin[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[(-0.5 * eh), $MachinePrecision] * N[(t * t), $MachinePrecision] + eh), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -5.9e-56], t$95$1, If[LessEqual[ew, 8.2e+18], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\sin \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) \cdot \mathsf{fma}\left(-0.5 \cdot eh, t \cdot t, eh\right) + \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(\sin t \cdot ew\right)\right|\\
\mathbf{if}\;ew \leq -5.9 \cdot 10^{-56}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;ew \leq 8.2 \cdot 10^{+18}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\frac{eh}{\sin t}}{ew} \cdot \cos t\right) \cdot \left(\cos t \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if ew < -5.8999999999999998e-56 or 8.2e18 < ew Initial program 99.8%
Taylor expanded in t around 0
associate-*r*N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.0
Applied rewrites75.0%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6475.8
Applied rewrites75.8%
if -5.8999999999999998e-56 < ew < 8.2e18Initial program 99.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
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
Applied rewrites86.0%
Final simplification80.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(* (sin (atan (* (/ (/ eh (sin t)) ew) (cos t)))) (* (cos t) eh)))))
(if (<= eh -2.5e-106)
t_1
(if (<= eh 2.05e-63)
(fabs (* (cos (atan (/ eh (* t ew)))) (* (sin t) ew)))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((sin(atan((((eh / sin(t)) / ew) * cos(t)))) * (cos(t) * eh)));
double tmp;
if (eh <= -2.5e-106) {
tmp = t_1;
} else if (eh <= 2.05e-63) {
tmp = fabs((cos(atan((eh / (t * ew)))) * (sin(t) * ew)));
} 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(atan((((eh / sin(t)) / ew) * cos(t)))) * (cos(t) * eh)))
if (eh <= (-2.5d-106)) then
tmp = t_1
else if (eh <= 2.05d-63) then
tmp = abs((cos(atan((eh / (t * ew)))) * (sin(t) * ew)))
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(Math.atan((((eh / Math.sin(t)) / ew) * Math.cos(t)))) * (Math.cos(t) * eh)));
double tmp;
if (eh <= -2.5e-106) {
tmp = t_1;
} else if (eh <= 2.05e-63) {
tmp = Math.abs((Math.cos(Math.atan((eh / (t * ew)))) * (Math.sin(t) * ew)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((math.sin(math.atan((((eh / math.sin(t)) / ew) * math.cos(t)))) * (math.cos(t) * eh))) tmp = 0 if eh <= -2.5e-106: tmp = t_1 elif eh <= 2.05e-63: tmp = math.fabs((math.cos(math.atan((eh / (t * ew)))) * (math.sin(t) * ew))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(sin(atan(Float64(Float64(Float64(eh / sin(t)) / ew) * cos(t)))) * Float64(cos(t) * eh))) tmp = 0.0 if (eh <= -2.5e-106) tmp = t_1; elseif (eh <= 2.05e-63) tmp = abs(Float64(cos(atan(Float64(eh / Float64(t * ew)))) * Float64(sin(t) * ew))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((sin(atan((((eh / sin(t)) / ew) * cos(t)))) * (cos(t) * eh))); tmp = 0.0; if (eh <= -2.5e-106) tmp = t_1; elseif (eh <= 2.05e-63) tmp = abs((cos(atan((eh / (t * ew)))) * (sin(t) * ew))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -2.5e-106], t$95$1, If[LessEqual[eh, 2.05e-63], N[Abs[N[(N[Cos[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\sin \tan^{-1} \left(\frac{\frac{eh}{\sin t}}{ew} \cdot \cos t\right) \cdot \left(\cos t \cdot eh\right)\right|\\
\mathbf{if}\;eh \leq -2.5 \cdot 10^{-106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 2.05 \cdot 10^{-63}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) \cdot \left(\sin t \cdot ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2.49999999999999991e-106 or 2.0499999999999999e-63 < eh Initial program 99.8%
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
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
Applied rewrites82.6%
if -2.49999999999999991e-106 < eh < 2.0499999999999999e-63Initial program 99.8%
Taylor expanded in ew around inf
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.0%
Taylor expanded in t around 0
Applied rewrites75.1%
Final simplification79.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (- eh))))
(if (<= eh -2.9e-12)
t_1
(if (<= eh 2.7e-6)
(fabs (* (cos (atan (/ eh (* t ew)))) (* (sin t) ew)))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(-eh);
double tmp;
if (eh <= -2.9e-12) {
tmp = t_1;
} else if (eh <= 2.7e-6) {
tmp = fabs((cos(atan((eh / (t * ew)))) * (sin(t) * ew)));
} 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(-eh)
if (eh <= (-2.9d-12)) then
tmp = t_1
else if (eh <= 2.7d-6) then
tmp = abs((cos(atan((eh / (t * ew)))) * (sin(t) * ew)))
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(-eh);
double tmp;
if (eh <= -2.9e-12) {
tmp = t_1;
} else if (eh <= 2.7e-6) {
tmp = Math.abs((Math.cos(Math.atan((eh / (t * ew)))) * (Math.sin(t) * ew)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs(-eh) tmp = 0 if eh <= -2.9e-12: tmp = t_1 elif eh <= 2.7e-6: tmp = math.fabs((math.cos(math.atan((eh / (t * ew)))) * (math.sin(t) * ew))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(-eh)) tmp = 0.0 if (eh <= -2.9e-12) tmp = t_1; elseif (eh <= 2.7e-6) tmp = abs(Float64(cos(atan(Float64(eh / Float64(t * ew)))) * Float64(sin(t) * ew))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs(-eh); tmp = 0.0; if (eh <= -2.9e-12) tmp = t_1; elseif (eh <= 2.7e-6) tmp = abs((cos(atan((eh / (t * ew)))) * (sin(t) * ew))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[(-eh)], $MachinePrecision]}, If[LessEqual[eh, -2.9e-12], t$95$1, If[LessEqual[eh, 2.7e-6], N[Abs[N[(N[Cos[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|-eh\right|\\
\mathbf{if}\;eh \leq -2.9 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 2.7 \cdot 10^{-6}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) \cdot \left(\sin t \cdot ew\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -2.9000000000000002e-12 or 2.69999999999999998e-6 < eh Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6459.1
Applied rewrites59.1%
Taylor expanded in t around 0
Applied rewrites57.4%
Applied rewrites14.7%
Taylor expanded in eh around -inf
Applied rewrites59.3%
if -2.9000000000000002e-12 < eh < 2.69999999999999998e-6Initial program 99.7%
Taylor expanded in ew around inf
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.7%
Taylor expanded in t around 0
Applied rewrites67.8%
Final simplification63.6%
(FPCore (eh ew t) :precision binary64 (fabs (- eh)))
double code(double eh, double ew, double t) {
return fabs(-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(-eh)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(-eh);
}
def code(eh, ew, t): return math.fabs(-eh)
function code(eh, ew, t) return abs(Float64(-eh)) end
function tmp = code(eh, ew, t) tmp = abs(-eh); end
code[eh_, ew_, t_] := N[Abs[(-eh)], $MachinePrecision]
\begin{array}{l}
\\
\left|-eh\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-cos.f6441.1
Applied rewrites41.1%
Taylor expanded in t around 0
Applied rewrites39.5%
Applied rewrites13.1%
Taylor expanded in eh around -inf
Applied rewrites41.6%
herbie shell --seed 2024282
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))