
(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}
Herbie found 9 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 (asinh (/ eh (* (tan t) ew))))) (fabs (fma (/ (sin t) (cosh t_1)) ew (* (tanh t_1) (* (cos t) eh))))))
double code(double eh, double ew, double t) {
double t_1 = asinh((eh / (tan(t) * ew)));
return fabs(fma((sin(t) / cosh(t_1)), ew, (tanh(t_1) * (cos(t) * eh))));
}
function code(eh, ew, t) t_1 = asinh(Float64(eh / Float64(tan(t) * ew))) return abs(fma(Float64(sin(t) / cosh(t_1)), ew, Float64(tanh(t_1) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcSinh[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[Sin[t], $MachinePrecision] / N[Cosh[t$95$1], $MachinePrecision]), $MachinePrecision] * ew + N[(N[Tanh[t$95$1], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sinh^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\\
\left|\mathsf{fma}\left(\frac{\sin t}{\cosh t\_1}, ew, \tanh t\_1 \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
(FPCore (eh ew t) :precision binary64 (fabs (fma (sin t) ew (* (tanh (asinh (/ eh (* (tan t) ew)))) (* (cos t) eh)))))
double code(double eh, double ew, double t) {
return fabs(fma(sin(t), ew, (tanh(asinh((eh / (tan(t) * ew)))) * (cos(t) * eh))));
}
function code(eh, ew, t) return abs(fma(sin(t), ew, Float64(tanh(asinh(Float64(eh / Float64(tan(t) * ew)))) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[t], $MachinePrecision] * ew + N[(N[Tanh[N[ArcSinh[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\sin t, ew, \tanh \sinh^{-1} \left(\frac{eh}{\tan t \cdot ew}\right) \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-sin.f6498.4
Applied rewrites98.4%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (asinh (/ eh (* ew t))))) (fabs (fma (/ (sin t) (cosh t_1)) ew (* (tanh t_1) (* (cos t) eh))))))
double code(double eh, double ew, double t) {
double t_1 = asinh((eh / (ew * t)));
return fabs(fma((sin(t) / cosh(t_1)), ew, (tanh(t_1) * (cos(t) * eh))));
}
function code(eh, ew, t) t_1 = asinh(Float64(eh / Float64(ew * t))) return abs(fma(Float64(sin(t) / cosh(t_1)), ew, Float64(tanh(t_1) * Float64(cos(t) * eh)))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcSinh[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[Sin[t], $MachinePrecision] / N[Cosh[t$95$1], $MachinePrecision]), $MachinePrecision] * ew + N[(N[Tanh[t$95$1], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sinh^{-1} \left(\frac{eh}{ew \cdot t}\right)\\
\left|\mathsf{fma}\left(\frac{\sin t}{\cosh t\_1}, ew, \tanh t\_1 \cdot \left(\cos t \cdot eh\right)\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in t around 0
lower-*.f6490.0
Applied rewrites90.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* ew t)))
(t_2
(fabs
(/ (fma t_1 (* (cos t) eh) (* (sin t) ew)) (cosh (asinh t_1))))))
(if (<= t -6.5e-10)
t_2
(if (<= t 1.35e-113)
(fabs (* (tanh (asinh (/ eh (* (tan t) ew)))) eh))
t_2))))
double code(double eh, double ew, double t) {
double t_1 = eh / (ew * t);
double t_2 = fabs((fma(t_1, (cos(t) * eh), (sin(t) * ew)) / cosh(asinh(t_1))));
double tmp;
if (t <= -6.5e-10) {
tmp = t_2;
} else if (t <= 1.35e-113) {
tmp = fabs((tanh(asinh((eh / (tan(t) * ew)))) * eh));
} else {
tmp = t_2;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(ew * t)) t_2 = abs(Float64(fma(t_1, Float64(cos(t) * eh), Float64(sin(t) * ew)) / cosh(asinh(t_1)))) tmp = 0.0 if (t <= -6.5e-10) tmp = t_2; elseif (t <= 1.35e-113) tmp = abs(Float64(tanh(asinh(Float64(eh / Float64(tan(t) * ew)))) * eh)); else tmp = t_2; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[(t$95$1 * N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] + N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -6.5e-10], t$95$2, If[LessEqual[t, 1.35e-113], N[Abs[N[(N[Tanh[N[ArcSinh[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{ew \cdot t}\\
t_2 := \left|\frac{\mathsf{fma}\left(t\_1, \cos t \cdot eh, \sin t \cdot ew\right)}{\cosh \sinh^{-1} t\_1}\right|\\
\mathbf{if}\;t \leq -6.5 \cdot 10^{-10}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t \leq 1.35 \cdot 10^{-113}:\\
\;\;\;\;\left|\tanh \sinh^{-1} \left(\frac{eh}{\tan t \cdot ew}\right) \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if t < -6.5000000000000003e-10 or 1.34999999999999998e-113 < t Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
associate-*l/N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
Applied rewrites63.0%
Taylor expanded in t around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in t around 0
lower-*.f6458.6
Applied rewrites58.6%
if -6.5000000000000003e-10 < t < 1.34999999999999998e-113Initial program 99.8%
Taylor expanded in t around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6441.8
Applied rewrites41.8%
Applied rewrites41.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* (sin t) ew))))
(if (<= t -1.2e-9)
t_1
(if (<= t 7e-10)
(fabs (* (tanh (asinh (* (cos t) (/ eh (* t ew))))) eh))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((sin(t) * ew));
double tmp;
if (t <= -1.2e-9) {
tmp = t_1;
} else if (t <= 7e-10) {
tmp = fabs((tanh(asinh((cos(t) * (eh / (t * ew))))) * eh));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((math.sin(t) * ew)) tmp = 0 if t <= -1.2e-9: tmp = t_1 elif t <= 7e-10: tmp = math.fabs((math.tanh(math.asinh((math.cos(t) * (eh / (t * ew))))) * eh)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(sin(t) * ew)) tmp = 0.0 if (t <= -1.2e-9) tmp = t_1; elseif (t <= 7e-10) tmp = abs(Float64(tanh(asinh(Float64(cos(t) * Float64(eh / Float64(t * ew))))) * eh)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((sin(t) * ew)); tmp = 0.0; if (t <= -1.2e-9) tmp = t_1; elseif (t <= 7e-10) tmp = abs((tanh(asinh((cos(t) * (eh / (t * ew))))) * eh)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1.2e-9], t$95$1, If[LessEqual[t, 7e-10], N[Abs[N[(N[Tanh[N[ArcSinh[N[(N[Cos[t], $MachinePrecision] * N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\sin t \cdot ew\right|\\
\mathbf{if}\;t \leq -1.2 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 7 \cdot 10^{-10}:\\
\;\;\;\;\left|\tanh \sinh^{-1} \left(\cos t \cdot \frac{eh}{t \cdot ew}\right) \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.2e-9 or 6.99999999999999961e-10 < t Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6442.1
Applied rewrites42.1%
if -1.2e-9 < t < 6.99999999999999961e-10Initial program 99.8%
Taylor expanded in t around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6441.8
Applied rewrites41.8%
Taylor expanded in t around 0
Applied rewrites40.0%
Applied rewrites40.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (fabs (* (sin t) ew))))
(if (<= t -1.2e-9)
t_1
(if (<= t 7e-10)
(fabs (* (tanh (asinh (/ eh (* (tan t) ew)))) eh))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs((sin(t) * ew));
double tmp;
if (t <= -1.2e-9) {
tmp = t_1;
} else if (t <= 7e-10) {
tmp = fabs((tanh(asinh((eh / (tan(t) * ew)))) * eh));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs((math.sin(t) * ew)) tmp = 0 if t <= -1.2e-9: tmp = t_1 elif t <= 7e-10: tmp = math.fabs((math.tanh(math.asinh((eh / (math.tan(t) * ew)))) * eh)) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(sin(t) * ew)) tmp = 0.0 if (t <= -1.2e-9) tmp = t_1; elseif (t <= 7e-10) tmp = abs(Float64(tanh(asinh(Float64(eh / Float64(tan(t) * ew)))) * eh)); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs((sin(t) * ew)); tmp = 0.0; if (t <= -1.2e-9) tmp = t_1; elseif (t <= 7e-10) tmp = abs((tanh(asinh((eh / (tan(t) * ew)))) * eh)); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1.2e-9], t$95$1, If[LessEqual[t, 7e-10], N[Abs[N[(N[Tanh[N[ArcSinh[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\sin t \cdot ew\right|\\
\mathbf{if}\;t \leq -1.2 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 7 \cdot 10^{-10}:\\
\;\;\;\;\left|\tanh \sinh^{-1} \left(\frac{eh}{\tan t \cdot ew}\right) \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.2e-9 or 6.99999999999999961e-10 < t Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6442.1
Applied rewrites42.1%
if -1.2e-9 < t < 6.99999999999999961e-10Initial program 99.8%
Taylor expanded in t around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6441.8
Applied rewrites41.8%
Applied rewrites41.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* ew t))) (t_2 (fabs (* (sin t) ew))))
(if (<= t -1e-81)
t_2
(if (<= t 6.6e-136) (fabs (/ (* t_1 eh) (cosh (asinh t_1)))) t_2))))
double code(double eh, double ew, double t) {
double t_1 = eh / (ew * t);
double t_2 = fabs((sin(t) * ew));
double tmp;
if (t <= -1e-81) {
tmp = t_2;
} else if (t <= 6.6e-136) {
tmp = fabs(((t_1 * eh) / cosh(asinh(t_1))));
} else {
tmp = t_2;
}
return tmp;
}
def code(eh, ew, t): t_1 = eh / (ew * t) t_2 = math.fabs((math.sin(t) * ew)) tmp = 0 if t <= -1e-81: tmp = t_2 elif t <= 6.6e-136: tmp = math.fabs(((t_1 * eh) / math.cosh(math.asinh(t_1)))) else: tmp = t_2 return tmp
function code(eh, ew, t) t_1 = Float64(eh / Float64(ew * t)) t_2 = abs(Float64(sin(t) * ew)) tmp = 0.0 if (t <= -1e-81) tmp = t_2; elseif (t <= 6.6e-136) tmp = abs(Float64(Float64(t_1 * eh) / cosh(asinh(t_1)))); else tmp = t_2; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh / (ew * t); t_2 = abs((sin(t) * ew)); tmp = 0.0; if (t <= -1e-81) tmp = t_2; elseif (t <= 6.6e-136) tmp = abs(((t_1 * eh) / cosh(asinh(t_1)))); else tmp = t_2; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1e-81], t$95$2, If[LessEqual[t, 6.6e-136], N[Abs[N[(N[(t$95$1 * eh), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{ew \cdot t}\\
t_2 := \left|\sin t \cdot ew\right|\\
\mathbf{if}\;t \leq -1 \cdot 10^{-81}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t \leq 6.6 \cdot 10^{-136}:\\
\;\;\;\;\left|\frac{t\_1 \cdot eh}{\cosh \sinh^{-1} t\_1}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if t < -9.9999999999999996e-82 or 6.60000000000000035e-136 < t Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6442.1
Applied rewrites42.1%
if -9.9999999999999996e-82 < t < 6.60000000000000035e-136Initial program 99.8%
Taylor expanded in t around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6441.8
Applied rewrites41.8%
lift-*.f64N/A
lift-sin.f64N/A
lift-atan.f64N/A
sin-atanN/A
lift-/.f64N/A
Applied rewrites15.5%
Taylor expanded in t around 0
lower-*.f6413.2
Applied rewrites13.2%
Taylor expanded in t around 0
lower-*.f6414.8
Applied rewrites14.8%
(FPCore (eh ew t) :precision binary64 (fabs (* (sin t) ew)))
double code(double eh, double ew, double t) {
return fabs((sin(t) * ew));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((sin(t) * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.sin(t) * ew));
}
def code(eh, ew, t): return math.fabs((math.sin(t) * ew))
function code(eh, ew, t) return abs(Float64(sin(t) * ew)) end
function tmp = code(eh, ew, t) tmp = abs((sin(t) * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sin t \cdot ew\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6442.1
Applied rewrites42.1%
(FPCore (eh ew t) :precision binary64 (fabs (* ew t)))
double code(double eh, double ew, double t) {
return fabs((ew * 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 * t))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * t));
}
def code(eh, ew, t): return math.fabs((ew * t))
function code(eh, ew, t) return abs(Float64(ew * t)) end
function tmp = code(eh, ew, t) tmp = abs((ew * t)); end
code[eh_, ew_, t_] := N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot t\right|
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6442.1
Applied rewrites42.1%
Taylor expanded in t around 0
Applied rewrites18.7%
herbie shell --seed 2025155
(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))))))))