
(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))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
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 12 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))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
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 (- (* (* eh (sin t)) (sin t_1)) (* (* ew (cos t)) (cos t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
return fabs((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(t_1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
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((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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((((eh * Math.sin(t)) * Math.sin(t_1)) - ((ew * Math.cos(t)) * Math.cos(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) return math.fabs((((eh * math.sin(t)) * math.sin(t_1)) - ((ew * math.cos(t)) * math.cos(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(t_1)) - Float64(Float64(ew * cos(t)) * cos(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = abs((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\left|\left(eh \cdot \sin t\right) \cdot \sin t\_1 - \left(ew \cdot \cos t\right) \cdot \cos t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (tan t) ew))
(t_2 (atan (* t_1 eh)))
(t_3 (atan (/ (* eh (tan t)) (- ew)))))
(if (<=
(- (* (* ew (cos t)) (cos t_3)) (* (* eh (sin t)) (sin t_3)))
-1e-283)
(fabs
(*
(fma
(/ eh ew)
(* (- (sin t)) (tanh (asinh (* t_1 (- eh)))))
(* (cos (atan (* (- eh) (/ t ew)))) (cos t)))
ew))
(fma (* (sin t_2) (sin t)) eh (* (* (cos t) ew) (cos t_2))))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) / ew;
double t_2 = atan((t_1 * eh));
double t_3 = atan(((eh * tan(t)) / -ew));
double tmp;
if ((((ew * cos(t)) * cos(t_3)) - ((eh * sin(t)) * sin(t_3))) <= -1e-283) {
tmp = fabs((fma((eh / ew), (-sin(t) * tanh(asinh((t_1 * -eh)))), (cos(atan((-eh * (t / ew)))) * cos(t))) * ew));
} else {
tmp = fma((sin(t_2) * sin(t)), eh, ((cos(t) * ew) * cos(t_2)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(tan(t) / ew) t_2 = atan(Float64(t_1 * eh)) t_3 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_3)) - Float64(Float64(eh * sin(t)) * sin(t_3))) <= -1e-283) tmp = abs(Float64(fma(Float64(eh / ew), Float64(Float64(-sin(t)) * tanh(asinh(Float64(t_1 * Float64(-eh))))), Float64(cos(atan(Float64(Float64(-eh) * Float64(t / ew)))) * cos(t))) * ew)); else tmp = fma(Float64(sin(t_2) * sin(t)), eh, Float64(Float64(cos(t) * ew) * cos(t_2))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(t$95$1 * eh), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-283], N[Abs[N[(N[(N[(eh / ew), $MachinePrecision] * N[((-N[Sin[t], $MachinePrecision]) * N[Tanh[N[ArcSinh[N[(t$95$1 * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[ArcTan[N[((-eh) * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[(N[(N[Sin[t$95$2], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * eh + N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew}\\
t_2 := \tan^{-1} \left(t\_1 \cdot eh\right)\\
t_3 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_3 - \left(eh \cdot \sin t\right) \cdot \sin t\_3 \leq -1 \cdot 10^{-283}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{eh}{ew}, \left(-\sin t\right) \cdot \tanh \sinh^{-1} \left(t\_1 \cdot \left(-eh\right)\right), \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right) \cdot \cos t\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin t\_2 \cdot \sin t, eh, \left(\cos t \cdot ew\right) \cdot \cos t\_2\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -9.99999999999999947e-284Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites88.6%
Taylor expanded in t around 0
Applied rewrites77.8%
Applied rewrites77.8%
if -9.99999999999999947e-284 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt99.8
lift--.f64N/A
lift-*.f64N/A
Applied rewrites99.8%
Final simplification89.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (* eh (tan t)) (- ew)))))
(if (<=
(- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1)))
-1e-283)
(fabs (* (cos (atan (* (- eh) (/ t ew)))) ew))
(* (cos t) ew))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
double tmp;
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -1e-283) {
tmp = fabs((cos(atan((-eh * (t / ew)))) * ew));
} else {
tmp = cos(t) * ew;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = atan(((eh * tan(t)) / -ew))
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= (-1d-283)) then
tmp = abs((cos(atan((-eh * (t / ew)))) * ew))
else
tmp = cos(t) * ew
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh * Math.tan(t)) / -ew));
double tmp;
if ((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))) <= -1e-283) {
tmp = Math.abs((Math.cos(Math.atan((-eh * (t / ew)))) * ew));
} else {
tmp = Math.cos(t) * ew;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) tmp = 0 if (((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))) <= -1e-283: tmp = math.fabs((math.cos(math.atan((-eh * (t / ew)))) * ew)) else: tmp = math.cos(t) * ew return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1))) <= -1e-283) tmp = abs(Float64(cos(atan(Float64(Float64(-eh) * Float64(t / ew)))) * ew)); else tmp = Float64(cos(t) * ew); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = 0.0; if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -1e-283) tmp = abs((cos(atan((-eh * (t / ew)))) * ew)); else tmp = cos(t) * ew; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[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], -1e-283], N[Abs[N[(N[Cos[N[ArcTan[N[((-eh) * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1 \leq -1 \cdot 10^{-283}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\cos t \cdot ew\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -9.99999999999999947e-284Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites44.7%
Taylor expanded in t around 0
Applied rewrites41.5%
Taylor expanded in t around 0
Applied rewrites43.7%
if -9.99999999999999947e-284 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites69.6%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6463.0
Applied rewrites63.0%
Final simplification54.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (* eh (tan t)) (- ew)))))
(if (<=
(- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1)))
-1e-283)
(fabs (* (cos (atan (/ (* (- eh) t) ew))) ew))
(* (cos t) ew))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
double tmp;
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -1e-283) {
tmp = fabs((cos(atan(((-eh * t) / ew))) * ew));
} else {
tmp = cos(t) * ew;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = atan(((eh * tan(t)) / -ew))
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= (-1d-283)) then
tmp = abs((cos(atan(((-eh * t) / ew))) * ew))
else
tmp = cos(t) * ew
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh * Math.tan(t)) / -ew));
double tmp;
if ((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))) <= -1e-283) {
tmp = Math.abs((Math.cos(Math.atan(((-eh * t) / ew))) * ew));
} else {
tmp = Math.cos(t) * ew;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) tmp = 0 if (((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))) <= -1e-283: tmp = math.fabs((math.cos(math.atan(((-eh * t) / ew))) * ew)) else: tmp = math.cos(t) * ew return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1))) <= -1e-283) tmp = abs(Float64(cos(atan(Float64(Float64(Float64(-eh) * t) / ew))) * ew)); else tmp = Float64(cos(t) * ew); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = 0.0; if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -1e-283) tmp = abs((cos(atan(((-eh * t) / ew))) * ew)); else tmp = cos(t) * ew; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[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], -1e-283], N[Abs[N[(N[Cos[N[ArcTan[N[(N[((-eh) * t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1 \leq -1 \cdot 10^{-283}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\cos t \cdot ew\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -9.99999999999999947e-284Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites44.7%
Taylor expanded in t around 0
Applied rewrites43.7%
if -9.99999999999999947e-284 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites69.6%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6463.0
Applied rewrites63.0%
Final simplification54.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (- (sin t))))
(if (or (<= eh -3.2e+255) (not (<= eh 1.05e+222)))
(fabs (* (* t_1 eh) (sin (atan (* (/ t_1 ew) (/ eh (cos t)))))))
(fabs
(*
(fma
(/ eh ew)
(* t_1 (tanh (asinh (* (/ (tan t) ew) (- eh)))))
(* (cos (atan (* (- eh) (/ t ew)))) (cos t)))
ew)))))
double code(double eh, double ew, double t) {
double t_1 = -sin(t);
double tmp;
if ((eh <= -3.2e+255) || !(eh <= 1.05e+222)) {
tmp = fabs(((t_1 * eh) * sin(atan(((t_1 / ew) * (eh / cos(t)))))));
} else {
tmp = fabs((fma((eh / ew), (t_1 * tanh(asinh(((tan(t) / ew) * -eh)))), (cos(atan((-eh * (t / ew)))) * cos(t))) * ew));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(-sin(t)) tmp = 0.0 if ((eh <= -3.2e+255) || !(eh <= 1.05e+222)) tmp = abs(Float64(Float64(t_1 * eh) * sin(atan(Float64(Float64(t_1 / ew) * Float64(eh / cos(t))))))); else tmp = abs(Float64(fma(Float64(eh / ew), Float64(t_1 * tanh(asinh(Float64(Float64(tan(t) / ew) * Float64(-eh))))), Float64(cos(atan(Float64(Float64(-eh) * Float64(t / ew)))) * cos(t))) * ew)); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = (-N[Sin[t], $MachinePrecision])}, If[Or[LessEqual[eh, -3.2e+255], N[Not[LessEqual[eh, 1.05e+222]], $MachinePrecision]], N[Abs[N[(N[(t$95$1 * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t$95$1 / ew), $MachinePrecision] * N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(eh / ew), $MachinePrecision] * N[(t$95$1 * N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[ArcTan[N[((-eh) * N[(t / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\sin t\\
\mathbf{if}\;eh \leq -3.2 \cdot 10^{+255} \lor \neg \left(eh \leq 1.05 \cdot 10^{+222}\right):\\
\;\;\;\;\left|\left(t\_1 \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{t\_1}{ew} \cdot \frac{eh}{\cos t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{eh}{ew}, t\_1 \cdot \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \cos \tan^{-1} \left(\left(-eh\right) \cdot \frac{t}{ew}\right) \cdot \cos t\right) \cdot ew\right|\\
\end{array}
\end{array}
if eh < -3.1999999999999998e255 or 1.05000000000000005e222 < eh Initial program 99.9%
Taylor expanded in eh around inf
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
*-commutativeN/A
times-fracN/A
distribute-lft-neg-inN/A
Applied rewrites85.7%
if -3.1999999999999998e255 < eh < 1.05000000000000005e222Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites96.3%
Taylor expanded in t around 0
Applied rewrites84.1%
Applied rewrites84.1%
Final simplification84.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (- (sin t))))
(if (or (<= ew -1.35e-49) (not (<= ew 5.2e-82)))
(fabs (* (* (cos (atan (* (/ eh ew) (tan t)))) (cos t)) ew))
(fabs (* (* t_1 eh) (sin (atan (* (/ t_1 ew) (/ eh (cos t))))))))))
double code(double eh, double ew, double t) {
double t_1 = -sin(t);
double tmp;
if ((ew <= -1.35e-49) || !(ew <= 5.2e-82)) {
tmp = fabs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew));
} else {
tmp = fabs(((t_1 * eh) * sin(atan(((t_1 / ew) * (eh / cos(t)))))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = -sin(t)
if ((ew <= (-1.35d-49)) .or. (.not. (ew <= 5.2d-82))) then
tmp = abs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew))
else
tmp = abs(((t_1 * eh) * sin(atan(((t_1 / ew) * (eh / cos(t)))))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = -Math.sin(t);
double tmp;
if ((ew <= -1.35e-49) || !(ew <= 5.2e-82)) {
tmp = Math.abs(((Math.cos(Math.atan(((eh / ew) * Math.tan(t)))) * Math.cos(t)) * ew));
} else {
tmp = Math.abs(((t_1 * eh) * Math.sin(Math.atan(((t_1 / ew) * (eh / Math.cos(t)))))));
}
return tmp;
}
def code(eh, ew, t): t_1 = -math.sin(t) tmp = 0 if (ew <= -1.35e-49) or not (ew <= 5.2e-82): tmp = math.fabs(((math.cos(math.atan(((eh / ew) * math.tan(t)))) * math.cos(t)) * ew)) else: tmp = math.fabs(((t_1 * eh) * math.sin(math.atan(((t_1 / ew) * (eh / math.cos(t))))))) return tmp
function code(eh, ew, t) t_1 = Float64(-sin(t)) tmp = 0.0 if ((ew <= -1.35e-49) || !(ew <= 5.2e-82)) tmp = abs(Float64(Float64(cos(atan(Float64(Float64(eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs(Float64(Float64(t_1 * eh) * sin(atan(Float64(Float64(t_1 / ew) * Float64(eh / cos(t))))))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = -sin(t); tmp = 0.0; if ((ew <= -1.35e-49) || ~((ew <= 5.2e-82))) tmp = abs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs(((t_1 * eh) * sin(atan(((t_1 / ew) * (eh / cos(t))))))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = (-N[Sin[t], $MachinePrecision])}, If[Or[LessEqual[ew, -1.35e-49], N[Not[LessEqual[ew, 5.2e-82]], $MachinePrecision]], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(t$95$1 * eh), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(t$95$1 / ew), $MachinePrecision] * N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\sin t\\
\mathbf{if}\;ew \leq -1.35 \cdot 10^{-49} \lor \neg \left(ew \leq 5.2 \cdot 10^{-82}\right):\\
\;\;\;\;\left|\left(\cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \cos t\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(t\_1 \cdot eh\right) \cdot \sin \tan^{-1} \left(\frac{t\_1}{ew} \cdot \frac{eh}{\cos t}\right)\right|\\
\end{array}
\end{array}
if ew < -1.35e-49 or 5.2e-82 < ew Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites99.2%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6486.6
Applied rewrites86.6%
Applied rewrites86.6%
if -1.35e-49 < ew < 5.2e-82Initial program 99.8%
Taylor expanded in eh around inf
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
*-commutativeN/A
times-fracN/A
distribute-lft-neg-inN/A
Applied rewrites72.2%
Final simplification81.3%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -5.7e-182) (not (<= ew 1.2e-149)))
(fabs (* (* (cos (atan (* (/ eh ew) (tan t)))) (cos t)) ew))
(fabs
(*
(/ (* (* (sin t) (tanh (asinh (* (- eh) (/ (tan t) ew))))) eh) (- ew))
ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -5.7e-182) || !(ew <= 1.2e-149)) {
tmp = fabs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew));
} else {
tmp = fabs(((((sin(t) * tanh(asinh((-eh * (tan(t) / ew))))) * eh) / -ew) * ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -5.7e-182) or not (ew <= 1.2e-149): tmp = math.fabs(((math.cos(math.atan(((eh / ew) * math.tan(t)))) * math.cos(t)) * ew)) else: tmp = math.fabs(((((math.sin(t) * math.tanh(math.asinh((-eh * (math.tan(t) / ew))))) * eh) / -ew) * ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -5.7e-182) || !(ew <= 1.2e-149)) tmp = abs(Float64(Float64(cos(atan(Float64(Float64(eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs(Float64(Float64(Float64(Float64(sin(t) * tanh(asinh(Float64(Float64(-eh) * Float64(tan(t) / ew))))) * eh) / Float64(-ew)) * ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -5.7e-182) || ~((ew <= 1.2e-149))) tmp = abs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs(((((sin(t) * tanh(asinh((-eh * (tan(t) / ew))))) * eh) / -ew) * ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -5.7e-182], N[Not[LessEqual[ew, 1.2e-149]], $MachinePrecision]], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(N[Sin[t], $MachinePrecision] * N[Tanh[N[ArcSinh[N[((-eh) * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision] / (-ew)), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -5.7 \cdot 10^{-182} \lor \neg \left(ew \leq 1.2 \cdot 10^{-149}\right):\\
\;\;\;\;\left|\left(\cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \cos t\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(\sin t \cdot \tanh \sinh^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right) \cdot eh}{-ew} \cdot ew\right|\\
\end{array}
\end{array}
if ew < -5.6999999999999998e-182 or 1.2000000000000001e-149 < ew Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites94.4%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6479.1
Applied rewrites79.1%
Applied rewrites79.1%
if -5.6999999999999998e-182 < ew < 1.2000000000000001e-149Initial program 99.9%
Taylor expanded in ew around inf
Applied rewrites64.0%
Taylor expanded in t around 0
Applied rewrites61.7%
Taylor expanded in eh around inf
Applied rewrites58.2%
Applied rewrites58.2%
Final simplification75.0%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -5.3e-182) (not (<= ew 7.5e-150)))
(fabs (* (* (cos (atan (* (/ eh ew) (tan t)))) (cos t)) ew))
(fabs
(*
(* (/ (- eh) ew) (* (sin t) (tanh (asinh (* (- eh) (/ (tan t) ew))))))
ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -5.3e-182) || !(ew <= 7.5e-150)) {
tmp = fabs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew));
} else {
tmp = fabs((((-eh / ew) * (sin(t) * tanh(asinh((-eh * (tan(t) / ew)))))) * ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -5.3e-182) or not (ew <= 7.5e-150): tmp = math.fabs(((math.cos(math.atan(((eh / ew) * math.tan(t)))) * math.cos(t)) * ew)) else: tmp = math.fabs((((-eh / ew) * (math.sin(t) * math.tanh(math.asinh((-eh * (math.tan(t) / ew)))))) * ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -5.3e-182) || !(ew <= 7.5e-150)) tmp = abs(Float64(Float64(cos(atan(Float64(Float64(eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs(Float64(Float64(Float64(Float64(-eh) / ew) * Float64(sin(t) * tanh(asinh(Float64(Float64(-eh) * Float64(tan(t) / ew)))))) * ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -5.3e-182) || ~((ew <= 7.5e-150))) tmp = abs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs((((-eh / ew) * (sin(t) * tanh(asinh((-eh * (tan(t) / ew)))))) * ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -5.3e-182], N[Not[LessEqual[ew, 7.5e-150]], $MachinePrecision]], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[((-eh) / ew), $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * N[Tanh[N[ArcSinh[N[((-eh) * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -5.3 \cdot 10^{-182} \lor \neg \left(ew \leq 7.5 \cdot 10^{-150}\right):\\
\;\;\;\;\left|\left(\cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \cos t\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\frac{-eh}{ew} \cdot \left(\sin t \cdot \tanh \sinh^{-1} \left(\left(-eh\right) \cdot \frac{\tan t}{ew}\right)\right)\right) \cdot ew\right|\\
\end{array}
\end{array}
if ew < -5.30000000000000005e-182 or 7.5000000000000004e-150 < ew Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites94.4%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6479.1
Applied rewrites79.1%
Applied rewrites79.1%
if -5.30000000000000005e-182 < ew < 7.5000000000000004e-150Initial program 99.9%
Taylor expanded in ew around inf
Applied rewrites64.0%
Taylor expanded in t around 0
Applied rewrites61.7%
Taylor expanded in eh around inf
Applied rewrites58.2%
Applied rewrites52.3%
Final simplification73.8%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -5.3e-182) (not (<= ew 7.5e-150)))
(fabs (* (* (cos (atan (* (/ eh ew) (tan t)))) (cos t)) ew))
(fabs
(* (* (sin t) (* eh (/ (tanh (asinh (* (/ (tan t) ew) eh))) ew))) ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -5.3e-182) || !(ew <= 7.5e-150)) {
tmp = fabs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew));
} else {
tmp = fabs(((sin(t) * (eh * (tanh(asinh(((tan(t) / ew) * eh))) / ew))) * ew));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -5.3e-182) or not (ew <= 7.5e-150): tmp = math.fabs(((math.cos(math.atan(((eh / ew) * math.tan(t)))) * math.cos(t)) * ew)) else: tmp = math.fabs(((math.sin(t) * (eh * (math.tanh(math.asinh(((math.tan(t) / ew) * eh))) / ew))) * ew)) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -5.3e-182) || !(ew <= 7.5e-150)) tmp = abs(Float64(Float64(cos(atan(Float64(Float64(eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs(Float64(Float64(sin(t) * Float64(eh * Float64(tanh(asinh(Float64(Float64(tan(t) / ew) * eh))) / ew))) * ew)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -5.3e-182) || ~((ew <= 7.5e-150))) tmp = abs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew)); else tmp = abs(((sin(t) * (eh * (tanh(asinh(((tan(t) / ew) * eh))) / ew))) * ew)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -5.3e-182], N[Not[LessEqual[ew, 7.5e-150]], $MachinePrecision]], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * N[(eh * N[(N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -5.3 \cdot 10^{-182} \lor \neg \left(ew \leq 7.5 \cdot 10^{-150}\right):\\
\;\;\;\;\left|\left(\cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \cos t\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\sin t \cdot \left(eh \cdot \frac{\tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)}{ew}\right)\right) \cdot ew\right|\\
\end{array}
\end{array}
if ew < -5.30000000000000005e-182 or 7.5000000000000004e-150 < ew Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites94.4%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6479.1
Applied rewrites79.1%
Applied rewrites79.1%
if -5.30000000000000005e-182 < ew < 7.5000000000000004e-150Initial program 99.9%
Taylor expanded in ew around inf
Applied rewrites64.0%
Taylor expanded in t around 0
Applied rewrites61.7%
Taylor expanded in eh around inf
Applied rewrites58.2%
Applied rewrites52.3%
Final simplification73.8%
(FPCore (eh ew t) :precision binary64 (fabs (* (* (cos (atan (* (/ eh ew) (tan t)))) (cos t)) ew)))
double code(double eh, double ew, double t) {
return fabs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((Math.cos(Math.atan(((eh / ew) * Math.tan(t)))) * Math.cos(t)) * ew));
}
def code(eh, ew, t): return math.fabs(((math.cos(math.atan(((eh / ew) * math.tan(t)))) * math.cos(t)) * ew))
function code(eh, ew, t) return abs(Float64(Float64(cos(atan(Float64(Float64(eh / ew) * tan(t)))) * cos(t)) * ew)) end
function tmp = code(eh, ew, t) tmp = abs(((cos(atan(((eh / ew) * tan(t)))) * cos(t)) * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right) \cdot \cos t\right) \cdot ew\right|
\end{array}
Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites88.4%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6466.7
Applied rewrites66.7%
Applied rewrites66.7%
(FPCore (eh ew t) :precision binary64 (* (cos t) ew))
double code(double eh, double ew, double t) {
return cos(t) * ew;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = cos(t) * ew
end function
public static double code(double eh, double ew, double t) {
return Math.cos(t) * ew;
}
def code(eh, ew, t): return math.cos(t) * ew
function code(eh, ew, t) return Float64(cos(t) * ew) end
function tmp = code(eh, ew, t) tmp = cos(t) * ew; end
code[eh_, ew_, t_] := N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]
\begin{array}{l}
\\
\cos t \cdot ew
\end{array}
Initial program 99.8%
Applied rewrites38.4%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6434.9
Applied rewrites34.9%
(FPCore (eh ew t) :precision binary64 (fma (* -0.5 ew) (* t t) ew))
double code(double eh, double ew, double t) {
return fma((-0.5 * ew), (t * t), ew);
}
function code(eh, ew, t) return fma(Float64(-0.5 * ew), Float64(t * t), ew) end
code[eh_, ew_, t_] := N[(N[(-0.5 * ew), $MachinePrecision] * N[(t * t), $MachinePrecision] + ew), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 \cdot ew, t \cdot t, ew\right)
\end{array}
Initial program 99.8%
Applied rewrites38.4%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6418.0
Applied rewrites18.0%
Taylor expanded in eh around 0
Applied rewrites21.3%
herbie shell --seed 2025015
(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)))))))