
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (- eh) (/ ew (tan t)))))) (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 / (ew / tan(t))));
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 / (ew / tan(t))))
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 / (ew / Math.tan(t))));
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 / (ew / math.tan(t)))) 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(-eh) / Float64(ew / tan(t)))) return abs(Float64(Float64(ew * Float64(cos(t) * cos(t_1))) - Float64(eh * Float64(sin(t) * sin(t_1))))) end
function tmp = code(eh, ew, t) t_1 = atan((-eh / (ew / tan(t)))); 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[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(ew * N[(N[Cos[t], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\\
\left|ew \cdot \left(\cos t \cdot \cos t_1\right) - eh \cdot \left(\sin t \cdot \sin t_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (/ ew (/ (hypot 1.0 (* (tan t) (/ eh ew))) (cos t))) (* eh (* (sin t) (sin (atan (/ (- eh) (/ ew (tan t))))))))))
double code(double eh, double ew, double t) {
return fabs(((ew / (hypot(1.0, (tan(t) * (eh / ew))) / cos(t))) - (eh * (sin(t) * sin(atan((-eh / (ew / tan(t)))))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((ew / (Math.hypot(1.0, (Math.tan(t) * (eh / ew))) / Math.cos(t))) - (eh * (Math.sin(t) * Math.sin(Math.atan((-eh / (ew / Math.tan(t)))))))));
}
def code(eh, ew, t): return math.fabs(((ew / (math.hypot(1.0, (math.tan(t) * (eh / ew))) / math.cos(t))) - (eh * (math.sin(t) * math.sin(math.atan((-eh / (ew / math.tan(t)))))))))
function code(eh, ew, t) return abs(Float64(Float64(ew / Float64(hypot(1.0, Float64(tan(t) * Float64(eh / ew))) / cos(t))) - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t))))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew / (hypot(1.0, (tan(t) * (eh / ew))) / cos(t))) - (eh * (sin(t) * sin(atan((-eh / (ew / tan(t))))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew / N[(N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew}{\frac{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}{\cos t}} - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right)\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
expm1-log1p-u72.3%
expm1-udef54.8%
Applied egg-rr56.7%
expm1-def74.2%
expm1-log1p99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(if (<= eh -1.7e+116)
(fabs (- ew (* eh (* (sin t) (sin (atan (/ (- t) (/ ew eh))))))))
(if (<= eh 5.5e-130)
(fabs (* ew (cos t)))
(fabs (- ew (* eh (* (sin t) (sin (atan (/ (- eh) (/ ew (tan t))))))))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.7e+116) {
tmp = fabs((ew - (eh * (sin(t) * sin(atan((-t / (ew / eh))))))));
} else if (eh <= 5.5e-130) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((ew - (eh * (sin(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 (eh <= (-1.7d+116)) then
tmp = abs((ew - (eh * (sin(t) * sin(atan((-t / (ew / eh))))))))
else if (eh <= 5.5d-130) then
tmp = abs((ew * cos(t)))
else
tmp = abs((ew - (eh * (sin(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 (eh <= -1.7e+116) {
tmp = Math.abs((ew - (eh * (Math.sin(t) * Math.sin(Math.atan((-t / (ew / eh))))))));
} else if (eh <= 5.5e-130) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((ew - (eh * (Math.sin(t) * Math.sin(Math.atan((-eh / (ew / Math.tan(t)))))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -1.7e+116: tmp = math.fabs((ew - (eh * (math.sin(t) * math.sin(math.atan((-t / (ew / eh)))))))) elif eh <= 5.5e-130: tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((ew - (eh * (math.sin(t) * math.sin(math.atan((-eh / (ew / math.tan(t))))))))) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -1.7e+116) tmp = abs(Float64(ew - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(-t) / Float64(ew / eh)))))))); elseif (eh <= 5.5e-130) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(ew - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(-eh) / Float64(ew / tan(t))))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -1.7e+116) tmp = abs((ew - (eh * (sin(t) * sin(atan((-t / (ew / eh)))))))); elseif (eh <= 5.5e-130) tmp = abs((ew * cos(t))); else tmp = abs((ew - (eh * (sin(t) * sin(atan((-eh / (ew / tan(t))))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -1.7e+116], N[Abs[N[(ew - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-t) / N[(ew / eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 5.5e-130], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-eh) / N[(ew / N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.7 \cdot 10^{+116}:\\
\;\;\;\;\left|ew - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{-t}{\frac{ew}{eh}}\right)\right)\right|\\
\mathbf{elif}\;eh \leq 5.5 \cdot 10^{-130}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{-eh}{\frac{ew}{\tan t}}\right)\right)\right|\\
\end{array}
\end{array}
if eh < -1.70000000000000011e116Initial program 99.9%
fabs-neg99.9%
sub0-neg99.9%
sub-neg99.9%
+-commutative99.9%
associate--r+99.9%
Simplified99.9%
expm1-log1p-u85.6%
expm1-udef84.9%
Applied egg-rr87.2%
expm1-def87.9%
expm1-log1p99.9%
associate-*r/99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in t around 0 98.1%
Taylor expanded in t around 0 98.1%
mul-1-neg98.1%
associate-/l*98.1%
distribute-neg-frac98.1%
Simplified98.1%
if -1.70000000000000011e116 < eh < 5.50000000000000007e-130Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
add-cube-cbrt98.2%
pow398.3%
Applied egg-rr98.3%
sin-mult85.8%
associate-*r/85.8%
Applied egg-rr85.5%
+-inverses85.5%
mul0-rgt85.5%
metadata-eval85.5%
Simplified85.5%
Taylor expanded in eh around 0 87.1%
pow-base-187.1%
*-rgt-identity87.1%
*-commutative87.1%
Simplified87.1%
if 5.50000000000000007e-130 < eh Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
expm1-log1p-u75.4%
expm1-udef62.0%
Applied egg-rr66.5%
expm1-def80.0%
expm1-log1p99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 90.8%
Final simplification90.3%
(FPCore (eh ew t) :precision binary64 (fabs (+ (/ (* ew (cos t)) (hypot 1.0 (* (tan t) (/ eh ew)))) (* eh (sin t)))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) / hypot(1.0, (tan(t) * (eh / ew)))) + (eh * sin(t))));
}
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) / Math.hypot(1.0, (Math.tan(t) * (eh / ew)))) + (eh * Math.sin(t))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) / math.hypot(1.0, (math.tan(t) * (eh / ew)))) + (eh * math.sin(t))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) / hypot(1.0, Float64(tan(t) * Float64(eh / ew)))) + Float64(eh * sin(t)))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) / hypot(1.0, (tan(t) * (eh / ew)))) + (eh * sin(t)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{ew \cdot \cos t}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)} + eh \cdot \sin t\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
associate-*r*99.8%
sin-atan80.0%
associate-*r/78.0%
associate-/r/75.6%
*-commutative75.6%
add-sqr-sqrt34.9%
sqrt-unprod67.6%
sqr-neg67.6%
sqrt-unprod40.1%
add-sqr-sqrt74.8%
hypot-1-def79.0%
associate-/r/79.0%
*-commutative79.0%
Applied egg-rr79.0%
Taylor expanded in eh around -inf 98.8%
mul-1-neg98.8%
distribute-rgt-neg-out98.8%
Simplified98.8%
expm1-log1p-u72.3%
expm1-udef54.8%
Applied egg-rr56.8%
expm1-def73.6%
expm1-log1p98.8%
associate-*r/98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -1.7e+116) (not (<= eh 9.2e-131))) (fabs (- ew (* eh (* (sin t) (sin (atan (/ (- t) (/ ew eh)))))))) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.7e+116) || !(eh <= 9.2e-131)) {
tmp = fabs((ew - (eh * (sin(t) * sin(atan((-t / (ew / eh))))))));
} else {
tmp = fabs((ew * cos(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 ((eh <= (-1.7d+116)) .or. (.not. (eh <= 9.2d-131))) then
tmp = abs((ew - (eh * (sin(t) * sin(atan((-t / (ew / eh))))))))
else
tmp = abs((ew * cos(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.7e+116) || !(eh <= 9.2e-131)) {
tmp = Math.abs((ew - (eh * (Math.sin(t) * Math.sin(Math.atan((-t / (ew / eh))))))));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -1.7e+116) or not (eh <= 9.2e-131): tmp = math.fabs((ew - (eh * (math.sin(t) * math.sin(math.atan((-t / (ew / eh)))))))) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -1.7e+116) || !(eh <= 9.2e-131)) tmp = abs(Float64(ew - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(-t) / Float64(ew / eh)))))))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -1.7e+116) || ~((eh <= 9.2e-131))) tmp = abs((ew - (eh * (sin(t) * sin(atan((-t / (ew / eh)))))))); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -1.7e+116], N[Not[LessEqual[eh, 9.2e-131]], $MachinePrecision]], N[Abs[N[(ew - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[((-t) / N[(ew / eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.7 \cdot 10^{+116} \lor \neg \left(eh \leq 9.2 \cdot 10^{-131}\right):\\
\;\;\;\;\left|ew - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{-t}{\frac{ew}{eh}}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -1.70000000000000011e116 or 9.20000000000000087e-131 < eh Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
expm1-log1p-u78.8%
expm1-udef69.5%
Applied egg-rr73.4%
expm1-def82.6%
expm1-log1p99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 93.3%
Taylor expanded in t around 0 93.3%
mul-1-neg93.3%
associate-/l*93.3%
distribute-neg-frac93.3%
Simplified93.3%
if -1.70000000000000011e116 < eh < 9.20000000000000087e-131Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
add-cube-cbrt98.2%
pow398.3%
Applied egg-rr98.3%
sin-mult85.8%
associate-*r/85.8%
Applied egg-rr85.5%
+-inverses85.5%
mul0-rgt85.5%
metadata-eval85.5%
Simplified85.5%
Taylor expanded in eh around 0 87.1%
pow-base-187.1%
*-rgt-identity87.1%
*-commutative87.1%
Simplified87.1%
Final simplification90.2%
(FPCore (eh ew t) :precision binary64 (if (or (<= t -7000000000000.0) (not (<= t 1.05e-10))) (fabs (* ew (cos t))) (fabs (- (* t (* eh (sin (atan (/ (- t) (/ ew eh)))))) ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -7000000000000.0) || !(t <= 1.05e-10)) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs(((t * (eh * sin(atan((-t / (ew / eh)))))) - 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 <= (-7000000000000.0d0)) .or. (.not. (t <= 1.05d-10))) then
tmp = abs((ew * cos(t)))
else
tmp = abs(((t * (eh * sin(atan((-t / (ew / eh)))))) - ew))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((t <= -7000000000000.0) || !(t <= 1.05e-10)) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs(((t * (eh * Math.sin(Math.atan((-t / (ew / eh)))))) - ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (t <= -7000000000000.0) or not (t <= 1.05e-10): tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs(((t * (eh * math.sin(math.atan((-t / (ew / eh)))))) - ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((t <= -7000000000000.0) || !(t <= 1.05e-10)) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(Float64(t * Float64(eh * sin(atan(Float64(Float64(-t) / Float64(ew / eh)))))) - ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((t <= -7000000000000.0) || ~((t <= 1.05e-10))) tmp = abs((ew * cos(t))); else tmp = abs(((t * (eh * sin(atan((-t / (ew / eh)))))) - ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -7000000000000.0], N[Not[LessEqual[t, 1.05e-10]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(t * N[(eh * N[Sin[N[ArcTan[N[((-t) / N[(ew / eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7000000000000 \lor \neg \left(t \leq 1.05 \cdot 10^{-10}\right):\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{-t}{\frac{ew}{eh}}\right)\right) - ew\right|\\
\end{array}
\end{array}
if t < -7e12 or 1.05e-10 < t Initial program 99.6%
fabs-neg99.6%
sub0-neg99.6%
sub-neg99.6%
+-commutative99.6%
associate--r+99.6%
Simplified99.6%
add-cube-cbrt98.8%
pow398.8%
Applied egg-rr98.8%
sin-mult57.5%
associate-*r/57.5%
Applied egg-rr56.0%
+-inverses56.0%
mul0-rgt56.0%
metadata-eval56.0%
Simplified56.0%
Taylor expanded in eh around 0 57.3%
pow-base-157.3%
*-rgt-identity57.3%
*-commutative57.3%
Simplified57.3%
if -7e12 < t < 1.05e-10Initial program 100.0%
fabs-neg100.0%
sub0-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
expm1-log1p-u72.0%
expm1-udef51.6%
Applied egg-rr52.4%
expm1-def72.7%
expm1-log1p100.0%
associate-*r/100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in t around 0 98.4%
Taylor expanded in t around 0 96.6%
*-commutative96.6%
associate-*l*96.6%
associate-*r/96.6%
neg-mul-196.6%
distribute-rgt-neg-in96.6%
Simplified96.6%
Taylor expanded in t around 0 96.6%
mul-1-neg96.6%
associate-/l*96.6%
distribute-neg-frac96.6%
Simplified96.6%
Final simplification78.4%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (cos t))))
double code(double eh, double ew, double t) {
return fabs((ew * cos(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)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.cos(t)))
function code(eh, ew, t) return abs(Float64(ew * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \cos t\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
add-cube-cbrt98.6%
pow398.7%
Applied egg-rr98.7%
sin-mult66.2%
associate-*r/66.2%
Applied egg-rr64.1%
+-inverses64.1%
mul0-rgt64.1%
metadata-eval64.1%
Simplified64.1%
Taylor expanded in eh around 0 65.7%
pow-base-165.7%
*-rgt-identity65.7%
*-commutative65.7%
Simplified65.7%
Final simplification65.7%
(FPCore (eh ew t) :precision binary64 (fabs ew))
double code(double eh, double ew, double t) {
return fabs(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(ew)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(ew);
}
def code(eh, ew, t): return math.fabs(ew)
function code(eh, ew, t) return abs(ew) end
function tmp = code(eh, ew, t) tmp = abs(ew); end
code[eh_, ew_, t_] := N[Abs[ew], $MachinePrecision]
\begin{array}{l}
\\
\left|ew\right|
\end{array}
Initial program 99.8%
fabs-neg99.8%
sub0-neg99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
Simplified99.8%
expm1-log1p-u72.3%
expm1-udef54.8%
Applied egg-rr56.7%
expm1-def74.2%
expm1-log1p99.8%
associate-*r/99.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 78.8%
Taylor expanded in t around 0 58.2%
*-commutative58.2%
associate-*l*58.2%
associate-*r/58.2%
neg-mul-158.2%
distribute-rgt-neg-in58.2%
Simplified58.2%
Taylor expanded in ew around inf 45.7%
Final simplification45.7%
herbie shell --seed 2023222
(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)))))))