
(FPCore (x y z) :precision binary64 (+ (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) + (z * sin(y));
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) + (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) + (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) + (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) + Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) + (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y + z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) + (z * sin(y));
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) + (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) + (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) + (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) + Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) + (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y + z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma (sin y) z (* (cos y) x)))
double code(double x, double y, double z) {
return fma(sin(y), z, (cos(y) * x));
}
function code(x, y, z) return fma(sin(y), z, Float64(cos(y) * x)) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * z + N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin y, z, \cos y \cdot x\right)
\end{array}
Initial program 99.7%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(if (<= x -4.8e+34)
(* (fma (sin y) (/ z x) (cos y)) x)
(if (<= x 8000000.0)
(* (fma (/ (* (cos y) x) z) 1.0 (sin y)) z)
(* (fma z (/ (sin y) x) (cos y)) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.8e+34) {
tmp = fma(sin(y), (z / x), cos(y)) * x;
} else if (x <= 8000000.0) {
tmp = fma(((cos(y) * x) / z), 1.0, sin(y)) * z;
} else {
tmp = fma(z, (sin(y) / x), cos(y)) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4.8e+34) tmp = Float64(fma(sin(y), Float64(z / x), cos(y)) * x); elseif (x <= 8000000.0) tmp = Float64(fma(Float64(Float64(cos(y) * x) / z), 1.0, sin(y)) * z); else tmp = Float64(fma(z, Float64(sin(y) / x), cos(y)) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4.8e+34], N[(N[(N[Sin[y], $MachinePrecision] * N[(z / x), $MachinePrecision] + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 8000000.0], N[(N[(N[(N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision] * 1.0 + N[Sin[y], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(z * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision] + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x\\
\mathbf{elif}\;x \leq 8000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{\sin y}{x}, \cos y\right) \cdot x\\
\end{array}
\end{array}
if x < -4.79999999999999974e34Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
associate-/l*N/A
lower-fma.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lift-cos.f6499.8
Applied rewrites99.8%
if -4.79999999999999974e34 < x < 8e6Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
if 8e6 < x Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (fma (cos y) x (* (sin y) z)))
double code(double x, double y, double z) {
return fma(cos(y), x, (sin(y) * z));
}
function code(x, y, z) return fma(cos(y), x, Float64(sin(y) * z)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * x + N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, x, \sin y \cdot z\right)
\end{array}
Initial program 99.7%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(if (<= x -4.8e+34)
(* (fma (sin y) (/ z x) (cos y)) x)
(if (<= x 15000000.0)
(* (fma (* (cos y) (/ x z)) 1.0 (sin y)) z)
(* (fma z (/ (sin y) x) (cos y)) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.8e+34) {
tmp = fma(sin(y), (z / x), cos(y)) * x;
} else if (x <= 15000000.0) {
tmp = fma((cos(y) * (x / z)), 1.0, sin(y)) * z;
} else {
tmp = fma(z, (sin(y) / x), cos(y)) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4.8e+34) tmp = Float64(fma(sin(y), Float64(z / x), cos(y)) * x); elseif (x <= 15000000.0) tmp = Float64(fma(Float64(cos(y) * Float64(x / z)), 1.0, sin(y)) * z); else tmp = Float64(fma(z, Float64(sin(y) / x), cos(y)) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4.8e+34], N[(N[(N[Sin[y], $MachinePrecision] * N[(z / x), $MachinePrecision] + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 15000000.0], N[(N[(N[(N[Cos[y], $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] * 1.0 + N[Sin[y], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(z * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision] + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x\\
\mathbf{elif}\;x \leq 15000000:\\
\;\;\;\;\mathsf{fma}\left(\cos y \cdot \frac{x}{z}, 1, \sin y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{\sin y}{x}, \cos y\right) \cdot x\\
\end{array}
\end{array}
if x < -4.79999999999999974e34Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
associate-/l*N/A
lower-fma.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lift-cos.f6499.8
Applied rewrites99.8%
if -4.79999999999999974e34 < x < 1.5e7Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
if 1.5e7 < x Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (+ (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) + (z * sin(y));
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) + (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) + (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) + (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) + Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) + (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y + z \cdot \sin y
\end{array}
Initial program 99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (sin y) x)))
(if (<= x -4.8e+34)
(* (fma (sin y) (/ z x) (cos y)) x)
(if (<= x 11000000.0)
(* (fma (/ x z) (cos y) (* x t_0)) z)
(* (fma z t_0 (cos y)) x)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / x;
double tmp;
if (x <= -4.8e+34) {
tmp = fma(sin(y), (z / x), cos(y)) * x;
} else if (x <= 11000000.0) {
tmp = fma((x / z), cos(y), (x * t_0)) * z;
} else {
tmp = fma(z, t_0, cos(y)) * x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(sin(y) / x) tmp = 0.0 if (x <= -4.8e+34) tmp = Float64(fma(sin(y), Float64(z / x), cos(y)) * x); elseif (x <= 11000000.0) tmp = Float64(fma(Float64(x / z), cos(y), Float64(x * t_0)) * z); else tmp = Float64(fma(z, t_0, cos(y)) * x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[x, -4.8e+34], N[(N[(N[Sin[y], $MachinePrecision] * N[(z / x), $MachinePrecision] + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 11000000.0], N[(N[(N[(x / z), $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(z * t$95$0 + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{x}\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x\\
\mathbf{elif}\;x \leq 11000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot t\_0\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t\_0, \cos y\right) \cdot x\\
\end{array}
\end{array}
if x < -4.79999999999999974e34Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
associate-/l*N/A
lower-fma.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lift-cos.f6499.8
Applied rewrites99.8%
if -4.79999999999999974e34 < x < 1.1e7Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift-sin.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites64.2%
Taylor expanded in x around inf
Applied rewrites99.7%
if 1.1e7 < x Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (sin y) x)))
(if (or (<= x -5e+34) (not (<= x 11000000.0)))
(* (fma z t_0 (cos y)) x)
(* (fma (/ x z) (cos y) (* x t_0)) z))))
double code(double x, double y, double z) {
double t_0 = sin(y) / x;
double tmp;
if ((x <= -5e+34) || !(x <= 11000000.0)) {
tmp = fma(z, t_0, cos(y)) * x;
} else {
tmp = fma((x / z), cos(y), (x * t_0)) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(sin(y) / x) tmp = 0.0 if ((x <= -5e+34) || !(x <= 11000000.0)) tmp = Float64(fma(z, t_0, cos(y)) * x); else tmp = Float64(fma(Float64(x / z), cos(y), Float64(x * t_0)) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]}, If[Or[LessEqual[x, -5e+34], N[Not[LessEqual[x, 11000000.0]], $MachinePrecision]], N[(N[(z * t$95$0 + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{x}\\
\mathbf{if}\;x \leq -5 \cdot 10^{+34} \lor \neg \left(x \leq 11000000\right):\\
\;\;\;\;\mathsf{fma}\left(z, t\_0, \cos y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot t\_0\right) \cdot z\\
\end{array}
\end{array}
if x < -4.9999999999999998e34 or 1.1e7 < x Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-lft-identityN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
if -4.9999999999999998e34 < x < 1.1e7Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift-sin.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites64.2%
Taylor expanded in x around inf
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e-123) (not (<= x 10000000.0))) (* (fma 1.0 (/ (* (sin y) z) x) (cos y)) x) (* (fma (/ x z) (cos y) (* x (/ (sin y) x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e-123) || !(x <= 10000000.0)) {
tmp = fma(1.0, ((sin(y) * z) / x), cos(y)) * x;
} else {
tmp = fma((x / z), cos(y), (x * (sin(y) / x))) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -1e-123) || !(x <= 10000000.0)) tmp = Float64(fma(1.0, Float64(Float64(sin(y) * z) / x), cos(y)) * x); else tmp = Float64(fma(Float64(x / z), cos(y), Float64(x * Float64(sin(y) / x))) * z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e-123], N[Not[LessEqual[x, 10000000.0]], $MachinePrecision]], N[(N[(1.0 * N[(N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(x * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-123} \lor \neg \left(x \leq 10000000\right):\\
\;\;\;\;\mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\
\end{array}
\end{array}
if x < -1.0000000000000001e-123 or 1e7 < x Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
if -1.0000000000000001e-123 < x < 1e7Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-sin.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites66.1%
Taylor expanded in x around inf
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+78) (not (<= z 1.65e-87))) (* (fma (/ x z) (cos y) (* x (/ (sin y) x))) z) (* (fma z (/ (cos y) z) (/ (* (sin y) z) x)) x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+78) || !(z <= 1.65e-87)) {
tmp = fma((x / z), cos(y), (x * (sin(y) / x))) * z;
} else {
tmp = fma(z, (cos(y) / z), ((sin(y) * z) / x)) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -2e+78) || !(z <= 1.65e-87)) tmp = Float64(fma(Float64(x / z), cos(y), Float64(x * Float64(sin(y) / x))) * z); else tmp = Float64(fma(z, Float64(cos(y) / z), Float64(Float64(sin(y) * z) / x)) * x); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+78], N[Not[LessEqual[z, 1.65e-87]], $MachinePrecision]], N[(N[(N[(x / z), $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(x * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(z * N[(N[Cos[y], $MachinePrecision] / z), $MachinePrecision] + N[(N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+78} \lor \neg \left(z \leq 1.65 \cdot 10^{-87}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{\cos y}{z}, \frac{\sin y \cdot z}{x}\right) \cdot x\\
\end{array}
\end{array}
if z < -2.00000000000000002e78 or 1.65e-87 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-sin.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites63.9%
Taylor expanded in x around inf
Applied rewrites99.6%
if -2.00000000000000002e78 < z < 1.65e-87Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
distribute-lft-inN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-cos.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (* (fma z (/ (cos y) z) (/ (* (sin y) z) x)) x))
double code(double x, double y, double z) {
return fma(z, (cos(y) / z), ((sin(y) * z) / x)) * x;
}
function code(x, y, z) return Float64(fma(z, Float64(cos(y) / z), Float64(Float64(sin(y) * z) / x)) * x) end
code[x_, y_, z_] := N[(N[(z * N[(N[Cos[y], $MachinePrecision] / z), $MachinePrecision] + N[(N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \frac{\cos y}{z}, \frac{\sin y \cdot z}{x}\right) \cdot x
\end{array}
Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6492.4
Applied rewrites92.4%
Taylor expanded in z around inf
distribute-lft-inN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-cos.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6492.2
Applied rewrites92.2%
herbie shell --seed 2025065
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutY from diagrams-lib-1.3.0.3"
:precision binary64
(+ (* x (cos y)) (* z (sin y))))