
(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 10 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 (- (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(eh * Float64(-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{eh \cdot \left(-\tan t\right)}{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}
Initial program 99.9%
Final simplification99.9%
(FPCore (eh ew t) :precision binary64 (fabs (- (/ 1.0 (/ (hypot 1.0 (* (tan t) (/ eh ew))) (* ew (cos t)))) (* (* eh (sin t)) (sin (atan (/ (* eh (- (tan t))) ew)))))))
double code(double eh, double ew, double t) {
return fabs(((1.0 / (hypot(1.0, (tan(t) * (eh / ew))) / (ew * cos(t)))) - ((eh * sin(t)) * sin(atan(((eh * -tan(t)) / ew))))));
}
public static double code(double eh, double ew, double t) {
return Math.abs(((1.0 / (Math.hypot(1.0, (Math.tan(t) * (eh / ew))) / (ew * Math.cos(t)))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * -Math.tan(t)) / ew))))));
}
def code(eh, ew, t): return math.fabs(((1.0 / (math.hypot(1.0, (math.tan(t) * (eh / ew))) / (ew * math.cos(t)))) - ((eh * math.sin(t)) * math.sin(math.atan(((eh * -math.tan(t)) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(1.0 / Float64(hypot(1.0, Float64(tan(t) * Float64(eh / ew))) / Float64(ew * cos(t)))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * Float64(-tan(t))) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs(((1.0 / (hypot(1.0, (tan(t) * (eh / ew))) / (ew * cos(t)))) - ((eh * sin(t)) * sin(atan(((eh * -tan(t)) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(1.0 / N[(N[Sqrt[1.0 ^ 2 + N[(N[Tan[t], $MachinePrecision] * N[(eh / ew), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * (-N[Tan[t], $MachinePrecision])), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\frac{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)}{ew \cdot \cos t}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\right|
\end{array}
Initial program 99.9%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
rem-cube-cbrt99.9%
clear-num99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* ew (cos t)) (* eh (* (sin t) (sin (atan (/ (* eh (- (tan t))) ew))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) - (eh * (sin(t) * sin(atan(((eh * -tan(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(((ew * cos(t)) - (eh * (sin(t) * sin(atan(((eh * -tan(t)) / ew)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.cos(t)) - (eh * (Math.sin(t) * Math.sin(Math.atan(((eh * -Math.tan(t)) / ew)))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.cos(t)) - (eh * (math.sin(t) * math.sin(math.atan(((eh * -math.tan(t)) / ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * cos(t)) - Float64(eh * Float64(sin(t) * sin(atan(Float64(Float64(eh * Float64(-tan(t))) / ew))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) - (eh * (sin(t) * sin(atan(((eh * -tan(t)) / ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] - N[(eh * N[(N[Sin[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * (-N[Tan[t], $MachinePrecision])), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \cos t - eh \cdot \left(\sin t \cdot \sin \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\right)\right|
\end{array}
Initial program 99.9%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
Taylor expanded in eh around 0 97.7%
Final simplification97.7%
(FPCore (eh ew t) :precision binary64 (fabs (- (* ew (cos t)) (* (* eh (sin t)) (sin (atan (* eh (/ (tan t) (- ew)))))))))
double code(double eh, double ew, double t) {
return fabs(((ew * cos(t)) - ((eh * sin(t)) * sin(atan((eh * (tan(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(((ew * cos(t)) - ((eh * sin(t)) * sin(atan((eh * (tan(t) / -ew)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew * Math.cos(t)) - ((eh * Math.sin(t)) * Math.sin(Math.atan((eh * (Math.tan(t) / -ew)))))));
}
def code(eh, ew, t): return math.fabs(((ew * math.cos(t)) - ((eh * math.sin(t)) * math.sin(math.atan((eh * (math.tan(t) / -ew)))))))
function code(eh, ew, t) return abs(Float64(Float64(ew * cos(t)) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew)))))))) end
function tmp = code(eh, ew, t) tmp = abs(((ew * cos(t)) - ((eh * sin(t)) * sin(atan((eh * (tan(t) / -ew))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \cos t - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right)\right|
\end{array}
Initial program 99.9%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
rem-cube-cbrt99.9%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in eh around 0 97.7%
mul-1-neg97.7%
+-commutative97.7%
*-commutative97.7%
mul-1-neg97.7%
associate-/l*97.7%
distribute-lft-neg-out97.7%
*-commutative97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (eh ew t)
:precision binary64
(if (<= t -0.6)
(fabs (* ew (cos t)))
(if (<= t 0.0011)
(fabs (- ew (* (sin (atan (* eh (/ (tan t) (- ew))))) (* t eh))))
(fabs (* (* eh (sin t)) (sin (atan (* t (/ eh (- ew))))))))))
double code(double eh, double ew, double t) {
double tmp;
if (t <= -0.6) {
tmp = fabs((ew * cos(t)));
} else if (t <= 0.0011) {
tmp = fabs((ew - (sin(atan((eh * (tan(t) / -ew)))) * (t * eh))));
} else {
tmp = fabs(((eh * sin(t)) * sin(atan((t * (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 <= (-0.6d0)) then
tmp = abs((ew * cos(t)))
else if (t <= 0.0011d0) then
tmp = abs((ew - (sin(atan((eh * (tan(t) / -ew)))) * (t * eh))))
else
tmp = abs(((eh * sin(t)) * sin(atan((t * (eh / -ew))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (t <= -0.6) {
tmp = Math.abs((ew * Math.cos(t)));
} else if (t <= 0.0011) {
tmp = Math.abs((ew - (Math.sin(Math.atan((eh * (Math.tan(t) / -ew)))) * (t * eh))));
} else {
tmp = Math.abs(((eh * Math.sin(t)) * Math.sin(Math.atan((t * (eh / -ew))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if t <= -0.6: tmp = math.fabs((ew * math.cos(t))) elif t <= 0.0011: tmp = math.fabs((ew - (math.sin(math.atan((eh * (math.tan(t) / -ew)))) * (t * eh)))) else: tmp = math.fabs(((eh * math.sin(t)) * math.sin(math.atan((t * (eh / -ew)))))) return tmp
function code(eh, ew, t) tmp = 0.0 if (t <= -0.6) tmp = abs(Float64(ew * cos(t))); elseif (t <= 0.0011) tmp = abs(Float64(ew - Float64(sin(atan(Float64(eh * Float64(tan(t) / Float64(-ew))))) * Float64(t * eh)))); else tmp = abs(Float64(Float64(eh * sin(t)) * sin(atan(Float64(t * Float64(eh / Float64(-ew))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (t <= -0.6) tmp = abs((ew * cos(t))); elseif (t <= 0.0011) tmp = abs((ew - (sin(atan((eh * (tan(t) / -ew)))) * (t * eh)))); else tmp = abs(((eh * sin(t)) * sin(atan((t * (eh / -ew)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[t, -0.6], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 0.0011], N[Abs[N[(ew - N[(N[Sin[N[ArcTan[N[(eh * N[(N[Tan[t], $MachinePrecision] / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(t * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(t * N[(eh / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.6:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{elif}\;t \leq 0.0011:\\
\;\;\;\;\left|ew - \sin \tan^{-1} \left(eh \cdot \frac{\tan t}{-ew}\right) \cdot \left(t \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(t \cdot \frac{eh}{-ew}\right)\right|\\
\end{array}
\end{array}
if t < -0.599999999999999978Initial program 99.8%
add-cube-cbrt98.6%
pow398.6%
Applied egg-rr98.6%
Taylor expanded in ew around inf 59.1%
if -0.599999999999999978 < t < 0.00110000000000000007Initial program 100.0%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
rem-cube-cbrt100.0%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in t around 0 97.0%
mul-1-neg97.0%
unsub-neg97.0%
associate-*r*97.0%
mul-1-neg97.0%
associate-/l*97.0%
distribute-lft-neg-out97.0%
distribute-lft-neg-out97.0%
distribute-rgt-neg-in97.0%
Simplified97.0%
if 0.00110000000000000007 < t Initial program 99.7%
Taylor expanded in ew around inf 92.3%
+-commutative92.3%
mul-1-neg92.3%
unsub-neg92.3%
Simplified92.0%
Taylor expanded in eh around inf 47.4%
associate-*r/47.4%
associate-*r*47.4%
neg-mul-147.4%
mul-1-neg47.4%
*-commutative47.4%
associate-*r/47.4%
*-commutative47.4%
distribute-rgt-neg-out47.4%
Simplified47.4%
Taylor expanded in t around 0 47.8%
mul-1-neg47.8%
associate-/l*47.8%
Simplified47.8%
Taylor expanded in ew around 0 55.3%
mul-1-neg55.3%
fabs-neg55.3%
associate-*r*55.3%
distribute-neg-frac255.3%
*-commutative55.3%
associate-/l*55.3%
Simplified55.3%
Final simplification79.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (- ew))))
(if (<= t -0.6)
(fabs (* ew (cos t)))
(if (<= t 0.00026)
(fabs (+ ew (* eh (* t (sin (atan (* (tan t) t_1)))))))
(fabs (* (* eh (sin t)) (sin (atan (* t t_1)))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / -ew;
double tmp;
if (t <= -0.6) {
tmp = fabs((ew * cos(t)));
} else if (t <= 0.00026) {
tmp = fabs((ew + (eh * (t * sin(atan((tan(t) * t_1)))))));
} else {
tmp = fabs(((eh * sin(t)) * sin(atan((t * 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 = eh / -ew
if (t <= (-0.6d0)) then
tmp = abs((ew * cos(t)))
else if (t <= 0.00026d0) then
tmp = abs((ew + (eh * (t * sin(atan((tan(t) * t_1)))))))
else
tmp = abs(((eh * sin(t)) * sin(atan((t * t_1)))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = eh / -ew;
double tmp;
if (t <= -0.6) {
tmp = Math.abs((ew * Math.cos(t)));
} else if (t <= 0.00026) {
tmp = Math.abs((ew + (eh * (t * Math.sin(Math.atan((Math.tan(t) * t_1)))))));
} else {
tmp = Math.abs(((eh * Math.sin(t)) * Math.sin(Math.atan((t * t_1)))));
}
return tmp;
}
def code(eh, ew, t): t_1 = eh / -ew tmp = 0 if t <= -0.6: tmp = math.fabs((ew * math.cos(t))) elif t <= 0.00026: tmp = math.fabs((ew + (eh * (t * math.sin(math.atan((math.tan(t) * t_1))))))) else: tmp = math.fabs(((eh * math.sin(t)) * math.sin(math.atan((t * t_1))))) return tmp
function code(eh, ew, t) t_1 = Float64(eh / Float64(-ew)) tmp = 0.0 if (t <= -0.6) tmp = abs(Float64(ew * cos(t))); elseif (t <= 0.00026) tmp = abs(Float64(ew + Float64(eh * Float64(t * sin(atan(Float64(tan(t) * t_1))))))); else tmp = abs(Float64(Float64(eh * sin(t)) * sin(atan(Float64(t * t_1))))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh / -ew; tmp = 0.0; if (t <= -0.6) tmp = abs((ew * cos(t))); elseif (t <= 0.00026) tmp = abs((ew + (eh * (t * sin(atan((tan(t) * t_1))))))); else tmp = abs(((eh * sin(t)) * sin(atan((t * t_1))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / (-ew)), $MachinePrecision]}, If[LessEqual[t, -0.6], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 0.00026], N[Abs[N[(ew + N[(eh * N[(t * N[Sin[N[ArcTan[N[(N[Tan[t], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(t * t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{-ew}\\
\mathbf{if}\;t \leq -0.6:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{elif}\;t \leq 0.00026:\\
\;\;\;\;\left|ew + eh \cdot \left(t \cdot \sin \tan^{-1} \left(\tan t \cdot t\_1\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(t \cdot t\_1\right)\right|\\
\end{array}
\end{array}
if t < -0.599999999999999978Initial program 99.8%
add-cube-cbrt98.6%
pow398.6%
Applied egg-rr98.6%
Taylor expanded in ew around inf 59.1%
if -0.599999999999999978 < t < 2.59999999999999977e-4Initial program 100.0%
fabs-sub100.0%
sub-neg100.0%
+-commutative100.0%
associate-*l*100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
Simplified100.0%
add-log-exp100.0%
*-commutative100.0%
cos-atan100.0%
un-div-inv100.0%
add-sqr-sqrt0.0%
sqrt-unprod98.6%
sqr-neg98.6%
sqrt-unprod98.6%
add-sqr-sqrt98.6%
hypot-1-def98.6%
associate-*r/98.6%
*-commutative98.6%
associate-/l*98.6%
Applied egg-rr98.6%
Taylor expanded in t around 0 97.0%
mul-1-neg97.0%
*-commutative97.0%
associate-*r/97.0%
*-commutative97.0%
distribute-rgt-neg-out97.0%
Simplified97.0%
if 2.59999999999999977e-4 < t Initial program 99.7%
Taylor expanded in ew around inf 92.3%
+-commutative92.3%
mul-1-neg92.3%
unsub-neg92.3%
Simplified92.0%
Taylor expanded in eh around inf 47.4%
associate-*r/47.4%
associate-*r*47.4%
neg-mul-147.4%
mul-1-neg47.4%
*-commutative47.4%
associate-*r/47.4%
*-commutative47.4%
distribute-rgt-neg-out47.4%
Simplified47.4%
Taylor expanded in t around 0 47.8%
mul-1-neg47.8%
associate-/l*47.8%
Simplified47.8%
Taylor expanded in ew around 0 55.3%
mul-1-neg55.3%
fabs-neg55.3%
associate-*r*55.3%
distribute-neg-frac255.3%
*-commutative55.3%
associate-/l*55.3%
Simplified55.3%
Final simplification79.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -7.5e-141) (not (<= ew 1.7e-146))) (fabs (* ew (cos t))) (fabs (* (* eh (sin t)) (sin (atan (* t (/ eh (- ew)))))))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -7.5e-141) || !(ew <= 1.7e-146)) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs(((eh * sin(t)) * sin(atan((t * (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 ((ew <= (-7.5d-141)) .or. (.not. (ew <= 1.7d-146))) then
tmp = abs((ew * cos(t)))
else
tmp = abs(((eh * sin(t)) * sin(atan((t * (eh / -ew))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -7.5e-141) || !(ew <= 1.7e-146)) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs(((eh * Math.sin(t)) * Math.sin(Math.atan((t * (eh / -ew))))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -7.5e-141) or not (ew <= 1.7e-146): tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs(((eh * math.sin(t)) * math.sin(math.atan((t * (eh / -ew)))))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -7.5e-141) || !(ew <= 1.7e-146)) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(Float64(eh * sin(t)) * sin(atan(Float64(t * Float64(eh / Float64(-ew))))))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -7.5e-141) || ~((ew <= 1.7e-146))) tmp = abs((ew * cos(t))); else tmp = abs(((eh * sin(t)) * sin(atan((t * (eh / -ew)))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -7.5e-141], N[Not[LessEqual[ew, 1.7e-146]], $MachinePrecision]], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(t * N[(eh / (-ew)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -7.5 \cdot 10^{-141} \lor \neg \left(ew \leq 1.7 \cdot 10^{-146}\right):\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(t \cdot \frac{eh}{-ew}\right)\right|\\
\end{array}
\end{array}
if ew < -7.50000000000000046e-141 or 1.7e-146 < ew Initial program 99.9%
add-cube-cbrt98.4%
pow398.4%
Applied egg-rr98.4%
Taylor expanded in ew around inf 78.2%
if -7.50000000000000046e-141 < ew < 1.7e-146Initial program 99.9%
Taylor expanded in ew around inf 82.1%
+-commutative82.1%
mul-1-neg82.1%
unsub-neg82.1%
Simplified82.0%
Taylor expanded in eh around inf 56.7%
associate-*r/56.7%
associate-*r*56.7%
neg-mul-156.7%
mul-1-neg56.7%
*-commutative56.7%
associate-*r/56.7%
*-commutative56.7%
distribute-rgt-neg-out56.7%
Simplified56.7%
Taylor expanded in t around 0 56.8%
mul-1-neg56.8%
associate-/l*56.8%
Simplified56.8%
Taylor expanded in ew around 0 74.5%
mul-1-neg74.5%
fabs-neg74.5%
associate-*r*74.5%
distribute-neg-frac274.5%
*-commutative74.5%
associate-/l*74.5%
Simplified74.5%
Final simplification77.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -1.26e+237) (not (<= eh 2.2e+157))) (fabs (* eh (* t (sin (atan (/ (* t eh) (- ew))))))) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -1.26e+237) || !(eh <= 2.2e+157)) {
tmp = fabs((eh * (t * sin(atan(((t * eh) / -ew))))));
} 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.26d+237)) .or. (.not. (eh <= 2.2d+157))) then
tmp = abs((eh * (t * sin(atan(((t * eh) / -ew))))))
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.26e+237) || !(eh <= 2.2e+157)) {
tmp = Math.abs((eh * (t * Math.sin(Math.atan(((t * eh) / -ew))))));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -1.26e+237) or not (eh <= 2.2e+157): tmp = math.fabs((eh * (t * math.sin(math.atan(((t * eh) / -ew)))))) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -1.26e+237) || !(eh <= 2.2e+157)) tmp = abs(Float64(eh * Float64(t * sin(atan(Float64(Float64(t * eh) / Float64(-ew))))))); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -1.26e+237) || ~((eh <= 2.2e+157))) tmp = abs((eh * (t * sin(atan(((t * eh) / -ew)))))); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -1.26e+237], N[Not[LessEqual[eh, 2.2e+157]], $MachinePrecision]], N[Abs[N[(eh * N[(t * N[Sin[N[ArcTan[N[(N[(t * eh), $MachinePrecision] / (-ew)), $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.26 \cdot 10^{+237} \lor \neg \left(eh \leq 2.2 \cdot 10^{+157}\right):\\
\;\;\;\;\left|eh \cdot \left(t \cdot \sin \tan^{-1} \left(\frac{t \cdot eh}{-ew}\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -1.2599999999999999e237 or 2.2000000000000001e157 < eh Initial program 99.9%
Taylor expanded in ew around inf 69.6%
+-commutative69.6%
mul-1-neg69.6%
unsub-neg69.6%
Simplified69.2%
Taylor expanded in eh around inf 61.2%
associate-*r/61.2%
associate-*r*61.2%
neg-mul-161.2%
mul-1-neg61.2%
*-commutative61.2%
associate-*r/61.2%
*-commutative61.2%
distribute-rgt-neg-out61.2%
Simplified61.2%
Taylor expanded in t around 0 61.2%
mul-1-neg61.2%
associate-/l*61.2%
Simplified61.2%
Taylor expanded in t around 0 59.2%
associate-*r*59.2%
neg-mul-159.2%
distribute-neg-frac259.2%
*-commutative59.2%
Simplified59.2%
if -1.2599999999999999e237 < eh < 2.2000000000000001e157Initial program 99.9%
add-cube-cbrt98.6%
pow398.6%
Applied egg-rr98.6%
Taylor expanded in ew around inf 70.4%
Final simplification68.9%
(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.9%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
Taylor expanded in ew around inf 62.8%
(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.9%
add-cube-cbrt98.7%
pow398.7%
Applied egg-rr98.7%
Taylor expanded in t around 0 44.1%
herbie shell --seed 2024163
(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)))))))