
(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 5 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 (let* ((t_1 (atan (/ (* eh (tan t)) (- ew))))) (fabs (- (* (* eh (sin t)) (sin t_1)) (* (* ew (cos t)) (cos t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
return fabs((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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((((eh * Math.sin(t)) * Math.sin(t_1)) - ((ew * Math.cos(t)) * Math.cos(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) return math.fabs((((eh * math.sin(t)) * math.sin(t_1)) - ((ew * math.cos(t)) * math.cos(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(t_1)) - Float64(Float64(ew * cos(t)) * cos(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = abs((((eh * sin(t)) * sin(t_1)) - ((ew * cos(t)) * cos(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[(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]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\left|\left(eh \cdot \sin t\right) \cdot \sin t\_1 - \left(ew \cdot \cos t\right) \cdot \cos t\_1\right|
\end{array}
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (- eh) ew) (tan t)))
(t_2 (cos (atan t_1)))
(t_3 (* (tanh (asinh t_1)) (sin t))))
(if (<= ew -5e+71)
(fabs
(*
(-
(* (/ eh ew) (- (sin t)))
(* (cos t) (cos (atan (* (/ eh ew) (tan t))))))
(- ew)))
(if (<= ew 7.8e-100)
(fabs (* (- (/ (* (* (cos t) ew) t_2) eh) t_3) eh))
(fabs (* (fma eh (/ t_3 ew) (* t_2 (- (cos t)))) (- ew)))))))
double code(double eh, double ew, double t) {
double t_1 = (-eh / ew) * tan(t);
double t_2 = cos(atan(t_1));
double t_3 = tanh(asinh(t_1)) * sin(t);
double tmp;
if (ew <= -5e+71) {
tmp = fabs(((((eh / ew) * -sin(t)) - (cos(t) * cos(atan(((eh / ew) * tan(t)))))) * -ew));
} else if (ew <= 7.8e-100) {
tmp = fabs((((((cos(t) * ew) * t_2) / eh) - t_3) * eh));
} else {
tmp = fabs((fma(eh, (t_3 / ew), (t_2 * -cos(t))) * -ew));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(Float64(-eh) / ew) * tan(t)) t_2 = cos(atan(t_1)) t_3 = Float64(tanh(asinh(t_1)) * sin(t)) tmp = 0.0 if (ew <= -5e+71) tmp = abs(Float64(Float64(Float64(Float64(eh / ew) * Float64(-sin(t))) - Float64(cos(t) * cos(atan(Float64(Float64(eh / ew) * tan(t)))))) * Float64(-ew))); elseif (ew <= 7.8e-100) tmp = abs(Float64(Float64(Float64(Float64(Float64(cos(t) * ew) * t_2) / eh) - t_3) * eh)); else tmp = abs(Float64(fma(eh, Float64(t_3 / ew), Float64(t_2 * Float64(-cos(t)))) * Float64(-ew))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[((-eh) / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -5e+71], N[Abs[N[(N[(N[(N[(eh / ew), $MachinePrecision] * (-N[Sin[t], $MachinePrecision])), $MachinePrecision] - N[(N[Cos[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-ew)), $MachinePrecision]], $MachinePrecision], If[LessEqual[ew, 7.8e-100], N[Abs[N[(N[(N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] * t$95$2), $MachinePrecision] / eh), $MachinePrecision] - t$95$3), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(eh * N[(t$95$3 / ew), $MachinePrecision] + N[(t$95$2 * (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * (-ew)), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-eh}{ew} \cdot \tan t\\
t_2 := \cos \tan^{-1} t\_1\\
t_3 := \tanh \sinh^{-1} t\_1 \cdot \sin t\\
\mathbf{if}\;ew \leq -5 \cdot 10^{+71}:\\
\;\;\;\;\left|\left(\frac{eh}{ew} \cdot \left(-\sin t\right) - \cos t \cdot \cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right)\right) \cdot \left(-ew\right)\right|\\
\mathbf{elif}\;ew \leq 7.8 \cdot 10^{-100}:\\
\;\;\;\;\left|\left(\frac{\left(\cos t \cdot ew\right) \cdot t\_2}{eh} - t\_3\right) \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, \frac{t\_3}{ew}, t\_2 \cdot \left(-\cos t\right)\right) \cdot \left(-ew\right)\right|\\
\end{array}
\end{array}
if ew < -4.99999999999999972e71Initial program 99.9%
Taylor expanded in ew around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites88.6%
Taylor expanded in eh around inf
lower-*.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
if -4.99999999999999972e71 < ew < 7.79999999999999955e-100Initial program 99.7%
Taylor expanded in eh around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
if 7.79999999999999955e-100 < ew Initial program 99.8%
Taylor expanded in ew around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
Applied rewrites99.8%
Final simplification99.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (/ (- eh) ew) (tan t))))
(fabs
(*
(fma
eh
(/ (* (tanh (asinh t_1)) (sin t)) ew)
(* (cos (atan t_1)) (- (cos t))))
(- ew)))))
double code(double eh, double ew, double t) {
double t_1 = (-eh / ew) * tan(t);
return fabs((fma(eh, ((tanh(asinh(t_1)) * sin(t)) / ew), (cos(atan(t_1)) * -cos(t))) * -ew));
}
function code(eh, ew, t) t_1 = Float64(Float64(Float64(-eh) / ew) * tan(t)) return abs(Float64(fma(eh, Float64(Float64(tanh(asinh(t_1)) * sin(t)) / ew), Float64(cos(atan(t_1)) * Float64(-cos(t)))) * Float64(-ew))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[((-eh) / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(eh * N[(N[(N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] + N[(N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision] * (-N[Cos[t], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * (-ew)), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-eh}{ew} \cdot \tan t\\
\left|\mathsf{fma}\left(eh, \frac{\tanh \sinh^{-1} t\_1 \cdot \sin t}{ew}, \cos \tan^{-1} t\_1 \cdot \left(-\cos t\right)\right) \cdot \left(-ew\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Taylor expanded in ew around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
Applied rewrites90.3%
Final simplification90.3%
(FPCore (eh ew t) :precision binary64 (fabs (* (- (* (/ eh ew) (- (sin t))) (* (cos t) (cos (atan (* (/ eh ew) (tan t)))))) (- ew))))
double code(double eh, double ew, double t) {
return fabs(((((eh / ew) * -sin(t)) - (cos(t) * cos(atan(((eh / ew) * tan(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 / ew) * -sin(t)) - (cos(t) * cos(atan(((eh / ew) * tan(t)))))) * -ew))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((((eh / ew) * -Math.sin(t)) - (Math.cos(t) * Math.cos(Math.atan(((eh / ew) * Math.tan(t)))))) * -ew));
}
def code(eh, ew, t): return math.fabs(((((eh / ew) * -math.sin(t)) - (math.cos(t) * math.cos(math.atan(((eh / ew) * math.tan(t)))))) * -ew))
function code(eh, ew, t) return abs(Float64(Float64(Float64(Float64(eh / ew) * Float64(-sin(t))) - Float64(cos(t) * cos(atan(Float64(Float64(eh / ew) * tan(t)))))) * Float64(-ew))) end
function tmp = code(eh, ew, t) tmp = abs(((((eh / ew) * -sin(t)) - (cos(t) * cos(atan(((eh / ew) * tan(t)))))) * -ew)); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(N[(eh / ew), $MachinePrecision] * (-N[Sin[t], $MachinePrecision])), $MachinePrecision] - N[(N[Cos[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-ew)), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(\frac{eh}{ew} \cdot \left(-\sin t\right) - \cos t \cdot \cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right)\right) \cdot \left(-ew\right)\right|
\end{array}
Initial program 99.8%
Taylor expanded in ew around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
Applied rewrites90.3%
Taylor expanded in t around inf
Applied rewrites60.5%
Taylor expanded in eh around inf
lower-*.f64N/A
lift-sin.f6484.0
Applied rewrites84.0%
Final simplification84.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (log (* ew (* 0.5 (/ (cos t) (* eh (sin t)))))))
(t_2 (exp t_1))
(t_3 (exp (- t_1))))
(fabs
(-
(fma
-1.0
(* ew (* (cos t) (cos (atan (* (/ eh ew) (tan t))))))
(/ (* eh (* (sin t) (- t_2 t_3))) (+ t_2 t_3)))))))
double code(double eh, double ew, double t) {
double t_1 = log((ew * (0.5 * (cos(t) / (eh * sin(t))))));
double t_2 = exp(t_1);
double t_3 = exp(-t_1);
return fabs(-fma(-1.0, (ew * (cos(t) * cos(atan(((eh / ew) * tan(t)))))), ((eh * (sin(t) * (t_2 - t_3))) / (t_2 + t_3))));
}
function code(eh, ew, t) t_1 = log(Float64(ew * Float64(0.5 * Float64(cos(t) / Float64(eh * sin(t)))))) t_2 = exp(t_1) t_3 = exp(Float64(-t_1)) return abs(Float64(-fma(-1.0, Float64(ew * Float64(cos(t) * cos(atan(Float64(Float64(eh / ew) * tan(t)))))), Float64(Float64(eh * Float64(sin(t) * Float64(t_2 - t_3))) / Float64(t_2 + t_3))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Log[N[(ew * N[(0.5 * N[(N[Cos[t], $MachinePrecision] / N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Exp[(-t$95$1)], $MachinePrecision]}, N[Abs[(-N[(-1.0 * N[(ew * N[(N[Cos[t], $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[(N[Sin[t], $MachinePrecision] * N[(t$95$2 - t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 + t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(ew \cdot \left(0.5 \cdot \frac{\cos t}{eh \cdot \sin t}\right)\right)\\
t_2 := e^{t\_1}\\
t_3 := e^{-t\_1}\\
\left|-\mathsf{fma}\left(-1, ew \cdot \left(\cos t \cdot \cos \tan^{-1} \left(\frac{eh}{ew} \cdot \tan t\right)\right), \frac{eh \cdot \left(\sin t \cdot \left(t\_2 - t\_3\right)\right)}{t\_2 + t\_3}\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Taylor expanded in ew around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
Applied rewrites90.3%
Taylor expanded in ew around 0
Applied rewrites32.9%
Final simplification32.9%
herbie shell --seed 2025057
(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)))))))