
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((-eh * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* eh (sin t)) (sin (atan (/ (* eh (tan t)) (- ew))))) (* (* (cos (atan (* (/ (tan t) ew) eh))) (cos t)) ew))))
double code(double eh, double ew, double t) {
return fabs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * cos(t)) * ew)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * cos(t)) * ew)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * Math.tan(t)) / -ew)))) - ((Math.cos(Math.atan(((Math.tan(t) / ew) * eh))) * Math.cos(t)) * ew)));
}
def code(eh, ew, t): return math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((eh * math.tan(t)) / -ew)))) - ((math.cos(math.atan(((math.tan(t) / ew) * eh))) * math.cos(t)) * ew)))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))) - Float64(Float64(cos(atan(Float64(Float64(tan(t) / ew) * eh))) * cos(t)) * ew))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * cos(t)) * ew))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) - \left(\cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot \cos t\right) \cdot ew\right|
\end{array}
Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (* eh (tan t)) (- ew))))
(t_2
(fabs (- (* (* eh (sin t)) (sin t_1)) (* (* ew (cos t)) (cos t_1)))))
(t_3 (* (cos t) ew)))
(if (<= t_2 1e-105)
(fabs (/ (fma (sin t) (* (/ (tan t) ew) (* eh eh)) t_3) 1.0))
(if (<= t_2 5e+129)
(fabs
(fma
(/ ew 1.0)
(cos t)
(* (* (- eh) (sin t)) (tanh (* t (fma -1.0 (/ eh ew) 0.0))))))
(fabs t_3)))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
double t_2 = fabs((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(t_1))));
double t_3 = cos(t) * ew;
double tmp;
if (t_2 <= 1e-105) {
tmp = fabs((fma(sin(t), ((tan(t) / ew) * (eh * eh)), t_3) / 1.0));
} else if (t_2 <= 5e+129) {
tmp = fabs(fma((ew / 1.0), cos(t), ((-eh * sin(t)) * tanh((t * fma(-1.0, (eh / ew), 0.0))))));
} else {
tmp = fabs(t_3);
}
return tmp;
}
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) t_2 = abs(Float64(Float64(Float64(eh * sin(t)) * sin(t_1)) - Float64(Float64(ew * cos(t)) * cos(t_1)))) t_3 = Float64(cos(t) * ew) tmp = 0.0 if (t_2 <= 1e-105) tmp = abs(Float64(fma(sin(t), Float64(Float64(tan(t) / ew) * Float64(eh * eh)), t_3) / 1.0)); elseif (t_2 <= 5e+129) tmp = abs(fma(Float64(ew / 1.0), cos(t), Float64(Float64(Float64(-eh) * sin(t)) * tanh(Float64(t * fma(-1.0, Float64(eh / ew), 0.0)))))); else tmp = abs(t_3); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, If[LessEqual[t$95$2, 1e-105], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * N[(eh * eh), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision] / 1.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$2, 5e+129], N[Abs[N[(N[(ew / 1.0), $MachinePrecision] * N[Cos[t], $MachinePrecision] + N[(N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Tanh[N[(t * N[(-1.0 * N[(eh / ew), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[t$95$3], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
t_2 := \left|\left(eh \cdot \sin t\right) \cdot \sin t\_1 - \left(ew \cdot \cos t\right) \cdot \cos t\_1\right|\\
t_3 := \cos t \cdot ew\\
\mathbf{if}\;t\_2 \leq 10^{-105}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, \frac{\tan t}{ew} \cdot \left(eh \cdot eh\right), t\_3\right)}{1}\right|\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+129}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{ew}{1}, \cos t, \left(\left(-eh\right) \cdot \sin t\right) \cdot \tanh \left(t \cdot \mathsf{fma}\left(-1, \frac{eh}{ew}, 0\right)\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_3\right|\\
\end{array}
\end{array}
if (fabs.f64 (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))))) < 9.99999999999999965e-106Initial program 99.8%
Applied rewrites87.0%
Taylor expanded in eh around 0
Applied rewrites74.3%
if 9.99999999999999965e-106 < (fabs.f64 (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))))) < 5.0000000000000003e129Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
associate-*l/N/A
lower-/.f64N/A
*-lft-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
sqr-neg-revN/A
cosh-asinh-revN/A
Applied rewrites99.7%
Taylor expanded in eh around 0
Applied rewrites98.5%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites98.5%
Taylor expanded in t around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6467.3
Applied rewrites67.3%
if 5.0000000000000003e129 < (fabs.f64 (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))))) Initial program 99.7%
Applied rewrites52.3%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6459.2
Applied rewrites59.2%
Final simplification77.5%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* eh (sin t)) (sin (atan (/ (* eh (tan t)) (- ew))))) (/ (* (cos t) ew) 1.0))))
double code(double eh, double ew, double t) {
return fabs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(t) * ew) / 1.0)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(t) * ew) / 1.0d0)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * Math.tan(t)) / -ew)))) - ((Math.cos(t) * ew) / 1.0)));
}
def code(eh, ew, t): return math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((eh * math.tan(t)) / -ew)))) - ((math.cos(t) * ew) / 1.0)))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))) - Float64(Float64(cos(t) * ew) / 1.0))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(t) * ew) / 1.0))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) - \frac{\cos t \cdot ew}{1}\right|
\end{array}
Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
associate-*l/N/A
lower-/.f64N/A
*-lft-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
sqr-neg-revN/A
cosh-asinh-revN/A
Applied rewrites99.7%
Taylor expanded in eh around 0
Applied rewrites98.6%
Final simplification98.6%
(FPCore (eh ew t)
:precision binary64
(if (or (<= t -3.9e-5) (not (<= t 4e-7)))
(fabs
(fma
(/ ew 1.0)
(cos t)
(* (* (- eh) (sin t)) (tanh (* t (fma -1.0 (/ eh ew) 0.0))))))
(fabs
(fma (- eh) (* (sin (atan (/ (/ (* (sin t) eh) (- ew)) (cos t)))) t) ew))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -3.9e-5) || !(t <= 4e-7)) {
tmp = fabs(fma((ew / 1.0), cos(t), ((-eh * sin(t)) * tanh((t * fma(-1.0, (eh / ew), 0.0))))));
} else {
tmp = fabs(fma(-eh, (sin(atan((((sin(t) * eh) / -ew) / cos(t)))) * t), ew));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((t <= -3.9e-5) || !(t <= 4e-7)) tmp = abs(fma(Float64(ew / 1.0), cos(t), Float64(Float64(Float64(-eh) * sin(t)) * tanh(Float64(t * fma(-1.0, Float64(eh / ew), 0.0)))))); else tmp = abs(fma(Float64(-eh), Float64(sin(atan(Float64(Float64(Float64(sin(t) * eh) / Float64(-ew)) / cos(t)))) * t), ew)); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -3.9e-5], N[Not[LessEqual[t, 4e-7]], $MachinePrecision]], N[Abs[N[(N[(ew / 1.0), $MachinePrecision] * N[Cos[t], $MachinePrecision] + N[(N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Tanh[N[(t * N[(-1.0 * N[(eh / ew), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-eh) * N[(N[Sin[N[ArcTan[N[(N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] / (-ew)), $MachinePrecision] / N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * t), $MachinePrecision] + ew), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.9 \cdot 10^{-5} \lor \neg \left(t \leq 4 \cdot 10^{-7}\right):\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{ew}{1}, \cos t, \left(\left(-eh\right) \cdot \sin t\right) \cdot \tanh \left(t \cdot \mathsf{fma}\left(-1, \frac{eh}{ew}, 0\right)\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(-eh, \sin \tan^{-1} \left(\frac{\frac{\sin t \cdot eh}{-ew}}{\cos t}\right) \cdot t, ew\right)\right|\\
\end{array}
\end{array}
if t < -3.8999999999999999e-5 or 3.9999999999999998e-7 < t Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
associate-*l/N/A
lower-/.f64N/A
*-lft-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
sqr-neg-revN/A
cosh-asinh-revN/A
Applied rewrites99.5%
Taylor expanded in eh around 0
Applied rewrites97.6%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites97.6%
Taylor expanded in t around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
if -3.8999999999999999e-5 < t < 3.9999999999999998e-7Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
associate-*l/N/A
lower-/.f64N/A
*-lft-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
sqr-neg-revN/A
cosh-asinh-revN/A
Applied rewrites100.0%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.7%
Final simplification98.2%
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* eh (sin t)) (sin (atan (/ (* (- eh) t) ew)))) (/ (* (cos t) ew) 1.0))))
double code(double eh, double ew, double t) {
return fabs((((eh * sin(t)) * sin(atan(((-eh * t) / ew)))) - ((cos(t) * ew) / 1.0)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((eh * sin(t)) * sin(atan(((-eh * t) / ew)))) - ((cos(t) * ew) / 1.0d0)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((-eh * t) / ew)))) - ((Math.cos(t) * ew) / 1.0)));
}
def code(eh, ew, t): return math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((-eh * t) / ew)))) - ((math.cos(t) * ew) / 1.0)))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-eh) * t) / ew)))) - Float64(Float64(cos(t) * ew) / 1.0))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * sin(t)) * sin(atan(((-eh * t) / ew)))) - ((cos(t) * ew) / 1.0))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[((-eh) * t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right) - \frac{\cos t \cdot ew}{1}\right|
\end{array}
Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
associate-*l/N/A
lower-/.f64N/A
*-lft-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
sqr-neg-revN/A
cosh-asinh-revN/A
Applied rewrites99.7%
Taylor expanded in eh around 0
Applied rewrites98.6%
Taylor expanded in t around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6498.2
Applied rewrites98.2%
Final simplification98.2%
(FPCore (eh ew t) :precision binary64 (fabs (* (cos t) ew)))
double code(double eh, double ew, double t) {
return fabs((cos(t) * ew));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((cos(t) * ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.cos(t) * ew));
}
def code(eh, ew, t): return math.fabs((math.cos(t) * ew))
function code(eh, ew, t) return abs(Float64(cos(t) * ew)) end
function tmp = code(eh, ew, t) tmp = abs((cos(t) * ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\cos t \cdot ew\right|
\end{array}
Initial program 99.7%
Applied rewrites67.9%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6459.7
Applied rewrites59.7%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* (* -0.5 ew) t) t ew)))
double code(double eh, double ew, double t) {
return fabs(fma(((-0.5 * ew) * t), t, ew));
}
function code(eh, ew, t) return abs(fma(Float64(Float64(-0.5 * ew) * t), t, ew)) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(-0.5 * ew), $MachinePrecision] * t), $MachinePrecision] * t + ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(\left(-0.5 \cdot ew\right) \cdot t, t, ew\right)\right|
\end{array}
Initial program 99.7%
Applied rewrites67.9%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6430.9
Applied rewrites30.9%
Taylor expanded in eh around 0
Applied rewrites35.5%
Applied rewrites35.5%
(FPCore (eh ew t) :precision binary64 (fabs (fma (* -0.5 ew) (* t t) ew)))
double code(double eh, double ew, double t) {
return fabs(fma((-0.5 * ew), (t * t), ew));
}
function code(eh, ew, t) return abs(fma(Float64(-0.5 * ew), Float64(t * t), ew)) end
code[eh_, ew_, t_] := N[Abs[N[(N[(-0.5 * ew), $MachinePrecision] * N[(t * t), $MachinePrecision] + ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(-0.5 \cdot ew, t \cdot t, ew\right)\right|
\end{array}
Initial program 99.7%
Applied rewrites67.9%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6430.9
Applied rewrites30.9%
Taylor expanded in eh around 0
Applied rewrites35.5%
herbie shell --seed 2024351
(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)))))))