
(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 13 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 (* 0.0 (sin t))) (t_2 (atan (/ (* eh (tan t)) (- ew)))))
(fabs
(-
(* (* eh (sin t)) (sin t_2))
(*
(* ew (/ (- (* t_1 t_1) (* (cos t) (cos t))) (- t_1 (cos t))))
(cos t_2))))))
double code(double eh, double ew, double t) {
double t_1 = 0.0 * sin(t);
double t_2 = atan(((eh * tan(t)) / -ew));
return fabs((((eh * sin(t)) * sin(t_2)) - ((ew * (((t_1 * t_1) - (cos(t) * cos(t))) / (t_1 - cos(t)))) * cos(t_2))));
}
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) :: t_2
t_1 = 0.0d0 * sin(t)
t_2 = atan(((eh * tan(t)) / -ew))
code = abs((((eh * sin(t)) * sin(t_2)) - ((ew * (((t_1 * t_1) - (cos(t) * cos(t))) / (t_1 - cos(t)))) * cos(t_2))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = 0.0 * Math.sin(t);
double t_2 = Math.atan(((eh * Math.tan(t)) / -ew));
return Math.abs((((eh * Math.sin(t)) * Math.sin(t_2)) - ((ew * (((t_1 * t_1) - (Math.cos(t) * Math.cos(t))) / (t_1 - Math.cos(t)))) * Math.cos(t_2))));
}
def code(eh, ew, t): t_1 = 0.0 * math.sin(t) t_2 = math.atan(((eh * math.tan(t)) / -ew)) return math.fabs((((eh * math.sin(t)) * math.sin(t_2)) - ((ew * (((t_1 * t_1) - (math.cos(t) * math.cos(t))) / (t_1 - math.cos(t)))) * math.cos(t_2))))
function code(eh, ew, t) t_1 = Float64(0.0 * sin(t)) t_2 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(t_2)) - Float64(Float64(ew * Float64(Float64(Float64(t_1 * t_1) - Float64(cos(t) * cos(t))) / Float64(t_1 - cos(t)))) * cos(t_2)))) end
function tmp = code(eh, ew, t) t_1 = 0.0 * sin(t); t_2 = atan(((eh * tan(t)) / -ew)); tmp = abs((((eh * sin(t)) * sin(t_2)) - ((ew * (((t_1 * t_1) - (cos(t) * cos(t))) / (t_1 - cos(t)))) * cos(t_2)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(0.0 * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$2], $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(N[Cos[t], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 0 \cdot \sin t\\
t_2 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\left|\left(eh \cdot \sin t\right) \cdot \sin t\_2 - \left(ew \cdot \frac{t\_1 \cdot t\_1 - \cos t \cdot \cos t}{t\_1 - \cos t}\right) \cdot \cos t\_2\right|
\end{array}
\end{array}
Initial program 99.8%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (tan t) ew) eh))
(t_2 (atan t_1))
(t_3 (atan (/ (* eh (tan t)) (- ew))))
(t_4 (* (cos t) ew)))
(if (<=
(- (* (* ew (cos t)) (cos t_3)) (* (* eh (sin t)) (sin t_3)))
-4e-232)
(fabs (/ (fma (* t_1 eh) (sin t) t_4) (cosh (asinh t_1))))
(fma (* (sin t_2) (sin t)) eh (* t_4 (cos t_2))))))
double code(double eh, double ew, double t) {
double t_1 = (tan(t) / ew) * eh;
double t_2 = atan(t_1);
double t_3 = atan(((eh * tan(t)) / -ew));
double t_4 = cos(t) * ew;
double tmp;
if ((((ew * cos(t)) * cos(t_3)) - ((eh * sin(t)) * sin(t_3))) <= -4e-232) {
tmp = fabs((fma((t_1 * eh), sin(t), t_4) / cosh(asinh(t_1))));
} else {
tmp = fma((sin(t_2) * sin(t)), eh, (t_4 * cos(t_2)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(tan(t) / ew) * eh) t_2 = atan(t_1) t_3 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) t_4 = Float64(cos(t) * ew) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_3)) - Float64(Float64(eh * sin(t)) * sin(t_3))) <= -4e-232) tmp = abs(Float64(fma(Float64(t_1 * eh), sin(t), t_4) / cosh(asinh(t_1)))); else tmp = fma(Float64(sin(t_2) * sin(t)), eh, Float64(t_4 * cos(t_2))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[t], $MachinePrecision] * ew), $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], -4e-232], N[Abs[N[(N[(N[(t$95$1 * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + t$95$4), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[Sin[t$95$2], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * eh + N[(t$95$4 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew} \cdot eh\\
t_2 := \tan^{-1} t\_1\\
t_3 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
t_4 := \cos t \cdot ew\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_3 - \left(eh \cdot \sin t\right) \cdot \sin t\_3 \leq -4 \cdot 10^{-232}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(t\_1 \cdot eh, \sin t, t\_4\right)}{\cosh \sinh^{-1} t\_1}\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin t\_2 \cdot \sin t, eh, t\_4 \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))))) < -4.0000000000000001e-232Initial program 99.8%
Applied rewrites71.7%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6471.7
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6482.0
Applied rewrites82.0%
if -4.0000000000000001e-232 < (-.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.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt99.9
lift--.f64N/A
lift-*.f64N/A
Applied rewrites99.9%
Final simplification90.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (cos t))) (t_2 (atan (/ (* eh (tan t)) (- ew)))))
(if (<= (- (* t_1 (cos t_2)) (* (* eh (sin t)) (sin t_2))) 2e-219)
(fabs ew)
t_1)))
double code(double eh, double ew, double t) {
double t_1 = ew * cos(t);
double t_2 = atan(((eh * tan(t)) / -ew));
double tmp;
if (((t_1 * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= 2e-219) {
tmp = fabs(ew);
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_1 = ew * cos(t)
t_2 = atan(((eh * tan(t)) / -ew))
if (((t_1 * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= 2d-219) then
tmp = abs(ew)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.cos(t);
double t_2 = Math.atan(((eh * Math.tan(t)) / -ew));
double tmp;
if (((t_1 * Math.cos(t_2)) - ((eh * Math.sin(t)) * Math.sin(t_2))) <= 2e-219) {
tmp = Math.abs(ew);
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.cos(t) t_2 = math.atan(((eh * math.tan(t)) / -ew)) tmp = 0 if ((t_1 * math.cos(t_2)) - ((eh * math.sin(t)) * math.sin(t_2))) <= 2e-219: tmp = math.fabs(ew) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = Float64(ew * cos(t)) t_2 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(t_1 * cos(t_2)) - Float64(Float64(eh * sin(t)) * sin(t_2))) <= 2e-219) tmp = abs(ew); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * cos(t); t_2 = atan(((eh * tan(t)) / -ew)); tmp = 0.0; if (((t_1 * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= 2e-219) tmp = abs(ew); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-219], N[Abs[ew], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \cos t\\
t_2 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;t\_1 \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2 \leq 2 \cdot 10^{-219}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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))))) < 2.0000000000000001e-219Initial program 99.8%
Applied rewrites71.6%
Taylor expanded in t around 0
Applied rewrites44.0%
if 2.0000000000000001e-219 < (-.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.9%
Applied rewrites49.5%
Taylor expanded in eh around 0
Applied rewrites65.5%
Final simplification54.2%
(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 (fabs (- (* (* eh (sin t)) (sin (atan (/ (* eh (tan t)) (- ew))))) (* (* (cos (atan (* (/ (tan t) ew) eh))) (cos t)) ew))))
double code(double eh, double ew, double t) {
return fabs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * 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((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * cos(t)) * ew)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * Math.tan(t)) / -ew)))) - ((Math.cos(Math.atan(((Math.tan(t) / ew) * eh))) * Math.cos(t)) * ew)));
}
def code(eh, ew, t): return math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((eh * math.tan(t)) / -ew)))) - ((math.cos(math.atan(((math.tan(t) / ew) * eh))) * math.cos(t)) * ew)))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))) - Float64(Float64(cos(atan(Float64(Float64(tan(t) / ew) * eh))) * cos(t)) * ew))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * cos(t)) * ew))); end
code[eh_, ew_, t_] := N[Abs[N[(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] - N[(N[(N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) - \left(\cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \cos t\right) \cdot ew\right|
\end{array}
Initial program 99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (tan t) ew) eh)))
(if (or (<= eh -1e+139) (not (<= eh 1.9e+227)))
(fabs (* (sin t) eh))
(fabs (/ (fma (* t_1 eh) (sin t) (* (cos t) ew)) (cosh (asinh t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (tan(t) / ew) * eh;
double tmp;
if ((eh <= -1e+139) || !(eh <= 1.9e+227)) {
tmp = fabs((sin(t) * eh));
} else {
tmp = fabs((fma((t_1 * eh), sin(t), (cos(t) * ew)) / cosh(asinh(t_1))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(tan(t) / ew) * eh) tmp = 0.0 if ((eh <= -1e+139) || !(eh <= 1.9e+227)) tmp = abs(Float64(sin(t) * eh)); else tmp = abs(Float64(fma(Float64(t_1 * eh), sin(t), Float64(cos(t) * ew)) / cosh(asinh(t_1)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]}, If[Or[LessEqual[eh, -1e+139], N[Not[LessEqual[eh, 1.9e+227]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(t$95$1 * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew} \cdot eh\\
\mathbf{if}\;eh \leq -1 \cdot 10^{+139} \lor \neg \left(eh \leq 1.9 \cdot 10^{+227}\right):\\
\;\;\;\;\left|\sin t \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(t\_1 \cdot eh, \sin t, \cos t \cdot ew\right)}{\cosh \sinh^{-1} t\_1}\right|\\
\end{array}
\end{array}
if eh < -1.00000000000000003e139 or 1.90000000000000018e227 < eh Initial program 99.9%
Applied rewrites5.2%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f644.2
Applied rewrites4.2%
Taylor expanded in eh around inf
Applied rewrites79.2%
if -1.00000000000000003e139 < eh < 1.90000000000000018e227Initial program 99.8%
Applied rewrites88.2%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6488.2
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6494.2
Applied rewrites94.2%
Final simplification91.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (tan t) ew)) (t_2 (* t_1 eh)))
(if (or (<= eh -8.8e+138) (not (<= eh 1.9e+227)))
(fabs (* (sin t) eh))
(fabs
(/
(fma (* (* (sin t) t_1) eh) eh (* (cos t) ew))
(sqrt (fma t_2 t_2 1.0)))))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) / ew;
double t_2 = t_1 * eh;
double tmp;
if ((eh <= -8.8e+138) || !(eh <= 1.9e+227)) {
tmp = fabs((sin(t) * eh));
} else {
tmp = fabs((fma(((sin(t) * t_1) * eh), eh, (cos(t) * ew)) / sqrt(fma(t_2, t_2, 1.0))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(tan(t) / ew) t_2 = Float64(t_1 * eh) tmp = 0.0 if ((eh <= -8.8e+138) || !(eh <= 1.9e+227)) tmp = abs(Float64(sin(t) * eh)); else tmp = abs(Float64(fma(Float64(Float64(sin(t) * t_1) * eh), eh, Float64(cos(t) * ew)) / sqrt(fma(t_2, t_2, 1.0)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * eh), $MachinePrecision]}, If[Or[LessEqual[eh, -8.8e+138], N[Not[LessEqual[eh, 1.9e+227]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[(N[Sin[t], $MachinePrecision] * t$95$1), $MachinePrecision] * eh), $MachinePrecision] * eh + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(t$95$2 * t$95$2 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew}\\
t_2 := t\_1 \cdot eh\\
\mathbf{if}\;eh \leq -8.8 \cdot 10^{+138} \lor \neg \left(eh \leq 1.9 \cdot 10^{+227}\right):\\
\;\;\;\;\left|\sin t \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\left(\sin t \cdot t\_1\right) \cdot eh, eh, \cos t \cdot ew\right)}{\sqrt{\mathsf{fma}\left(t\_2, t\_2, 1\right)}}\right|\\
\end{array}
\end{array}
if eh < -8.8000000000000003e138 or 1.90000000000000018e227 < eh Initial program 99.9%
Applied rewrites5.2%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f644.2
Applied rewrites4.2%
Taylor expanded in eh around inf
Applied rewrites79.2%
if -8.8000000000000003e138 < eh < 1.90000000000000018e227Initial program 99.8%
Applied rewrites88.2%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f6485.9
Applied rewrites85.9%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6492.5
Applied rewrites92.5%
Final simplification89.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (tan t) ew)))
(if (or (<= eh -8.8e+138) (not (<= eh 1.1e+154)))
(fabs (* (sin t) eh))
(fabs
(/
(fma (sin t) (* t_1 (* eh eh)) (* (cos t) ew))
(sqrt (- (pow (* eh t_1) 2.0) -1.0)))))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) / ew;
double tmp;
if ((eh <= -8.8e+138) || !(eh <= 1.1e+154)) {
tmp = fabs((sin(t) * eh));
} else {
tmp = fabs((fma(sin(t), (t_1 * (eh * eh)), (cos(t) * ew)) / sqrt((pow((eh * t_1), 2.0) - -1.0))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(tan(t) / ew) tmp = 0.0 if ((eh <= -8.8e+138) || !(eh <= 1.1e+154)) tmp = abs(Float64(sin(t) * eh)); else tmp = abs(Float64(fma(sin(t), Float64(t_1 * Float64(eh * eh)), Float64(cos(t) * ew)) / sqrt(Float64((Float64(eh * t_1) ^ 2.0) - -1.0)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]}, If[Or[LessEqual[eh, -8.8e+138], N[Not[LessEqual[eh, 1.1e+154]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * N[(t$95$1 * N[(eh * eh), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[(eh * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew}\\
\mathbf{if}\;eh \leq -8.8 \cdot 10^{+138} \lor \neg \left(eh \leq 1.1 \cdot 10^{+154}\right):\\
\;\;\;\;\left|\sin t \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, t\_1 \cdot \left(eh \cdot eh\right), \cos t \cdot ew\right)}{\sqrt{{\left(eh \cdot t\_1\right)}^{2} - -1}}\right|\\
\end{array}
\end{array}
if eh < -8.8000000000000003e138 or 1.1000000000000001e154 < eh Initial program 99.9%
Applied rewrites4.8%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f643.8
Applied rewrites3.8%
Taylor expanded in eh around inf
Applied rewrites72.1%
if -8.8000000000000003e138 < eh < 1.1000000000000001e154Initial program 99.8%
Applied rewrites94.1%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f6491.7
Applied rewrites91.7%
lift-fma.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
pow2N/A
lower-pow.f6491.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.7
Applied rewrites91.7%
Final simplification86.6%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -5.2e+56) (not (<= eh 1.9e+227))) (fabs (* (sin t) eh)) (fabs (* ew (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -5.2e+56) || !(eh <= 1.9e+227)) {
tmp = fabs((sin(t) * eh));
} else {
tmp = fabs((ew * 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) :: tmp
if ((eh <= (-5.2d+56)) .or. (.not. (eh <= 1.9d+227))) then
tmp = abs((sin(t) * 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 <= -5.2e+56) || !(eh <= 1.9e+227)) {
tmp = Math.abs((Math.sin(t) * eh));
} else {
tmp = Math.abs((ew * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -5.2e+56) or not (eh <= 1.9e+227): tmp = math.fabs((math.sin(t) * eh)) else: tmp = math.fabs((ew * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -5.2e+56) || !(eh <= 1.9e+227)) tmp = abs(Float64(sin(t) * eh)); else tmp = abs(Float64(ew * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -5.2e+56) || ~((eh <= 1.9e+227))) tmp = abs((sin(t) * eh)); else tmp = abs((ew * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -5.2e+56], N[Not[LessEqual[eh, 1.9e+227]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -5.2 \cdot 10^{+56} \lor \neg \left(eh \leq 1.9 \cdot 10^{+227}\right):\\
\;\;\;\;\left|\sin t \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\end{array}
\end{array}
if eh < -5.20000000000000022e56 or 1.90000000000000018e227 < eh Initial program 99.9%
Applied rewrites19.7%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f6418.0
Applied rewrites18.0%
Taylor expanded in eh around inf
Applied rewrites75.5%
if -5.20000000000000022e56 < eh < 1.90000000000000018e227Initial program 99.8%
Applied rewrites89.2%
Taylor expanded in eh around 0
Applied rewrites81.2%
Final simplification79.7%
(FPCore (eh ew t) :precision binary64 (if (<= eh 1.7e+231) (fabs (* ew (cos t))) (fabs (* t eh))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= 1.7e+231) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((t * eh));
}
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) :: tmp
if (eh <= 1.7d+231) then
tmp = abs((ew * cos(t)))
else
tmp = abs((t * eh))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= 1.7e+231) {
tmp = Math.abs((ew * Math.cos(t)));
} else {
tmp = Math.abs((t * eh));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= 1.7e+231: tmp = math.fabs((ew * math.cos(t))) else: tmp = math.fabs((t * eh)) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= 1.7e+231) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(t * eh)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= 1.7e+231) tmp = abs((ew * cos(t))); else tmp = abs((t * eh)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, 1.7e+231], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq 1.7 \cdot 10^{+231}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t \cdot eh\right|\\
\end{array}
\end{array}
if eh < 1.7e231Initial program 99.8%
Applied rewrites75.8%
Taylor expanded in eh around 0
Applied rewrites71.2%
if 1.7e231 < eh Initial program 100.0%
Applied rewrites3.3%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f642.6
Applied rewrites2.6%
Taylor expanded in eh around inf
Applied rewrites89.8%
Taylor expanded in t around 0
Applied rewrites53.9%
(FPCore (eh ew t) :precision binary64 (if (<= eh 1.2e+231) (fabs ew) (fabs (* t eh))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= 1.2e+231) {
tmp = fabs(ew);
} else {
tmp = fabs((t * eh));
}
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) :: tmp
if (eh <= 1.2d+231) then
tmp = abs(ew)
else
tmp = abs((t * eh))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= 1.2e+231) {
tmp = Math.abs(ew);
} else {
tmp = Math.abs((t * eh));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= 1.2e+231: tmp = math.fabs(ew) else: tmp = math.fabs((t * eh)) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= 1.2e+231) tmp = abs(ew); else tmp = abs(Float64(t * eh)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= 1.2e+231) tmp = abs(ew); else tmp = abs((t * eh)); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, 1.2e+231], N[Abs[ew], $MachinePrecision], N[Abs[N[(t * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq 1.2 \cdot 10^{+231}:\\
\;\;\;\;\left|ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t \cdot eh\right|\\
\end{array}
\end{array}
if eh < 1.20000000000000003e231Initial program 99.8%
Applied rewrites75.8%
Taylor expanded in t around 0
Applied rewrites46.0%
if 1.20000000000000003e231 < eh Initial program 100.0%
Applied rewrites3.3%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
lower-sqrt.f64N/A
lower-fma.f642.6
Applied rewrites2.6%
Taylor expanded in eh around inf
Applied rewrites89.8%
Taylor expanded in t around 0
Applied rewrites53.9%
(FPCore (eh ew t) :precision binary64 (fabs ew))
double code(double eh, double ew, double t) {
return fabs(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(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%
Applied rewrites70.7%
Taylor expanded in t around 0
Applied rewrites43.2%
(FPCore (eh ew t) :precision binary64 ew)
double code(double eh, double ew, double t) {
return 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 = ew
end function
public static double code(double eh, double ew, double t) {
return ew;
}
def code(eh, ew, t): return ew
function code(eh, ew, t) return ew end
function tmp = code(eh, ew, t) tmp = ew; end
code[eh_, ew_, t_] := ew
\begin{array}{l}
\\
ew
\end{array}
Initial program 99.8%
Applied rewrites47.9%
Taylor expanded in t around 0
Applied rewrites22.2%
herbie shell --seed 2025018
(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)))))))