
(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 13 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 (/ (/ eh ew) (tan t))))
(fabs
(+
(* (sin t) (/ ew (hypot 1.0 t_1)))
(* (* eh (cos t)) (sin (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs(((sin(t) * (ew / hypot(1.0, t_1))) + ((eh * cos(t)) * sin(atan(t_1)))));
}
public static double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / Math.tan(t);
return Math.abs(((Math.sin(t) * (ew / Math.hypot(1.0, t_1))) + ((eh * Math.cos(t)) * Math.sin(Math.atan(t_1)))));
}
def code(eh, ew, t): t_1 = (eh / ew) / math.tan(t) return math.fabs(((math.sin(t) * (ew / math.hypot(1.0, t_1))) + ((eh * math.cos(t)) * math.sin(math.atan(t_1)))))
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(sin(t) * Float64(ew / hypot(1.0, t_1))) + Float64(Float64(eh * cos(t)) * sin(atan(t_1))))) end
function tmp = code(eh, ew, t) t_1 = (eh / ew) / tan(t); tmp = abs(((sin(t) * (ew / hypot(1.0, t_1))) + ((eh * cos(t)) * sin(atan(t_1))))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * N[(ew / N[Sqrt[1.0 ^ 2 + t$95$1 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, t\_1\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t\_1\right|
\end{array}
\end{array}
Initial program 99.7%
associate-/r*99.7%
cos-atan99.7%
un-div-inv99.7%
hypot-1-def99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.7%
associate-/r*99.7%
Simplified99.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (* (cos (atan (/ eh (* t ew)))) (* (sin t) ew)))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (cos(atan((eh / (t * ew)))) * (sin(t) * ew))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (cos(atan((eh / (t * ew)))) * (sin(t) * ew))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + (Math.cos(Math.atan((eh / (t * ew)))) * (Math.sin(t) * ew))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + (math.cos(math.atan((eh / (t * ew)))) * (math.sin(t) * ew))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(cos(atan(Float64(eh / Float64(t * ew)))) * Float64(sin(t) * ew)))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (cos(atan((eh / (t * ew)))) * (sin(t) * ew)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \cos \tan^{-1} \left(\frac{eh}{t \cdot ew}\right) \cdot \left(\sin t \cdot ew\right)\right|
\end{array}
Initial program 99.7%
Taylor expanded in t around 0 98.7%
Final simplification98.7%
(FPCore (eh ew t) :precision binary64 (fabs (+ (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))) (* (sin t) ew))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (sin(t) * ew)));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (sin(t) * ew)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t))))) + (Math.sin(t) * ew)));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t))))) + (math.sin(t) * ew)))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(sin(t) * ew))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan(((eh / ew) / tan(t))))) + (sin(t) * ew))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \sin t \cdot ew\right|
\end{array}
Initial program 99.7%
associate-/r*99.7%
cos-atan99.7%
un-div-inv99.7%
hypot-1-def99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in ew around inf 97.7%
Final simplification97.7%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -1.8e+23) (not (<= ew 1.8e+88)))
(fabs (* (sin t) ew))
(fabs
(*
eh
(*
(cos t)
(sin
(atan
(* (/ eh ew) (/ (+ 1.0 (* (pow t 2.0) -0.3333333333333333)) t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.8e+23) || !(ew <= 1.8e+88)) {
tmp = fabs((sin(t) * ew));
} else {
tmp = fabs((eh * (cos(t) * sin(atan(((eh / ew) * ((1.0 + (pow(t, 2.0) * -0.3333333333333333)) / t)))))));
}
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.8d+23)) .or. (.not. (ew <= 1.8d+88))) then
tmp = abs((sin(t) * ew))
else
tmp = abs((eh * (cos(t) * sin(atan(((eh / ew) * ((1.0d0 + ((t ** 2.0d0) * (-0.3333333333333333d0))) / t)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.8e+23) || !(ew <= 1.8e+88)) {
tmp = Math.abs((Math.sin(t) * ew));
} else {
tmp = Math.abs((eh * (Math.cos(t) * Math.sin(Math.atan(((eh / ew) * ((1.0 + (Math.pow(t, 2.0) * -0.3333333333333333)) / t)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.8e+23) or not (ew <= 1.8e+88): tmp = math.fabs((math.sin(t) * ew)) else: tmp = math.fabs((eh * (math.cos(t) * math.sin(math.atan(((eh / ew) * ((1.0 + (math.pow(t, 2.0) * -0.3333333333333333)) / t))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.8e+23) || !(ew <= 1.8e+88)) tmp = abs(Float64(sin(t) * ew)); else tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh / ew) * Float64(Float64(1.0 + Float64((t ^ 2.0) * -0.3333333333333333)) / t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.8e+23) || ~((ew <= 1.8e+88))) tmp = abs((sin(t) * ew)); else tmp = abs((eh * (cos(t) * sin(atan(((eh / ew) * ((1.0 + ((t ^ 2.0) * -0.3333333333333333)) / t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.8e+23], N[Not[LessEqual[ew, 1.8e+88]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[(N[(1.0 + N[(N[Power[t, 2.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.8 \cdot 10^{+23} \lor \neg \left(ew \leq 1.8 \cdot 10^{+88}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew} \cdot \frac{1 + {t}^{2} \cdot -0.3333333333333333}{t}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -1.7999999999999999e23 or 1.8000000000000001e88 < ew Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log90.7%
add-sqr-sqrt43.6%
fabs-sqr43.6%
add-sqr-sqrt43.6%
Applied egg-rr43.6%
Taylor expanded in eh around 0 33.1%
rem-exp-log36.7%
add-sqr-sqrt36.1%
sqrt-unprod36.6%
pow236.6%
Applied egg-rr36.6%
unpow236.6%
rem-sqrt-square74.1%
Simplified74.1%
if -1.7999999999999999e23 < ew < 1.8000000000000001e88Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in ew around 0 82.7%
associate-/r*82.7%
div-inv82.7%
Applied egg-rr82.7%
Taylor expanded in t around 0 82.8%
*-commutative82.8%
Simplified82.8%
Final simplification79.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -1.02e+24) (not (<= ew 9.8e+88))) (fabs (* (sin t) ew)) (fabs (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.02e+24) || !(ew <= 9.8e+88)) {
tmp = fabs((sin(t) * ew));
} else {
tmp = fabs((eh * (cos(t) * sin(atan((eh / (ew * tan(t))))))));
}
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.02d+24)) .or. (.not. (ew <= 9.8d+88))) then
tmp = abs((sin(t) * ew))
else
tmp = abs((eh * (cos(t) * sin(atan((eh / (ew * tan(t))))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -1.02e+24) || !(ew <= 9.8e+88)) {
tmp = Math.abs((Math.sin(t) * ew));
} else {
tmp = Math.abs((eh * (Math.cos(t) * Math.sin(Math.atan((eh / (ew * Math.tan(t))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -1.02e+24) or not (ew <= 9.8e+88): tmp = math.fabs((math.sin(t) * ew)) else: tmp = math.fabs((eh * (math.cos(t) * math.sin(math.atan((eh / (ew * math.tan(t)))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -1.02e+24) || !(ew <= 9.8e+88)) tmp = abs(Float64(sin(t) * ew)); else tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -1.02e+24) || ~((ew <= 9.8e+88))) tmp = abs((sin(t) * ew)); else tmp = abs((eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -1.02e+24], N[Not[LessEqual[ew, 9.8e+88]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -1.02 \cdot 10^{+24} \lor \neg \left(ew \leq 9.8 \cdot 10^{+88}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -1.02000000000000004e24 or 9.8000000000000005e88 < ew Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log90.7%
add-sqr-sqrt43.6%
fabs-sqr43.6%
add-sqr-sqrt43.6%
Applied egg-rr43.6%
Taylor expanded in eh around 0 33.1%
rem-exp-log36.7%
add-sqr-sqrt36.1%
sqrt-unprod36.6%
pow236.6%
Applied egg-rr36.6%
unpow236.6%
rem-sqrt-square74.1%
Simplified74.1%
if -1.02000000000000004e24 < ew < 9.8000000000000005e88Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in ew around 0 82.7%
Final simplification78.9%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -0.06) (not (<= ew 1.65e+85))) (fabs (* (sin t) ew)) (fabs (* eh (* (cos t) (sin (atan (/ eh (* t ew)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -0.06) || !(ew <= 1.65e+85)) {
tmp = fabs((sin(t) * ew));
} else {
tmp = fabs((eh * (cos(t) * sin(atan((eh / (t * ew)))))));
}
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 <= (-0.06d0)) .or. (.not. (ew <= 1.65d+85))) then
tmp = abs((sin(t) * ew))
else
tmp = abs((eh * (cos(t) * sin(atan((eh / (t * ew)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -0.06) || !(ew <= 1.65e+85)) {
tmp = Math.abs((Math.sin(t) * ew));
} else {
tmp = Math.abs((eh * (Math.cos(t) * Math.sin(Math.atan((eh / (t * ew)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -0.06) or not (ew <= 1.65e+85): tmp = math.fabs((math.sin(t) * ew)) else: tmp = math.fabs((eh * (math.cos(t) * math.sin(math.atan((eh / (t * ew))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -0.06) || !(ew <= 1.65e+85)) tmp = abs(Float64(sin(t) * ew)); else tmp = abs(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(t * ew))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -0.06) || ~((ew <= 1.65e+85))) tmp = abs((sin(t) * ew)); else tmp = abs((eh * (cos(t) * sin(atan((eh / (t * ew))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -0.06], N[Not[LessEqual[ew, 1.65e+85]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -0.06 \lor \neg \left(ew \leq 1.65 \cdot 10^{+85}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\right)\right|\\
\end{array}
\end{array}
if ew < -0.059999999999999998 or 1.65e85 < ew Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log90.8%
add-sqr-sqrt43.7%
fabs-sqr43.7%
add-sqr-sqrt43.7%
Applied egg-rr43.7%
Taylor expanded in eh around 0 32.9%
rem-exp-log36.4%
add-sqr-sqrt35.7%
sqrt-unprod37.1%
pow237.1%
Applied egg-rr37.1%
unpow237.1%
rem-sqrt-square73.3%
Simplified73.3%
if -0.059999999999999998 < ew < 1.65e85Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in ew around 0 83.5%
Taylor expanded in t around 0 74.2%
Final simplification73.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -4.2e-43) (not (<= t 3.8e-45))) (fabs (* (sin t) ew)) (fabs (* eh (sin (atan (/ eh (* ew (tan t)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -4.2e-43) || !(t <= 3.8e-45)) {
tmp = fabs((sin(t) * ew));
} else {
tmp = fabs((eh * sin(atan((eh / (ew * tan(t)))))));
}
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 ((t <= (-4.2d-43)) .or. (.not. (t <= 3.8d-45))) then
tmp = abs((sin(t) * ew))
else
tmp = abs((eh * sin(atan((eh / (ew * tan(t)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -4.2e-43) || !(t <= 3.8e-45)) {
tmp = Math.abs((Math.sin(t) * ew));
} else {
tmp = Math.abs((eh * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -4.2e-43) or not (t <= 3.8e-45): tmp = math.fabs((math.sin(t) * ew)) else: tmp = math.fabs((eh * math.sin(math.atan((eh / (ew * math.tan(t))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -4.2e-43) || !(t <= 3.8e-45)) tmp = abs(Float64(sin(t) * ew)); else tmp = abs(Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -4.2e-43) || ~((t <= 3.8e-45))) tmp = abs((sin(t) * ew)); else tmp = abs((eh * sin(atan((eh / (ew * tan(t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -4.2e-43], N[Not[LessEqual[t, 3.8e-45]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.2 \cdot 10^{-43} \lor \neg \left(t \leq 3.8 \cdot 10^{-45}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\
\end{array}
\end{array}
if t < -4.2000000000000001e-43 or 3.79999999999999997e-45 < t Initial program 99.5%
associate-*l*99.5%
fma-define99.5%
associate-/r*99.5%
associate-*l*99.5%
associate-/r*99.5%
Simplified99.5%
add-exp-log90.6%
add-sqr-sqrt42.2%
fabs-sqr42.2%
add-sqr-sqrt42.2%
Applied egg-rr42.2%
Taylor expanded in eh around 0 24.1%
rem-exp-log27.1%
add-sqr-sqrt26.2%
sqrt-unprod27.4%
pow227.4%
Applied egg-rr27.4%
unpow227.4%
rem-sqrt-square56.1%
Simplified56.1%
if -4.2000000000000001e-43 < t < 3.79999999999999997e-45Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in ew around 0 74.8%
Taylor expanded in t around 0 74.8%
Final simplification64.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2.1e-139) (not (<= ew 2.15e-98))) (fabs (* (sin t) ew)) (* eh (sin (atan (/ eh (* ew (tan t))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.1e-139) || !(ew <= 2.15e-98)) {
tmp = fabs((sin(t) * ew));
} else {
tmp = eh * sin(atan((eh / (ew * tan(t)))));
}
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 <= (-2.1d-139)) .or. (.not. (ew <= 2.15d-98))) then
tmp = abs((sin(t) * ew))
else
tmp = eh * sin(atan((eh / (ew * tan(t)))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.1e-139) || !(ew <= 2.15e-98)) {
tmp = Math.abs((Math.sin(t) * ew));
} else {
tmp = eh * Math.sin(Math.atan((eh / (ew * Math.tan(t)))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.1e-139) or not (ew <= 2.15e-98): tmp = math.fabs((math.sin(t) * ew)) else: tmp = eh * math.sin(math.atan((eh / (ew * math.tan(t))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.1e-139) || !(ew <= 2.15e-98)) tmp = abs(Float64(sin(t) * ew)); else tmp = Float64(eh * sin(atan(Float64(eh / Float64(ew * tan(t)))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.1e-139) || ~((ew <= 2.15e-98))) tmp = abs((sin(t) * ew)); else tmp = eh * sin(atan((eh / (ew * tan(t))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.1e-139], N[Not[LessEqual[ew, 2.15e-98]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[(eh * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.1 \cdot 10^{-139} \lor \neg \left(ew \leq 2.15 \cdot 10^{-98}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\end{array}
\end{array}
if ew < -2.10000000000000008e-139 or 2.14999999999999994e-98 < ew Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
add-exp-log91.0%
add-sqr-sqrt45.4%
fabs-sqr45.4%
add-sqr-sqrt45.4%
Applied egg-rr45.4%
Taylor expanded in eh around 0 28.0%
rem-exp-log31.1%
add-sqr-sqrt30.4%
sqrt-unprod36.4%
pow236.4%
Applied egg-rr36.4%
unpow236.4%
rem-sqrt-square61.4%
Simplified61.4%
if -2.10000000000000008e-139 < ew < 2.14999999999999994e-98Initial program 99.6%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log90.9%
add-sqr-sqrt44.3%
fabs-sqr44.3%
add-sqr-sqrt44.3%
Applied egg-rr44.3%
Taylor expanded in t around 0 32.9%
Final simplification52.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2.4e-141) (not (<= ew 2e-98))) (fabs (* (sin t) ew)) (* eh (sin (atan (/ eh (* t ew)))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.4e-141) || !(ew <= 2e-98)) {
tmp = fabs((sin(t) * ew));
} else {
tmp = eh * sin(atan((eh / (t * ew))));
}
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 <= (-2.4d-141)) .or. (.not. (ew <= 2d-98))) then
tmp = abs((sin(t) * ew))
else
tmp = eh * sin(atan((eh / (t * ew))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.4e-141) || !(ew <= 2e-98)) {
tmp = Math.abs((Math.sin(t) * ew));
} else {
tmp = eh * Math.sin(Math.atan((eh / (t * ew))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.4e-141) or not (ew <= 2e-98): tmp = math.fabs((math.sin(t) * ew)) else: tmp = eh * math.sin(math.atan((eh / (t * ew)))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.4e-141) || !(ew <= 2e-98)) tmp = abs(Float64(sin(t) * ew)); else tmp = Float64(eh * sin(atan(Float64(eh / Float64(t * ew))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.4e-141) || ~((ew <= 2e-98))) tmp = abs((sin(t) * ew)); else tmp = eh * sin(atan((eh / (t * ew)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.4e-141], N[Not[LessEqual[ew, 2e-98]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[(eh * N[Sin[N[ArcTan[N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.4 \cdot 10^{-141} \lor \neg \left(ew \leq 2 \cdot 10^{-98}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;eh \cdot \sin \tan^{-1} \left(\frac{eh}{t \cdot ew}\right)\\
\end{array}
\end{array}
if ew < -2.4000000000000001e-141 or 1.99999999999999988e-98 < ew Initial program 99.8%
associate-*l*99.8%
fma-define99.8%
associate-/r*99.8%
associate-*l*99.8%
associate-/r*99.8%
Simplified99.8%
add-exp-log91.0%
add-sqr-sqrt45.4%
fabs-sqr45.4%
add-sqr-sqrt45.4%
Applied egg-rr45.4%
Taylor expanded in eh around 0 28.0%
rem-exp-log31.1%
add-sqr-sqrt30.4%
sqrt-unprod36.4%
pow236.4%
Applied egg-rr36.4%
unpow236.4%
rem-sqrt-square61.4%
Simplified61.4%
if -2.4000000000000001e-141 < ew < 1.99999999999999988e-98Initial program 99.6%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log90.9%
add-sqr-sqrt44.3%
fabs-sqr44.3%
add-sqr-sqrt44.3%
Applied egg-rr44.3%
Taylor expanded in t around 0 32.9%
Taylor expanded in t around 0 30.5%
Final simplification51.3%
(FPCore (eh ew t) :precision binary64 (fabs (* (sin t) ew)))
double code(double eh, double ew, double t) {
return fabs((sin(t) * ew));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((sin(t) * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.sin(t) * ew));
}
def code(eh, ew, t): return math.fabs((math.sin(t) * ew))
function code(eh, ew, t) return abs(Float64(sin(t) * ew)) end
function tmp = code(eh, ew, t) tmp = abs((sin(t) * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin t \cdot ew\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log91.0%
add-sqr-sqrt45.0%
fabs-sqr45.0%
add-sqr-sqrt45.0%
Applied egg-rr45.0%
Taylor expanded in eh around 0 20.0%
rem-exp-log22.4%
add-sqr-sqrt21.5%
sqrt-unprod26.5%
pow226.5%
Applied egg-rr26.5%
unpow226.5%
rem-sqrt-square44.3%
Simplified44.3%
Final simplification44.3%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -1.45e-5) (not (<= t 5.6))) (* (sin t) ew) (fabs (* t ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.45e-5) || !(t <= 5.6)) {
tmp = sin(t) * ew;
} else {
tmp = fabs((t * ew));
}
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 ((t <= (-1.45d-5)) .or. (.not. (t <= 5.6d0))) then
tmp = sin(t) * ew
else
tmp = abs((t * ew))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.45e-5) || !(t <= 5.6)) {
tmp = Math.sin(t) * ew;
} else {
tmp = Math.abs((t * ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -1.45e-5) or not (t <= 5.6): tmp = math.sin(t) * ew else: tmp = math.fabs((t * ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -1.45e-5) || !(t <= 5.6)) tmp = Float64(sin(t) * ew); else tmp = abs(Float64(t * ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -1.45e-5) || ~((t <= 5.6))) tmp = sin(t) * ew; else tmp = abs((t * ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -1.45e-5], N[Not[LessEqual[t, 5.6]], $MachinePrecision]], N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision], N[Abs[N[(t * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-5} \lor \neg \left(t \leq 5.6\right):\\
\;\;\;\;\sin t \cdot ew\\
\mathbf{else}:\\
\;\;\;\;\left|t \cdot ew\right|\\
\end{array}
\end{array}
if t < -1.45e-5 or 5.5999999999999996 < t Initial program 99.5%
associate-*l*99.5%
fma-define99.5%
associate-/r*99.5%
associate-*l*99.5%
associate-/r*99.5%
Simplified99.5%
add-exp-log90.6%
add-sqr-sqrt41.7%
fabs-sqr41.7%
add-sqr-sqrt41.7%
Applied egg-rr41.7%
Taylor expanded in eh around 0 22.4%
rem-exp-log25.2%
*-commutative25.2%
Applied egg-rr25.2%
if -1.45e-5 < t < 5.5999999999999996Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
associate-/r*100.0%
associate-*l*100.0%
associate-/r*100.0%
Simplified100.0%
add-exp-log91.3%
add-sqr-sqrt48.2%
fabs-sqr48.2%
add-sqr-sqrt48.2%
Applied egg-rr48.2%
Taylor expanded in eh around 0 17.6%
Taylor expanded in t around 0 19.7%
add-sqr-sqrt18.9%
sqrt-unprod26.9%
pow226.9%
Applied egg-rr26.9%
unpow226.9%
rem-sqrt-square34.1%
Simplified34.1%
Final simplification29.8%
(FPCore (eh ew t) :precision binary64 (fabs (* t ew)))
double code(double eh, double ew, double t) {
return fabs((t * ew));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((t * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((t * ew));
}
def code(eh, ew, t): return math.fabs((t * ew))
function code(eh, ew, t) return abs(Float64(t * ew)) end
function tmp = code(eh, ew, t) tmp = abs((t * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(t * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|t \cdot ew\right|
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log91.0%
add-sqr-sqrt45.0%
fabs-sqr45.0%
add-sqr-sqrt45.0%
Applied egg-rr45.0%
Taylor expanded in eh around 0 20.0%
Taylor expanded in t around 0 12.4%
add-sqr-sqrt11.7%
sqrt-unprod16.9%
pow216.9%
Applied egg-rr16.9%
unpow216.9%
rem-sqrt-square21.0%
Simplified21.0%
Final simplification21.0%
(FPCore (eh ew t) :precision binary64 (* t ew))
double code(double eh, double ew, double t) {
return t * ew;
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = t * ew
end function
public static double code(double eh, double ew, double t) {
return t * ew;
}
def code(eh, ew, t): return t * ew
function code(eh, ew, t) return Float64(t * ew) end
function tmp = code(eh, ew, t) tmp = t * ew; end
code[eh_, ew_, t_] := N[(t * ew), $MachinePrecision]
\begin{array}{l}
\\
t \cdot ew
\end{array}
Initial program 99.7%
associate-*l*99.7%
fma-define99.7%
associate-/r*99.7%
associate-*l*99.7%
associate-/r*99.7%
Simplified99.7%
add-exp-log91.0%
add-sqr-sqrt45.0%
fabs-sqr45.0%
add-sqr-sqrt45.0%
Applied egg-rr45.0%
Taylor expanded in eh around 0 20.0%
Taylor expanded in t around 0 12.4%
Final simplification12.4%
herbie shell --seed 2024121
(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))))))))