
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Initial program 99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ x (sin y)) (* z (cos y)))))
(if (<= t_0 -4000000000.0)
(+ z x)
(if (<= t_0 -0.05)
(sin y)
(if (<= t_0 0.002)
(fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))
(if (<= t_0 1.0) (sin y) (+ z x)))))))
double code(double x, double y, double z) {
double t_0 = (x + sin(y)) + (z * cos(y));
double tmp;
if (t_0 <= -4000000000.0) {
tmp = z + x;
} else if (t_0 <= -0.05) {
tmp = sin(y);
} else if (t_0 <= 0.002) {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
} else if (t_0 <= 1.0) {
tmp = sin(y);
} else {
tmp = z + x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + sin(y)) + Float64(z * cos(y))) tmp = 0.0 if (t_0 <= -4000000000.0) tmp = Float64(z + x); elseif (t_0 <= -0.05) tmp = sin(y); elseif (t_0 <= 0.002) tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x)); elseif (t_0 <= 1.0) tmp = sin(y); else tmp = Float64(z + x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4000000000.0], N[(z + x), $MachinePrecision], If[LessEqual[t$95$0, -0.05], N[Sin[y], $MachinePrecision], If[LessEqual[t$95$0, 0.002], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[y], $MachinePrecision], N[(z + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \sin y\right) + z \cdot \cos y\\
\mathbf{if}\;t\_0 \leq -4000000000:\\
\;\;\;\;z + x\\
\mathbf{elif}\;t\_0 \leq -0.05:\\
\;\;\;\;\sin y\\
\mathbf{elif}\;t\_0 \leq 0.002:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -4e9 or 1 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6479.2
Applied rewrites79.2%
if -4e9 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.050000000000000003 or 2e-3 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1Initial program 100.0%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
cos-sumN/A
cos-+PI/2-revN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f64N/A
Applied rewrites100.0%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-lft-identityN/A
*-lft-identityN/A
lift-neg.f64N/A
sub0-negN/A
mul0-lftN/A
lift-*.f64N/A
flip-+N/A
lift-*.f64N/A
mul0-lftN/A
+-lft-identity100.0
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
Applied rewrites97.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites97.9%
if -0.050000000000000003 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 2e-3Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.0
Applied rewrites99.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (+ x (sin y)) (* z (cos y))))) (if (or (<= t_0 -0.21) (not (<= t_0 0.2))) (+ z x) (+ (+ z y) x))))
double code(double x, double y, double z) {
double t_0 = (x + sin(y)) + (z * cos(y));
double tmp;
if ((t_0 <= -0.21) || !(t_0 <= 0.2)) {
tmp = z + x;
} else {
tmp = (z + y) + x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + sin(y)) + (z * cos(y))
if ((t_0 <= (-0.21d0)) .or. (.not. (t_0 <= 0.2d0))) then
tmp = z + x
else
tmp = (z + y) + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + Math.sin(y)) + (z * Math.cos(y));
double tmp;
if ((t_0 <= -0.21) || !(t_0 <= 0.2)) {
tmp = z + x;
} else {
tmp = (z + y) + x;
}
return tmp;
}
def code(x, y, z): t_0 = (x + math.sin(y)) + (z * math.cos(y)) tmp = 0 if (t_0 <= -0.21) or not (t_0 <= 0.2): tmp = z + x else: tmp = (z + y) + x return tmp
function code(x, y, z) t_0 = Float64(Float64(x + sin(y)) + Float64(z * cos(y))) tmp = 0.0 if ((t_0 <= -0.21) || !(t_0 <= 0.2)) tmp = Float64(z + x); else tmp = Float64(Float64(z + y) + x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + sin(y)) + (z * cos(y)); tmp = 0.0; if ((t_0 <= -0.21) || ~((t_0 <= 0.2))) tmp = z + x; else tmp = (z + y) + x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.21], N[Not[LessEqual[t$95$0, 0.2]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[(z + y), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \sin y\right) + z \cdot \cos y\\
\mathbf{if}\;t\_0 \leq -0.21 \lor \neg \left(t\_0 \leq 0.2\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;\left(z + y\right) + x\\
\end{array}
\end{array}
if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.209999999999999992 or 0.20000000000000001 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6469.7
Applied rewrites69.7%
if -0.209999999999999992 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 0.20000000000000001Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
Final simplification72.0%
(FPCore (x y z) :precision binary64 (fma (cos y) z (+ (sin y) x)))
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) + x));
}
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) + x)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, z, \sin y + x\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cos y) z)))
(if (<= z -2.4e+95)
t_0
(if (<= z -1e-188) (+ z x) (if (<= z 3.4e+40) (+ (sin y) x) t_0)))))
double code(double x, double y, double z) {
double t_0 = cos(y) * z;
double tmp;
if (z <= -2.4e+95) {
tmp = t_0;
} else if (z <= -1e-188) {
tmp = z + x;
} else if (z <= 3.4e+40) {
tmp = sin(y) + x;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = cos(y) * z
if (z <= (-2.4d+95)) then
tmp = t_0
else if (z <= (-1d-188)) then
tmp = z + x
else if (z <= 3.4d+40) then
tmp = sin(y) + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.cos(y) * z;
double tmp;
if (z <= -2.4e+95) {
tmp = t_0;
} else if (z <= -1e-188) {
tmp = z + x;
} else if (z <= 3.4e+40) {
tmp = Math.sin(y) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.cos(y) * z tmp = 0 if z <= -2.4e+95: tmp = t_0 elif z <= -1e-188: tmp = z + x elif z <= 3.4e+40: tmp = math.sin(y) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(cos(y) * z) tmp = 0.0 if (z <= -2.4e+95) tmp = t_0; elseif (z <= -1e-188) tmp = Float64(z + x); elseif (z <= 3.4e+40) tmp = Float64(sin(y) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = cos(y) * z; tmp = 0.0; if (z <= -2.4e+95) tmp = t_0; elseif (z <= -1e-188) tmp = z + x; elseif (z <= 3.4e+40) tmp = sin(y) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.4e+95], t$95$0, If[LessEqual[z, -1e-188], N[(z + x), $MachinePrecision], If[LessEqual[z, 3.4e+40], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot z\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+95}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-188}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+40}:\\
\;\;\;\;\sin y + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.4e95 or 3.39999999999999989e40 < z Initial program 99.8%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
cos-sumN/A
cos-+PI/2-revN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f64N/A
Applied rewrites99.8%
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6484.2
Applied rewrites84.2%
if -2.4e95 < z < -9.9999999999999995e-189Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6481.8
Applied rewrites81.8%
if -9.9999999999999995e-189 < z < 3.39999999999999989e40Initial program 100.0%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
cos-sumN/A
cos-+PI/2-revN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6496.1
Applied rewrites96.1%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (<= z -5.8e+88) (+ (+ y x) (* z (cos y))) (if (<= z 6e+142) (+ (+ x (sin y)) (* z 1.0)) (* (cos y) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.8e+88) {
tmp = (y + x) + (z * cos(y));
} else if (z <= 6e+142) {
tmp = (x + sin(y)) + (z * 1.0);
} else {
tmp = cos(y) * z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-5.8d+88)) then
tmp = (y + x) + (z * cos(y))
else if (z <= 6d+142) then
tmp = (x + sin(y)) + (z * 1.0d0)
else
tmp = cos(y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.8e+88) {
tmp = (y + x) + (z * Math.cos(y));
} else if (z <= 6e+142) {
tmp = (x + Math.sin(y)) + (z * 1.0);
} else {
tmp = Math.cos(y) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.8e+88: tmp = (y + x) + (z * math.cos(y)) elif z <= 6e+142: tmp = (x + math.sin(y)) + (z * 1.0) else: tmp = math.cos(y) * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.8e+88) tmp = Float64(Float64(y + x) + Float64(z * cos(y))); elseif (z <= 6e+142) tmp = Float64(Float64(x + sin(y)) + Float64(z * 1.0)); else tmp = Float64(cos(y) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.8e+88) tmp = (y + x) + (z * cos(y)); elseif (z <= 6e+142) tmp = (x + sin(y)) + (z * 1.0); else tmp = cos(y) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.8e+88], N[(N[(y + x), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6e+142], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+88}:\\
\;\;\;\;\left(y + x\right) + z \cdot \cos y\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+142}:\\
\;\;\;\;\left(x + \sin y\right) + z \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\cos y \cdot z\\
\end{array}
\end{array}
if z < -5.7999999999999999e88Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6488.3
Applied rewrites88.3%
if -5.7999999999999999e88 < z < 5.99999999999999949e142Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites93.2%
if 5.99999999999999949e142 < z Initial program 99.6%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
cos-sumN/A
cos-+PI/2-revN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f64N/A
Applied rewrites99.6%
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6499.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6498.3
Applied rewrites98.3%
Final simplification92.8%
(FPCore (x y z) :precision binary64 (if (<= z -5.4e-16) (+ (+ y x) (* z (cos y))) (if (<= z 3.4e+40) (+ (sin y) x) (* (cos y) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.4e-16) {
tmp = (y + x) + (z * cos(y));
} else if (z <= 3.4e+40) {
tmp = sin(y) + x;
} else {
tmp = cos(y) * z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-5.4d-16)) then
tmp = (y + x) + (z * cos(y))
else if (z <= 3.4d+40) then
tmp = sin(y) + x
else
tmp = cos(y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.4e-16) {
tmp = (y + x) + (z * Math.cos(y));
} else if (z <= 3.4e+40) {
tmp = Math.sin(y) + x;
} else {
tmp = Math.cos(y) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.4e-16: tmp = (y + x) + (z * math.cos(y)) elif z <= 3.4e+40: tmp = math.sin(y) + x else: tmp = math.cos(y) * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.4e-16) tmp = Float64(Float64(y + x) + Float64(z * cos(y))); elseif (z <= 3.4e+40) tmp = Float64(sin(y) + x); else tmp = Float64(cos(y) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.4e-16) tmp = (y + x) + (z * cos(y)); elseif (z <= 3.4e+40) tmp = sin(y) + x; else tmp = cos(y) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.4e-16], N[(N[(y + x), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.4e+40], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.4 \cdot 10^{-16}:\\
\;\;\;\;\left(y + x\right) + z \cdot \cos y\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+40}:\\
\;\;\;\;\sin y + x\\
\mathbf{else}:\\
\;\;\;\;\cos y \cdot z\\
\end{array}
\end{array}
if z < -5.39999999999999999e-16Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6480.1
Applied rewrites80.1%
if -5.39999999999999999e-16 < z < 3.39999999999999989e40Initial program 100.0%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
cos-sumN/A
cos-+PI/2-revN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6493.2
Applied rewrites93.2%
if 3.39999999999999989e40 < z Initial program 99.8%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
cos-sumN/A
cos-+PI/2-revN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f64N/A
Applied rewrites99.7%
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6487.4
Applied rewrites87.4%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.042) (not (<= y 0.2))) (+ (sin y) x) (fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.042) || !(y <= 0.2)) {
tmp = sin(y) + x;
} else {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -0.042) || !(y <= 0.2)) tmp = Float64(sin(y) + x); else tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.042], N[Not[LessEqual[y, 0.2]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.042 \lor \neg \left(y \leq 0.2\right):\\
\;\;\;\;\sin y + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
\end{array}
\end{array}
if y < -0.0420000000000000026 or 0.20000000000000001 < y Initial program 99.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
flip-+N/A
remove-double-negN/A
sin-neg-revN/A
cos-+PI/2-revN/A
cos-neg-revN/A
sin-+PI/2-revN/A
cos-sumN/A
cos-+PI/2-revN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f64N/A
Applied rewrites99.8%
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-sin.f6466.9
Applied rewrites66.9%
if -0.0420000000000000026 < y < 0.20000000000000001Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -13500000000.0) (not (<= y 3.6e-20))) (+ z x) (fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -13500000000.0) || !(y <= 3.6e-20)) {
tmp = z + x;
} else {
tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -13500000000.0) || !(y <= 3.6e-20)) tmp = Float64(z + x); else tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -13500000000.0], N[Not[LessEqual[y, 3.6e-20]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -13500000000 \lor \neg \left(y \leq 3.6 \cdot 10^{-20}\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
\end{array}
\end{array}
if y < -1.35e10 or 3.59999999999999974e-20 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6448.0
Applied rewrites48.0%
if -1.35e10 < y < 3.59999999999999974e-20Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.3
Applied rewrites99.3%
Final simplification72.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -25000000000.0) (not (<= y 3.6e-20))) (+ z x) (fma (fma (* y y) -0.5 1.0) z (+ x y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -25000000000.0) || !(y <= 3.6e-20)) {
tmp = z + x;
} else {
tmp = fma(fma((y * y), -0.5, 1.0), z, (x + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -25000000000.0) || !(y <= 3.6e-20)) tmp = Float64(z + x); else tmp = fma(fma(Float64(y * y), -0.5, 1.0), z, Float64(x + y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -25000000000.0], N[Not[LessEqual[y, 3.6e-20]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[(N[(y * y), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -25000000000 \lor \neg \left(y \leq 3.6 \cdot 10^{-20}\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, -0.5, 1\right), z, x + y\right)\\
\end{array}
\end{array}
if y < -2.5e10 or 3.59999999999999974e-20 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6448.0
Applied rewrites48.0%
if -2.5e10 < y < 3.59999999999999974e-20Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.8
Applied rewrites98.8%
Taylor expanded in y around -inf
Applied rewrites98.8%
Taylor expanded in x around 0
Applied rewrites98.8%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.7e-5) (not (<= x 1.75e-64))) (+ x y) (+ y z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e-5) || !(x <= 1.75e-64)) {
tmp = x + y;
} else {
tmp = y + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.7d-5)) .or. (.not. (x <= 1.75d-64))) then
tmp = x + y
else
tmp = y + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e-5) || !(x <= 1.75e-64)) {
tmp = x + y;
} else {
tmp = y + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.7e-5) or not (x <= 1.75e-64): tmp = x + y else: tmp = y + z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.7e-5) || !(x <= 1.75e-64)) tmp = Float64(x + y); else tmp = Float64(y + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.7e-5) || ~((x <= 1.75e-64))) tmp = x + y; else tmp = y + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.7e-5], N[Not[LessEqual[x, 1.75e-64]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(y + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-5} \lor \neg \left(x \leq 1.75 \cdot 10^{-64}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;y + z\\
\end{array}
\end{array}
if x < -1.7e-5 or 1.7500000000000002e-64 < x Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6472.1
Applied rewrites72.1%
Taylor expanded in x around 0
Applied rewrites14.1%
Taylor expanded in z around 0
Applied rewrites60.4%
if -1.7e-5 < x < 1.7500000000000002e-64Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6451.0
Applied rewrites51.0%
Taylor expanded in x around 0
Applied rewrites45.9%
Final simplification54.0%
(FPCore (x y z) :precision binary64 (+ z x))
double code(double x, double y, double z) {
return z + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + x
end function
public static double code(double x, double y, double z) {
return z + x;
}
def code(x, y, z): return z + x
function code(x, y, z) return Float64(z + x) end
function tmp = code(x, y, z) tmp = z + x; end
code[x_, y_, z_] := N[(z + x), $MachinePrecision]
\begin{array}{l}
\\
z + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6468.3
Applied rewrites68.3%
(FPCore (x y z) :precision binary64 (+ x y))
double code(double x, double y, double z) {
return x + y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + y
end function
public static double code(double x, double y, double z) {
return x + y;
}
def code(x, y, z): return x + y
function code(x, y, z) return Float64(x + y) end
function tmp = code(x, y, z) tmp = x + y; end
code[x_, y_, z_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in x around 0
Applied rewrites28.0%
Taylor expanded in z around 0
Applied rewrites40.8%
herbie shell --seed 2024329
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))