
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
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 / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
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 / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ eh (* (tan t) ew))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan((eh / (tan(t) * ew)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(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 * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan((eh / (Math.tan(t) * ew)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan((eh / (math.tan(t) * ew))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(eh / Float64(tan(t) * ew))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan((eh / (tan(t) * ew))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f6499.8
Applied rewrites99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew)))
(if (or (<= eh -4.2e+119) (not (<= eh 5e+69)))
(fabs (* (sin (atan (* (/ (cos t) ew) (/ eh (sin t))))) (* (cos t) eh)))
(fabs (/ (+ (* (sin t) ew) (* (* eh (cos t)) t_1)) (cosh (asinh t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / tan(t)) / ew;
double tmp;
if ((eh <= -4.2e+119) || !(eh <= 5e+69)) {
tmp = fabs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(t) * eh)));
} else {
tmp = fabs((((sin(t) * ew) + ((eh * cos(t)) * t_1)) / cosh(asinh(t_1))));
}
return tmp;
}
def code(eh, ew, t): t_1 = (eh / math.tan(t)) / ew tmp = 0 if (eh <= -4.2e+119) or not (eh <= 5e+69): tmp = math.fabs((math.sin(math.atan(((math.cos(t) / ew) * (eh / math.sin(t))))) * (math.cos(t) * eh))) else: tmp = math.fabs((((math.sin(t) * ew) + ((eh * math.cos(t)) * t_1)) / math.cosh(math.asinh(t_1)))) return tmp
function code(eh, ew, t) t_1 = Float64(Float64(eh / tan(t)) / ew) tmp = 0.0 if ((eh <= -4.2e+119) || !(eh <= 5e+69)) tmp = abs(Float64(sin(atan(Float64(Float64(cos(t) / ew) * Float64(eh / sin(t))))) * Float64(cos(t) * eh))); else tmp = abs(Float64(Float64(Float64(sin(t) * ew) + Float64(Float64(eh * cos(t)) * t_1)) / cosh(asinh(t_1)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = (eh / tan(t)) / ew; tmp = 0.0; if ((eh <= -4.2e+119) || ~((eh <= 5e+69))) tmp = abs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(t) * eh))); else tmp = abs((((sin(t) * ew) + ((eh * cos(t)) * t_1)) / cosh(asinh(t_1)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]}, If[Or[LessEqual[eh, -4.2e+119], N[Not[LessEqual[eh, 5e+69]], $MachinePrecision]], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[Cos[t], $MachinePrecision] / ew), $MachinePrecision] * N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{\tan t}}{ew}\\
\mathbf{if}\;eh \leq -4.2 \cdot 10^{+119} \lor \neg \left(eh \leq 5 \cdot 10^{+69}\right):\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\cos t}{ew} \cdot \frac{eh}{\sin t}\right) \cdot \left(\cos t \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\sin t \cdot ew + \left(eh \cdot \cos t\right) \cdot t\_1}{\cosh \sinh^{-1} t\_1}\right|\\
\end{array}
\end{array}
if eh < -4.19999999999999966e119 or 5.00000000000000036e69 < eh Initial program 99.8%
Taylor expanded in eh around inf
Applied rewrites92.9%
if -4.19999999999999966e119 < eh < 5.00000000000000036e69Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Applied rewrites89.3%
Final simplification90.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh (tan t)) ew)))
(if (or (<= eh -4.2e+119) (not (<= eh 5.4e+16)))
(fabs (* (sin (atan (* (/ (cos t) ew) (/ eh (sin t))))) (* (cos t) eh)))
(fabs
(/
(+ (* (sin t) ew) (* (* eh (cos t)) t_1))
(sqrt (- (pow t_1 2.0) -1.0)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / tan(t)) / ew;
double tmp;
if ((eh <= -4.2e+119) || !(eh <= 5.4e+16)) {
tmp = fabs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(t) * eh)));
} else {
tmp = fabs((((sin(t) * ew) + ((eh * cos(t)) * t_1)) / sqrt((pow(t_1, 2.0) - -1.0))));
}
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 = (eh / tan(t)) / ew
if ((eh <= (-4.2d+119)) .or. (.not. (eh <= 5.4d+16))) then
tmp = abs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(t) * eh)))
else
tmp = abs((((sin(t) * ew) + ((eh * cos(t)) * t_1)) / sqrt(((t_1 ** 2.0d0) - (-1.0d0)))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = (eh / Math.tan(t)) / ew;
double tmp;
if ((eh <= -4.2e+119) || !(eh <= 5.4e+16)) {
tmp = Math.abs((Math.sin(Math.atan(((Math.cos(t) / ew) * (eh / Math.sin(t))))) * (Math.cos(t) * eh)));
} else {
tmp = Math.abs((((Math.sin(t) * ew) + ((eh * Math.cos(t)) * t_1)) / Math.sqrt((Math.pow(t_1, 2.0) - -1.0))));
}
return tmp;
}
def code(eh, ew, t): t_1 = (eh / math.tan(t)) / ew tmp = 0 if (eh <= -4.2e+119) or not (eh <= 5.4e+16): tmp = math.fabs((math.sin(math.atan(((math.cos(t) / ew) * (eh / math.sin(t))))) * (math.cos(t) * eh))) else: tmp = math.fabs((((math.sin(t) * ew) + ((eh * math.cos(t)) * t_1)) / math.sqrt((math.pow(t_1, 2.0) - -1.0)))) return tmp
function code(eh, ew, t) t_1 = Float64(Float64(eh / tan(t)) / ew) tmp = 0.0 if ((eh <= -4.2e+119) || !(eh <= 5.4e+16)) tmp = abs(Float64(sin(atan(Float64(Float64(cos(t) / ew) * Float64(eh / sin(t))))) * Float64(cos(t) * eh))); else tmp = abs(Float64(Float64(Float64(sin(t) * ew) + Float64(Float64(eh * cos(t)) * t_1)) / sqrt(Float64((t_1 ^ 2.0) - -1.0)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = (eh / tan(t)) / ew; tmp = 0.0; if ((eh <= -4.2e+119) || ~((eh <= 5.4e+16))) tmp = abs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(t) * eh))); else tmp = abs((((sin(t) * ew) + ((eh * cos(t)) * t_1)) / sqrt(((t_1 ^ 2.0) - -1.0)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]}, If[Or[LessEqual[eh, -4.2e+119], N[Not[LessEqual[eh, 5.4e+16]], $MachinePrecision]], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[Cos[t], $MachinePrecision] / ew), $MachinePrecision] * N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$1, 2.0], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{\tan t}}{ew}\\
\mathbf{if}\;eh \leq -4.2 \cdot 10^{+119} \lor \neg \left(eh \leq 5.4 \cdot 10^{+16}\right):\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\cos t}{ew} \cdot \frac{eh}{\sin t}\right) \cdot \left(\cos t \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\sin t \cdot ew + \left(eh \cdot \cos t\right) \cdot t\_1}{\sqrt{{t\_1}^{2} - -1}}\right|\\
\end{array}
\end{array}
if eh < -4.19999999999999966e119 or 5.4e16 < eh Initial program 99.8%
Taylor expanded in eh around inf
Applied rewrites91.6%
if -4.19999999999999966e119 < eh < 5.4e16Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Applied rewrites89.7%
Applied rewrites80.3%
Final simplification84.6%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -4.3e+129) (not (<= ew 1.65e+92))) (fabs (* (- ew) (sin t))) (fabs (* (sin (atan (* (/ (cos t) ew) (/ eh (sin t))))) (* (cos t) eh)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -4.3e+129) || !(ew <= 1.65e+92)) {
tmp = fabs((-ew * sin(t)));
} else {
tmp = fabs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(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 ((ew <= (-4.3d+129)) .or. (.not. (ew <= 1.65d+92))) then
tmp = abs((-ew * sin(t)))
else
tmp = abs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(t) * eh)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -4.3e+129) || !(ew <= 1.65e+92)) {
tmp = Math.abs((-ew * Math.sin(t)));
} else {
tmp = Math.abs((Math.sin(Math.atan(((Math.cos(t) / ew) * (eh / Math.sin(t))))) * (Math.cos(t) * eh)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -4.3e+129) or not (ew <= 1.65e+92): tmp = math.fabs((-ew * math.sin(t))) else: tmp = math.fabs((math.sin(math.atan(((math.cos(t) / ew) * (eh / math.sin(t))))) * (math.cos(t) * eh))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -4.3e+129) || !(ew <= 1.65e+92)) tmp = abs(Float64(Float64(-ew) * sin(t))); else tmp = abs(Float64(sin(atan(Float64(Float64(cos(t) / ew) * Float64(eh / sin(t))))) * Float64(cos(t) * eh))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -4.3e+129) || ~((ew <= 1.65e+92))) tmp = abs((-ew * sin(t))); else tmp = abs((sin(atan(((cos(t) / ew) * (eh / sin(t))))) * (cos(t) * eh))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -4.3e+129], N[Not[LessEqual[ew, 1.65e+92]], $MachinePrecision]], N[Abs[N[((-ew) * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[Cos[t], $MachinePrecision] / ew), $MachinePrecision] * N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -4.3 \cdot 10^{+129} \lor \neg \left(ew \leq 1.65 \cdot 10^{+92}\right):\\
\;\;\;\;\left|\left(-ew\right) \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\cos t}{ew} \cdot \frac{eh}{\sin t}\right) \cdot \left(\cos t \cdot eh\right)\right|\\
\end{array}
\end{array}
if ew < -4.30000000000000021e129 or 1.64999999999999987e92 < ew Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Applied rewrites83.7%
Taylor expanded in eh around 0
Applied rewrites75.5%
if -4.30000000000000021e129 < ew < 1.64999999999999987e92Initial program 99.9%
Taylor expanded in eh around inf
Applied rewrites78.9%
Final simplification77.6%
(FPCore (eh ew t) :precision binary64 (if (<= eh -4.2e+119) (* (- eh) (cos t)) (if (<= eh 5.4e+16) (fabs (* (- ew) (sin t))) (* eh (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -4.2e+119) {
tmp = -eh * cos(t);
} else if (eh <= 5.4e+16) {
tmp = fabs((-ew * sin(t)));
} else {
tmp = 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) :: tmp
if (eh <= (-4.2d+119)) then
tmp = -eh * cos(t)
else if (eh <= 5.4d+16) then
tmp = abs((-ew * sin(t)))
else
tmp = eh * cos(t)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -4.2e+119) {
tmp = -eh * Math.cos(t);
} else if (eh <= 5.4e+16) {
tmp = Math.abs((-ew * Math.sin(t)));
} else {
tmp = eh * Math.cos(t);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -4.2e+119: tmp = -eh * math.cos(t) elif eh <= 5.4e+16: tmp = math.fabs((-ew * math.sin(t))) else: tmp = eh * math.cos(t) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -4.2e+119) tmp = Float64(Float64(-eh) * cos(t)); elseif (eh <= 5.4e+16) tmp = abs(Float64(Float64(-ew) * sin(t))); else tmp = Float64(eh * cos(t)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -4.2e+119) tmp = -eh * cos(t); elseif (eh <= 5.4e+16) tmp = abs((-ew * sin(t))); else tmp = eh * cos(t); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -4.2e+119], N[((-eh) * N[Cos[t], $MachinePrecision]), $MachinePrecision], If[LessEqual[eh, 5.4e+16], N[Abs[N[((-ew) * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -4.2 \cdot 10^{+119}:\\
\;\;\;\;\left(-eh\right) \cdot \cos t\\
\mathbf{elif}\;eh \leq 5.4 \cdot 10^{+16}:\\
\;\;\;\;\left|\left(-ew\right) \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;eh \cdot \cos t\\
\end{array}
\end{array}
if eh < -4.19999999999999966e119Initial program 99.8%
Applied rewrites10.3%
Applied rewrites7.7%
Taylor expanded in eh around -inf
Applied rewrites78.2%
if -4.19999999999999966e119 < eh < 5.4e16Initial program 99.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Applied rewrites89.7%
Taylor expanded in eh around 0
Applied rewrites64.8%
if 5.4e16 < eh Initial program 99.8%
Applied rewrites16.5%
Applied rewrites15.0%
Taylor expanded in eh around inf
Applied rewrites73.3%
Final simplification68.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2.05e+106) (not (<= ew 3e+87))) (* ew (sin t)) (* eh (cos t))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.05e+106) || !(ew <= 3e+87)) {
tmp = ew * sin(t);
} else {
tmp = 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) :: tmp
if ((ew <= (-2.05d+106)) .or. (.not. (ew <= 3d+87))) then
tmp = ew * sin(t)
else
tmp = eh * cos(t)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.05e+106) || !(ew <= 3e+87)) {
tmp = ew * Math.sin(t);
} else {
tmp = eh * Math.cos(t);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.05e+106) or not (ew <= 3e+87): tmp = ew * math.sin(t) else: tmp = eh * math.cos(t) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.05e+106) || !(ew <= 3e+87)) tmp = Float64(ew * sin(t)); else tmp = Float64(eh * cos(t)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.05e+106) || ~((ew <= 3e+87))) tmp = ew * sin(t); else tmp = eh * cos(t); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.05e+106], N[Not[LessEqual[ew, 3e+87]], $MachinePrecision]], N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision], N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.05 \cdot 10^{+106} \lor \neg \left(ew \leq 3 \cdot 10^{+87}\right):\\
\;\;\;\;ew \cdot \sin t\\
\mathbf{else}:\\
\;\;\;\;eh \cdot \cos t\\
\end{array}
\end{array}
if ew < -2.0500000000000001e106 or 2.9999999999999999e87 < ew Initial program 99.8%
Applied rewrites42.0%
Taylor expanded in eh around 0
Applied rewrites39.2%
if -2.0500000000000001e106 < ew < 2.9999999999999999e87Initial program 99.9%
Applied rewrites24.4%
Applied rewrites18.2%
Taylor expanded in eh around inf
Applied rewrites41.6%
Final simplification40.6%
(FPCore (eh ew t) :precision binary64 (if (<= eh -1.65e-249) (* (- eh) (cos t)) (if (<= eh 3.3e-110) (* ew (sin t)) (* eh (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.65e-249) {
tmp = -eh * cos(t);
} else if (eh <= 3.3e-110) {
tmp = ew * sin(t);
} else {
tmp = 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) :: tmp
if (eh <= (-1.65d-249)) then
tmp = -eh * cos(t)
else if (eh <= 3.3d-110) then
tmp = ew * sin(t)
else
tmp = eh * cos(t)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= -1.65e-249) {
tmp = -eh * Math.cos(t);
} else if (eh <= 3.3e-110) {
tmp = ew * Math.sin(t);
} else {
tmp = eh * Math.cos(t);
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= -1.65e-249: tmp = -eh * math.cos(t) elif eh <= 3.3e-110: tmp = ew * math.sin(t) else: tmp = eh * math.cos(t) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= -1.65e-249) tmp = Float64(Float64(-eh) * cos(t)); elseif (eh <= 3.3e-110) tmp = Float64(ew * sin(t)); else tmp = Float64(eh * cos(t)); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= -1.65e-249) tmp = -eh * cos(t); elseif (eh <= 3.3e-110) tmp = ew * sin(t); else tmp = eh * cos(t); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, -1.65e-249], N[((-eh) * N[Cos[t], $MachinePrecision]), $MachinePrecision], If[LessEqual[eh, 3.3e-110], N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision], N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -1.65 \cdot 10^{-249}:\\
\;\;\;\;\left(-eh\right) \cdot \cos t\\
\mathbf{elif}\;eh \leq 3.3 \cdot 10^{-110}:\\
\;\;\;\;ew \cdot \sin t\\
\mathbf{else}:\\
\;\;\;\;eh \cdot \cos t\\
\end{array}
\end{array}
if eh < -1.65e-249Initial program 99.8%
Applied rewrites30.0%
Applied rewrites26.0%
Taylor expanded in eh around -inf
Applied rewrites54.0%
if -1.65e-249 < eh < 3.2999999999999999e-110Initial program 99.9%
Applied rewrites43.1%
Taylor expanded in eh around 0
Applied rewrites41.4%
if 3.2999999999999999e-110 < eh Initial program 99.8%
Applied rewrites28.0%
Applied rewrites23.4%
Taylor expanded in eh around inf
Applied rewrites60.6%
Final simplification53.9%
(FPCore (eh ew t) :precision binary64 (if (<= eh 5.2e+16) (* ew (sin t)) eh))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= 5.2e+16) {
tmp = ew * sin(t);
} else {
tmp = 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 <= 5.2d+16) then
tmp = ew * sin(t)
else
tmp = eh
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= 5.2e+16) {
tmp = ew * Math.sin(t);
} else {
tmp = eh;
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= 5.2e+16: tmp = ew * math.sin(t) else: tmp = eh return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= 5.2e+16) tmp = Float64(ew * sin(t)); else tmp = eh; end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= 5.2e+16) tmp = ew * sin(t); else tmp = eh; end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, 5.2e+16], N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision], eh]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq 5.2 \cdot 10^{+16}:\\
\;\;\;\;ew \cdot \sin t\\
\mathbf{else}:\\
\;\;\;\;eh\\
\end{array}
\end{array}
if eh < 5.2e16Initial program 99.8%
Applied rewrites36.0%
Taylor expanded in eh around 0
Applied rewrites27.9%
if 5.2e16 < eh Initial program 99.8%
Applied rewrites16.5%
Applied rewrites15.0%
Taylor expanded in t around 0
Applied rewrites50.2%
(FPCore (eh ew t) :precision binary64 (if (<= eh 2.25e-95) (* ew t) eh))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= 2.25e-95) {
tmp = ew * t;
} else {
tmp = 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 <= 2.25d-95) then
tmp = ew * t
else
tmp = eh
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= 2.25e-95) {
tmp = ew * t;
} else {
tmp = eh;
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= 2.25e-95: tmp = ew * t else: tmp = eh return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= 2.25e-95) tmp = Float64(ew * t); else tmp = eh; end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= 2.25e-95) tmp = ew * t; else tmp = eh; end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, 2.25e-95], N[(ew * t), $MachinePrecision], eh]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq 2.25 \cdot 10^{-95}:\\
\;\;\;\;ew \cdot t\\
\mathbf{else}:\\
\;\;\;\;eh\\
\end{array}
\end{array}
if eh < 2.25e-95Initial program 99.8%
Applied rewrites34.0%
Taylor expanded in eh around 0
Applied rewrites27.3%
Taylor expanded in t around 0
Applied rewrites13.1%
if 2.25e-95 < eh Initial program 99.8%
Applied rewrites27.5%
Applied rewrites22.7%
Taylor expanded in t around 0
Applied rewrites41.9%
(FPCore (eh ew t) :precision binary64 eh)
double code(double eh, double ew, double t) {
return eh;
}
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 = eh
end function
public static double code(double eh, double ew, double t) {
return eh;
}
def code(eh, ew, t): return eh
function code(eh, ew, t) return eh end
function tmp = code(eh, ew, t) tmp = eh; end
code[eh_, ew_, t_] := eh
\begin{array}{l}
\\
eh
\end{array}
Initial program 99.8%
Applied rewrites31.8%
Applied rewrites28.3%
Taylor expanded in t around 0
Applied rewrites16.9%
herbie shell --seed 2025018
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))