
(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 14 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 (/ (/ eh ew) (tan t))))
(fabs
(fma
ew
(* (sin t) (cos (atan t_1)))
(* (tanh (asinh t_1)) (* (cos t) eh))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs(fma(ew, (sin(t) * cos(atan(t_1))), (tanh(asinh(t_1)) * (cos(t) * eh))));
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(fma(ew, Float64(sin(t) * cos(atan(t_1))), Float64(tanh(asinh(t_1)) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} t\_1, \tanh \sinh^{-1} t\_1 \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(fma
ew
(* (sin t) (/ 1.0 (sqrt (+ 1.0 (pow t_1 2.0)))))
(* (tanh (asinh t_1)) (* (cos t) eh))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs(fma(ew, (sin(t) * (1.0 / sqrt((1.0 + pow(t_1, 2.0))))), (tanh(asinh(t_1)) * (cos(t) * eh))));
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(fma(ew, Float64(sin(t) * Float64(1.0 / sqrt(Float64(1.0 + (t_1 ^ 2.0))))), Float64(tanh(asinh(t_1)) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(1.0 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\mathsf{fma}\left(ew, \sin t \cdot \frac{1}{\sqrt{1 + {t\_1}^{2}}}, \tanh \sinh^{-1} t\_1 \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (* (sin t) (/ 1.0 (sqrt (+ 1.0 (pow (/ (/ eh ew) (tan t)) 2.0))))) (* (tanh (/ (* eh (cos t)) (* ew (sin t)))) (* (cos t) eh)))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, (sin(t) * (1.0 / sqrt((1.0 + pow(((eh / ew) / tan(t)), 2.0))))), (tanh(((eh * cos(t)) / (ew * sin(t)))) * (cos(t) * eh))));
}
function code(eh, ew, t) return abs(fma(ew, Float64(sin(t) * Float64(1.0 / sqrt(Float64(1.0 + (Float64(Float64(eh / ew) / tan(t)) ^ 2.0))))), Float64(tanh(Float64(Float64(eh * cos(t)) / Float64(ew * sin(t)))) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(1.0 + N[Power[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Tanh[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \sin t \cdot \frac{1}{\sqrt{1 + {\left(\frac{\frac{eh}{ew}}{\tan t}\right)}^{2}}}, \tanh \left(\frac{eh \cdot \cos t}{ew \cdot \sin t}\right) \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6497.3
Applied rewrites97.3%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (* (sin t) (cos (atan (/ eh (* ew t))))) (* (tanh (asinh (/ (/ eh ew) (tan t)))) (* (cos t) eh)))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, (sin(t) * cos(atan((eh / (ew * t))))), (tanh(asinh(((eh / ew) / tan(t)))) * (cos(t) * eh))));
}
function code(eh, ew, t) return abs(fma(ew, Float64(sin(t) * cos(atan(Float64(eh / Float64(ew * t))))), Float64(tanh(asinh(Float64(Float64(eh / ew) / tan(t)))) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Tanh[N[ArcSinh[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right), \tanh \sinh^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(+
(* (* ew (sin t)) (/ 1.0 (sqrt (+ 1.0 (* t_1 t_1)))))
(*
(* eh (cos t))
(sin
(atan (/ (/ (fma -0.3333333333333333 (* (* t t) eh) eh) ew) t))))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs((((ew * sin(t)) * (1.0 / sqrt((1.0 + (t_1 * t_1))))) + ((eh * cos(t)) * sin(atan(((fma(-0.3333333333333333, ((t * t) * eh), eh) / ew) / t))))));
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(Float64(Float64(Float64(ew * sin(t)) * Float64(1.0 / sqrt(Float64(1.0 + Float64(t_1 * t_1))))) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(fma(-0.3333333333333333, Float64(Float64(t * t) * eh), eh) / ew) / t)))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(N[(-0.3333333333333333 * N[(N[(t * t), $MachinePrecision] * eh), $MachinePrecision] + eh), $MachinePrecision] / ew), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\left(ew \cdot \sin t\right) \cdot \frac{1}{\sqrt{1 + t\_1 \cdot t\_1}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{\mathsf{fma}\left(-0.3333333333333333, \left(t \cdot t\right) \cdot eh, eh\right)}{ew}}{t}\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.9
Applied rewrites96.9%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6496.9
Applied rewrites96.9%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (sin t) (* (tanh (asinh (/ (/ eh ew) (tan t)))) (* (cos t) eh)))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, sin(t), (tanh(asinh(((eh / ew) / tan(t)))) * (cos(t) * eh))));
}
function code(eh, ew, t) return abs(fma(ew, sin(t), Float64(tanh(asinh(Float64(Float64(eh / ew) / tan(t)))) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Sin[t], $MachinePrecision] + N[(N[Tanh[N[ArcSinh[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \sin t, \tanh \sinh^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-sin.f6496.3
Applied rewrites96.3%
(FPCore (eh ew t) :precision binary64 (fabs (fma ew (sin t) (* (tanh (/ (* eh (cos t)) (* ew (sin t)))) (* (cos t) eh)))))
double code(double eh, double ew, double t) {
return fabs(fma(ew, sin(t), (tanh(((eh * cos(t)) / (ew * sin(t)))) * (cos(t) * eh))));
}
function code(eh, ew, t) return abs(fma(ew, sin(t), Float64(tanh(Float64(Float64(eh * cos(t)) / Float64(ew * sin(t)))) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Sin[t], $MachinePrecision] + N[(N[Tanh[N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(ew, \sin t, \tanh \left(\frac{eh \cdot \cos t}{ew \cdot \sin t}\right) \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
Initial program 99.8%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-sin.f6496.3
Applied rewrites96.3%
Taylor expanded in eh around 0
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6496.3
Applied rewrites96.3%
(FPCore (eh ew t)
:precision binary64
(if (or (<= ew -2.1e-63) (not (<= ew 2.05e-111)))
(fabs
(* ew (+ (sin t) (/ (* eh (* (cos t) (sin (atan (/ eh (* ew t)))))) ew))))
(fabs (* eh (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.1e-63) || !(ew <= 2.05e-111)) {
tmp = fabs((ew * (sin(t) + ((eh * (cos(t) * sin(atan((eh / (ew * t)))))) / ew))));
} else {
tmp = fabs((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.1d-63)) .or. (.not. (ew <= 2.05d-111))) then
tmp = abs((ew * (sin(t) + ((eh * (cos(t) * sin(atan((eh / (ew * t)))))) / ew))))
else
tmp = abs((eh * cos(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.1e-63) || !(ew <= 2.05e-111)) {
tmp = Math.abs((ew * (Math.sin(t) + ((eh * (Math.cos(t) * Math.sin(Math.atan((eh / (ew * t)))))) / ew))));
} else {
tmp = Math.abs((eh * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.1e-63) or not (ew <= 2.05e-111): tmp = math.fabs((ew * (math.sin(t) + ((eh * (math.cos(t) * math.sin(math.atan((eh / (ew * t)))))) / ew)))) else: tmp = math.fabs((eh * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.1e-63) || !(ew <= 2.05e-111)) tmp = abs(Float64(ew * Float64(sin(t) + Float64(Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * t)))))) / ew)))); else tmp = abs(Float64(eh * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.1e-63) || ~((ew <= 2.05e-111))) tmp = abs((ew * (sin(t) + ((eh * (cos(t) * sin(atan((eh / (ew * t)))))) / ew)))); else tmp = abs((eh * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.1e-63], N[Not[LessEqual[ew, 2.05e-111]], $MachinePrecision]], N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] + N[(N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.1 \cdot 10^{-63} \lor \neg \left(ew \leq 2.05 \cdot 10^{-111}\right):\\
\;\;\;\;\left|ew \cdot \left(\sin t + \frac{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right)}{ew}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\end{array}
\end{array}
if ew < -2.1e-63 or 2.04999999999999984e-111 < ew Initial program 99.7%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
Taylor expanded in ew around inf
pow2N/A
cos-atan-revN/A
sin-atan-revN/A
lower-*.f64N/A
Applied rewrites94.9%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6487.8
Applied rewrites87.8%
if -2.1e-63 < ew < 2.04999999999999984e-111Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.0
Applied rewrites98.0%
sin-atanN/A
lower-/.f64N/A
Applied rewrites17.0%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6490.3
Applied rewrites90.3%
Final simplification88.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(if (<= ew -3.1e-64)
(fabs (fma ew (sin t) (* (tanh (asinh t_1)) eh)))
(if (<= ew 1.55e-151)
(fabs (* eh (cos t)))
(fabs (+ (* (* ew (sin t)) (cos (atan t_1))) eh))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
double tmp;
if (ew <= -3.1e-64) {
tmp = fabs(fma(ew, sin(t), (tanh(asinh(t_1)) * eh)));
} else if (ew <= 1.55e-151) {
tmp = fabs((eh * cos(t)));
} else {
tmp = fabs((((ew * sin(t)) * cos(atan(t_1))) + eh));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) tmp = 0.0 if (ew <= -3.1e-64) tmp = abs(fma(ew, sin(t), Float64(tanh(asinh(t_1)) * eh))); elseif (ew <= 1.55e-151) tmp = abs(Float64(eh * cos(t))); else tmp = abs(Float64(Float64(Float64(ew * sin(t)) * cos(atan(t_1))) + eh)); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -3.1e-64], N[Abs[N[(ew * N[Sin[t], $MachinePrecision] + N[(N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 1.55e-151], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + eh), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\mathbf{if}\;ew \leq -3.1 \cdot 10^{-64}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew, \sin t, \tanh \sinh^{-1} t\_1 \cdot eh\right)\right|\\
\mathbf{elif}\;ew \leq 1.55 \cdot 10^{-151}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} t\_1 + eh\right|\\
\end{array}
\end{array}
if ew < -3.10000000000000025e-64Initial program 99.7%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
Taylor expanded in eh around 0
lower-sin.f6494.9
Applied rewrites94.9%
Taylor expanded in t around 0
Applied rewrites88.3%
if -3.10000000000000025e-64 < ew < 1.54999999999999992e-151Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.9
Applied rewrites97.9%
sin-atanN/A
lower-/.f64N/A
Applied rewrites17.9%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6490.8
Applied rewrites90.8%
if 1.54999999999999992e-151 < ew Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.0
Applied rewrites97.0%
sin-atanN/A
lower-/.f64N/A
Applied rewrites42.0%
Taylor expanded in t around 0
Applied rewrites82.8%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -3.1e-64) (not (<= ew 1.55e-151))) (fabs (fma ew (sin t) (* (tanh (asinh (/ (/ eh ew) (tan t)))) eh))) (fabs (* eh (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -3.1e-64) || !(ew <= 1.55e-151)) {
tmp = fabs(fma(ew, sin(t), (tanh(asinh(((eh / ew) / tan(t)))) * eh)));
} else {
tmp = fabs((eh * cos(t)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((ew <= -3.1e-64) || !(ew <= 1.55e-151)) tmp = abs(fma(ew, sin(t), Float64(tanh(asinh(Float64(Float64(eh / ew) / tan(t)))) * eh))); else tmp = abs(Float64(eh * cos(t))); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -3.1e-64], N[Not[LessEqual[ew, 1.55e-151]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision] + N[(N[Tanh[N[ArcSinh[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -3.1 \cdot 10^{-64} \lor \neg \left(ew \leq 1.55 \cdot 10^{-151}\right):\\
\;\;\;\;\left|\mathsf{fma}\left(ew, \sin t, \tanh \sinh^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot eh\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\end{array}
\end{array}
if ew < -3.10000000000000025e-64 or 1.54999999999999992e-151 < ew Initial program 99.8%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-sin.f6495.6
Applied rewrites95.6%
Taylor expanded in t around 0
Applied rewrites85.0%
if -3.10000000000000025e-64 < ew < 1.54999999999999992e-151Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.9
Applied rewrites97.9%
sin-atanN/A
lower-/.f64N/A
Applied rewrites17.9%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6490.8
Applied rewrites90.8%
Final simplification87.1%
(FPCore (eh ew t) :precision binary64 (if (or (<= ew -2.15e+52) (not (<= ew 2.6e+89))) (fabs (* ew (sin t))) (fabs (* eh (cos t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.15e+52) || !(ew <= 2.6e+89)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs((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.15d+52)) .or. (.not. (ew <= 2.6d+89))) then
tmp = abs((ew * sin(t)))
else
tmp = abs((eh * cos(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if ((ew <= -2.15e+52) || !(ew <= 2.6e+89)) {
tmp = Math.abs((ew * Math.sin(t)));
} else {
tmp = Math.abs((eh * Math.cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (ew <= -2.15e+52) or not (ew <= 2.6e+89): tmp = math.fabs((ew * math.sin(t))) else: tmp = math.fabs((eh * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((ew <= -2.15e+52) || !(ew <= 2.6e+89)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(eh * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((ew <= -2.15e+52) || ~((ew <= 2.6e+89))) tmp = abs((ew * sin(t))); else tmp = abs((eh * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -2.15e+52], N[Not[LessEqual[ew, 2.6e+89]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq -2.15 \cdot 10^{+52} \lor \neg \left(ew \leq 2.6 \cdot 10^{+89}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\end{array}
\end{array}
if ew < -2.15e52 or 2.6000000000000001e89 < ew Initial program 99.7%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.7
Applied rewrites99.7%
Taylor expanded in eh around 0
pow2N/A
cos-atan-revN/A
sin-atan-revN/A
lower-*.f64N/A
lower-sin.f6477.6
Applied rewrites77.6%
if -2.15e52 < ew < 2.6000000000000001e89Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.4
Applied rewrites96.4%
sin-atanN/A
lower-/.f64N/A
Applied rewrites25.0%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6478.7
Applied rewrites78.7%
Final simplification78.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (* eh eh) ew)))
(if (<= ew 1.8e+202)
(fabs (* eh (cos t)))
(fabs
(/ (fma 0.5 t_1 (* (* t t) (+ ew (* -0.4166666666666667 t_1)))) t)))))
double code(double eh, double ew, double t) {
double t_1 = (eh * eh) / ew;
double tmp;
if (ew <= 1.8e+202) {
tmp = fabs((eh * cos(t)));
} else {
tmp = fabs((fma(0.5, t_1, ((t * t) * (ew + (-0.4166666666666667 * t_1)))) / t));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh * eh) / ew) tmp = 0.0 if (ew <= 1.8e+202) tmp = abs(Float64(eh * cos(t))); else tmp = abs(Float64(fma(0.5, t_1, Float64(Float64(t * t) * Float64(ew + Float64(-0.4166666666666667 * t_1)))) / t)); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh * eh), $MachinePrecision] / ew), $MachinePrecision]}, If[LessEqual[ew, 1.8e+202], N[Abs[N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(0.5 * t$95$1 + N[(N[(t * t), $MachinePrecision] * N[(ew + N[(-0.4166666666666667 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh \cdot eh}{ew}\\
\mathbf{if}\;ew \leq 1.8 \cdot 10^{+202}:\\
\;\;\;\;\left|eh \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(0.5, t\_1, \left(t \cdot t\right) \cdot \left(ew + -0.4166666666666667 \cdot t\_1\right)\right)}{t}\right|\\
\end{array}
\end{array}
if ew < 1.80000000000000004e202Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.7
Applied rewrites96.7%
sin-atanN/A
lower-/.f64N/A
Applied rewrites33.3%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-cos.f6462.5
Applied rewrites62.5%
if 1.80000000000000004e202 < ew Initial program 99.9%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.9
Applied rewrites99.9%
Taylor expanded in eh around 0
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites79.3%
Taylor expanded in t around 0
lower-/.f64N/A
Applied rewrites37.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (* eh eh) ew)))
(if (<= ew 2.2e+185)
(fabs eh)
(fabs
(/ (fma 0.5 t_1 (* (* t t) (+ ew (* -0.4166666666666667 t_1)))) t)))))
double code(double eh, double ew, double t) {
double t_1 = (eh * eh) / ew;
double tmp;
if (ew <= 2.2e+185) {
tmp = fabs(eh);
} else {
tmp = fabs((fma(0.5, t_1, ((t * t) * (ew + (-0.4166666666666667 * t_1)))) / t));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh * eh) / ew) tmp = 0.0 if (ew <= 2.2e+185) tmp = abs(eh); else tmp = abs(Float64(fma(0.5, t_1, Float64(Float64(t * t) * Float64(ew + Float64(-0.4166666666666667 * t_1)))) / t)); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh * eh), $MachinePrecision] / ew), $MachinePrecision]}, If[LessEqual[ew, 2.2e+185], N[Abs[eh], $MachinePrecision], N[Abs[N[(N[(0.5 * t$95$1 + N[(N[(t * t), $MachinePrecision] * N[(ew + N[(-0.4166666666666667 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh \cdot eh}{ew}\\
\mathbf{if}\;ew \leq 2.2 \cdot 10^{+185}:\\
\;\;\;\;\left|eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(0.5, t\_1, \left(t \cdot t\right) \cdot \left(ew + -0.4166666666666667 \cdot t\_1\right)\right)}{t}\right|\\
\end{array}
\end{array}
if ew < 2.2000000000000001e185Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.7
Applied rewrites96.7%
sin-atanN/A
lower-/.f64N/A
Applied rewrites32.9%
Taylor expanded in t around 0
Applied rewrites42.4%
if 2.2000000000000001e185 < ew Initial program 99.9%
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
cos-atanN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-tan.f6499.9
Applied rewrites99.9%
Taylor expanded in eh around 0
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites73.4%
Taylor expanded in t around 0
lower-/.f64N/A
Applied rewrites36.6%
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
return fabs(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 = abs(eh)
end function
public static double code(double eh, double ew, double t) {
return Math.abs(eh);
}
def code(eh, ew, t): return math.fabs(eh)
function code(eh, ew, t) return abs(eh) end
function tmp = code(eh, ew, t) tmp = abs(eh); end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}
\\
\left|eh\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.9
Applied rewrites96.9%
sin-atanN/A
lower-/.f64N/A
Applied rewrites36.0%
Taylor expanded in t around 0
Applied rewrites39.9%
herbie shell --seed 2025044
(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))))))))