
(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}
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}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
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}
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}
(FPCore (eh ew t) :precision binary64 (fabs (fma (* (/ 1.0 (cosh (asinh (/ (* (tan t) eh) ew)))) ew) (cos t) (* (* (sin t) (- eh)) (tanh (asinh (* (/ (tan t) ew) (- eh))))))))
double code(double eh, double ew, double t) {
return fabs(fma(((1.0 / cosh(asinh(((tan(t) * eh) / ew)))) * ew), cos(t), ((sin(t) * -eh) * tanh(asinh(((tan(t) / ew) * -eh))))));
}
function code(eh, ew, t) return abs(fma(Float64(Float64(1.0 / cosh(asinh(Float64(Float64(tan(t) * eh) / ew)))) * ew), cos(t), Float64(Float64(sin(t) * Float64(-eh)) * tanh(asinh(Float64(Float64(tan(t) / ew) * Float64(-eh))))))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(1.0 / N[Cosh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision] * N[Cos[t], $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * (-eh)), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\mathsf{fma}\left(\frac{1}{\cosh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)} \cdot ew, \cos t, \left(\sin t \cdot \left(-eh\right)\right) \cdot \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right)\right)\right|
Initial program 99.8%
Applied rewrites99.8%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (asinh (/ (* (tan t) eh) ew)))) (fabs (fma (* (sin t) eh) (tanh t_1) (* (/ (cos t) (cosh t_1)) ew)))))
double code(double eh, double ew, double t) {
double t_1 = asinh(((tan(t) * eh) / ew));
return fabs(fma((sin(t) * eh), tanh(t_1), ((cos(t) / cosh(t_1)) * ew)));
}
function code(eh, ew, t) t_1 = asinh(Float64(Float64(tan(t) * eh) / ew)) return abs(fma(Float64(sin(t) * eh), tanh(t_1), Float64(Float64(cos(t) / cosh(t_1)) * ew))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[t$95$1], $MachinePrecision] + N[(N[(N[Cos[t], $MachinePrecision] / N[Cosh[t$95$1], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_1 := \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)\\
\left|\mathsf{fma}\left(\sin t \cdot eh, \tanh t\_1, \frac{\cos t}{\cosh t\_1} \cdot ew\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (tanh (asinh (* (/ t ew) (- eh)))) (* (sin t) eh)) (/ (* ew (cos t)) (cosh (asinh (* (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs(((tanh(asinh(((t / ew) * -eh))) * (sin(t) * eh)) - ((ew * cos(t)) / cosh(asinh(((eh / ew) * tan(t)))))));
}
def code(eh, ew, t): return math.fabs(((math.tanh(math.asinh(((t / ew) * -eh))) * (math.sin(t) * eh)) - ((ew * math.cos(t)) / math.cosh(math.asinh(((eh / ew) * math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(tanh(asinh(Float64(Float64(t / ew) * Float64(-eh)))) * Float64(sin(t) * eh)) - Float64(Float64(ew * cos(t)) / cosh(asinh(Float64(Float64(eh / ew) * tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs(((tanh(asinh(((t / ew) * -eh))) * (sin(t) * eh)) - ((ew * cos(t)) / cosh(asinh(((eh / ew) * tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Tanh[N[ArcSinh[N[(N[(t / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\tanh \sinh^{-1} \left(\frac{t}{ew} \cdot \left(-eh\right)\right) \cdot \left(\sin t \cdot eh\right) - \frac{ew \cdot \cos t}{\cosh \sinh^{-1} \left(\frac{eh}{ew} \cdot \tan t\right)}\right|
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-/.f6499.1
Applied rewrites99.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f6499.1
Applied rewrites99.1%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* (sin t) eh) (tanh (asinh (/ (* (tan t) eh) ew))) (* (cos t) ew))))
double code(double eh, double ew, double t) {
return fabs(fma((sin(t) * eh), tanh(asinh(((tan(t) * eh) / ew))), (cos(t) * ew)));
}
function code(eh, ew, t) return abs(fma(Float64(sin(t) * eh), tanh(asinh(Float64(Float64(tan(t) * eh) / ew))), Float64(cos(t) * ew))) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\mathsf{fma}\left(\sin t \cdot eh, \tanh \sinh^{-1} \left(\frac{\tan t \cdot eh}{ew}\right), \cos t \cdot ew\right)\right|
Initial program 99.8%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-cos.f6498.5
Applied rewrites98.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (* (- (fabs eh)) t) ew)))
(if (<= (fabs eh) 4.8e-125)
(fabs (* ew (cos t)))
(fabs
(-
(/ (* (cos t) ew) (sqrt (fma t_1 t_1 1.0)))
(* (tanh (asinh t_1)) (* (sin t) (fabs eh))))))))double code(double eh, double ew, double t) {
double t_1 = (-fabs(eh) * t) / ew;
double tmp;
if (fabs(eh) <= 4.8e-125) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((((cos(t) * ew) / sqrt(fma(t_1, t_1, 1.0))) - (tanh(asinh(t_1)) * (sin(t) * fabs(eh)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(Float64(-abs(eh)) * t) / ew) tmp = 0.0 if (abs(eh) <= 4.8e-125) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(Float64(Float64(cos(t) * ew) / sqrt(fma(t_1, t_1, 1.0))) - Float64(tanh(asinh(t_1)) * Float64(sin(t) * abs(eh))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[((-N[Abs[eh], $MachinePrecision]) * t), $MachinePrecision] / ew), $MachinePrecision]}, If[LessEqual[N[Abs[eh], $MachinePrecision], 4.8e-125], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * N[Abs[eh], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_1 := \frac{\left(-\left|eh\right|\right) \cdot t}{ew}\\
\mathbf{if}\;\left|eh\right| \leq 4.8 \cdot 10^{-125}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\cos t \cdot ew}{\sqrt{\mathsf{fma}\left(t\_1, t\_1, 1\right)}} - \tanh \sinh^{-1} t\_1 \cdot \left(\sin t \cdot \left|eh\right|\right)\right|\\
\end{array}
if eh < 4.8000000000000003e-125Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6461.8
Applied rewrites61.8%
if 4.8000000000000003e-125 < eh Initial program 99.8%
Taylor expanded in t around 0
lower-*.f64N/A
lower-*.f6490.1
Applied rewrites90.1%
Taylor expanded in t around 0
lower-*.f64N/A
lower-*.f6490.1
Applied rewrites90.1%
Applied rewrites89.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (- (fabs eh)) t)))
(if (<= (fabs eh) 1.46e-54)
(fabs (* ew (cos t)))
(fabs
(-
(* (/ (cos t) (sqrt (fma t_1 (/ t_1 (* ew ew)) 1.0))) ew)
(* (tanh (asinh (/ t_1 ew))) (* (sin t) (fabs eh))))))))double code(double eh, double ew, double t) {
double t_1 = -fabs(eh) * t;
double tmp;
if (fabs(eh) <= 1.46e-54) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((((cos(t) / sqrt(fma(t_1, (t_1 / (ew * ew)), 1.0))) * ew) - (tanh(asinh((t_1 / ew))) * (sin(t) * fabs(eh)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(-abs(eh)) * t) tmp = 0.0 if (abs(eh) <= 1.46e-54) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(Float64(Float64(cos(t) / sqrt(fma(t_1, Float64(t_1 / Float64(ew * ew)), 1.0))) * ew) - Float64(tanh(asinh(Float64(t_1 / ew))) * Float64(sin(t) * abs(eh))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[((-N[Abs[eh], $MachinePrecision]) * t), $MachinePrecision]}, If[LessEqual[N[Abs[eh], $MachinePrecision], 1.46e-54], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(N[Cos[t], $MachinePrecision] / N[Sqrt[N[(t$95$1 * N[(t$95$1 / N[(ew * ew), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision] - N[(N[Tanh[N[ArcSinh[N[(t$95$1 / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[t], $MachinePrecision] * N[Abs[eh], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_1 := \left(-\left|eh\right|\right) \cdot t\\
\mathbf{if}\;\left|eh\right| \leq 1.46 \cdot 10^{-54}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\cos t}{\sqrt{\mathsf{fma}\left(t\_1, \frac{t\_1}{ew \cdot ew}, 1\right)}} \cdot ew - \tanh \sinh^{-1} \left(\frac{t\_1}{ew}\right) \cdot \left(\sin t \cdot \left|eh\right|\right)\right|\\
\end{array}
if eh < 1.4600000000000001e-54Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6461.8
Applied rewrites61.8%
if 1.4600000000000001e-54 < eh Initial program 99.8%
Taylor expanded in t around 0
lower-*.f64N/A
lower-*.f6490.1
Applied rewrites90.1%
Taylor expanded in t around 0
lower-*.f64N/A
lower-*.f6490.1
Applied rewrites90.1%
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
mult-flipN/A
cos-atanN/A
lift-atan.f64N/A
lift-cos.f64N/A
lower-*.f6453.3
Applied rewrites61.3%
Applied rewrites85.2%
(FPCore (eh ew t)
:precision binary64
(if (<= (fabs eh) 1.2e-30)
(fabs (* ew (cos t)))
(fabs
(*
(fma
ew
(/ 1.0 (fabs eh))
(* (tanh (asinh (/ (* (tan t) (fabs eh)) ew))) (sin t)))
(fabs eh)))))double code(double eh, double ew, double t) {
double tmp;
if (fabs(eh) <= 1.2e-30) {
tmp = fabs((ew * cos(t)));
} else {
tmp = fabs((fma(ew, (1.0 / fabs(eh)), (tanh(asinh(((tan(t) * fabs(eh)) / ew))) * sin(t))) * fabs(eh)));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (abs(eh) <= 1.2e-30) tmp = abs(Float64(ew * cos(t))); else tmp = abs(Float64(fma(ew, Float64(1.0 / abs(eh)), Float64(tanh(asinh(Float64(Float64(tan(t) * abs(eh)) / ew))) * sin(t))) * abs(eh))); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[N[Abs[eh], $MachinePrecision], 1.2e-30], N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * N[(1.0 / N[Abs[eh], $MachinePrecision]), $MachinePrecision] + N[(N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] * N[Abs[eh], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[eh], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|eh\right| \leq 1.2 \cdot 10^{-30}:\\
\;\;\;\;\left|ew \cdot \cos t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew, \frac{1}{\left|eh\right|}, \tanh \sinh^{-1} \left(\frac{\tan t \cdot \left|eh\right|}{ew}\right) \cdot \sin t\right) \cdot \left|eh\right|\right|\\
\end{array}
if eh < 1.19999999999999992e-30Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6461.8
Applied rewrites61.8%
if 1.19999999999999992e-30 < eh Initial program 99.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower--.f64N/A
Applied rewrites87.9%
Applied rewrites51.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.1
Applied rewrites87.8%
Taylor expanded in t around 0
lower-/.f6472.0
Applied rewrites72.0%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (cos t))))
double code(double eh, double ew, double t) {
return fabs((ew * cos(t)));
}
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 * cos(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.cos(t)))
function code(eh, ew, t) return abs(Float64(ew * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|ew \cdot \cos t\right|
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6461.8
Applied rewrites61.8%
(FPCore (eh ew t) :precision binary64 (if (<= (fabs t) 0.00032) (fabs (* (fma (* (fabs t) (fabs t)) -0.5 1.0) ew)) (fabs (* (/ ew eh) eh))))
double code(double eh, double ew, double t) {
double tmp;
if (fabs(t) <= 0.00032) {
tmp = fabs((fma((fabs(t) * fabs(t)), -0.5, 1.0) * ew));
} else {
tmp = fabs(((ew / eh) * eh));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (abs(t) <= 0.00032) tmp = abs(Float64(fma(Float64(abs(t) * abs(t)), -0.5, 1.0) * ew)); else tmp = abs(Float64(Float64(ew / eh) * eh)); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[N[Abs[t], $MachinePrecision], 0.00032], N[Abs[N[(N[(N[(N[Abs[t], $MachinePrecision] * N[Abs[t], $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew / eh), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|t\right| \leq 0.00032:\\
\;\;\;\;\left|\mathsf{fma}\left(\left|t\right| \cdot \left|t\right|, -0.5, 1\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{ew}{eh} \cdot eh\right|\\
\end{array}
if t < 3.20000000000000026e-4Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6461.8
Applied rewrites61.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6438.9
Applied rewrites38.9%
Applied rewrites38.9%
if 3.20000000000000026e-4 < t Initial program 99.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower--.f64N/A
Applied rewrites87.9%
Applied rewrites51.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.1
Applied rewrites87.8%
Taylor expanded in t around 0
lower-/.f6435.4
Applied rewrites35.4%
(FPCore (eh ew t) :precision binary64 (fabs (* (/ ew eh) eh)))
double code(double eh, double ew, double t) {
return fabs(((ew / eh) * 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(((ew / eh) * eh))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((ew / eh) * eh));
}
def code(eh, ew, t): return math.fabs(((ew / eh) * eh))
function code(eh, ew, t) return abs(Float64(Float64(ew / eh) * eh)) end
function tmp = code(eh, ew, t) tmp = abs(((ew / eh) * eh)); end
code[eh_, ew_, t_] := N[Abs[N[(N[(ew / eh), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\left|\frac{ew}{eh} \cdot eh\right|
Initial program 99.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower--.f64N/A
Applied rewrites87.9%
Applied rewrites51.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.1
Applied rewrites87.8%
Taylor expanded in t around 0
lower-/.f6435.4
Applied rewrites35.4%
herbie shell --seed 2025173
(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)))))))