
(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));
}
real(8) function code(x, y, z)
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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 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));
}
real(8) function code(x, y, z)
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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(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));
}
real(8) function code(x, y, z)
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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Initial program 99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (sin y)))
(t_1 (- (+ x (cos y)) t_0))
(t_2 (- (+ x 1.0) t_0)))
(if (<= t_1 -1000000.0) t_2 (if (<= t_1 0.996) (- (cos y) t_0) t_2))))
double code(double x, double y, double z) {
double t_0 = z * sin(y);
double t_1 = (x + cos(y)) - t_0;
double t_2 = (x + 1.0) - t_0;
double tmp;
if (t_1 <= -1000000.0) {
tmp = t_2;
} else if (t_1 <= 0.996) {
tmp = cos(y) - t_0;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = z * sin(y)
t_1 = (x + cos(y)) - t_0
t_2 = (x + 1.0d0) - t_0
if (t_1 <= (-1000000.0d0)) then
tmp = t_2
else if (t_1 <= 0.996d0) then
tmp = cos(y) - t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.sin(y);
double t_1 = (x + Math.cos(y)) - t_0;
double t_2 = (x + 1.0) - t_0;
double tmp;
if (t_1 <= -1000000.0) {
tmp = t_2;
} else if (t_1 <= 0.996) {
tmp = Math.cos(y) - t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.sin(y) t_1 = (x + math.cos(y)) - t_0 t_2 = (x + 1.0) - t_0 tmp = 0 if t_1 <= -1000000.0: tmp = t_2 elif t_1 <= 0.996: tmp = math.cos(y) - t_0 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(z * sin(y)) t_1 = Float64(Float64(x + cos(y)) - t_0) t_2 = Float64(Float64(x + 1.0) - t_0) tmp = 0.0 if (t_1 <= -1000000.0) tmp = t_2; elseif (t_1 <= 0.996) tmp = Float64(cos(y) - t_0); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * sin(y); t_1 = (x + cos(y)) - t_0; t_2 = (x + 1.0) - t_0; tmp = 0.0; if (t_1 <= -1000000.0) tmp = t_2; elseif (t_1 <= 0.996) tmp = cos(y) - t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -1000000.0], t$95$2, If[LessEqual[t$95$1, 0.996], N[(N[Cos[y], $MachinePrecision] - t$95$0), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \sin y\\
t_1 := \left(x + \cos y\right) - t\_0\\
t_2 := \left(x + 1\right) - t\_0\\
\mathbf{if}\;t\_1 \leq -1000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.996:\\
\;\;\;\;\cos y - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e6 or 0.996 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.4
Simplified99.4%
if -1e6 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.996Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6499.8
Simplified99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (+ x (cos y)) (* z (sin y))))) (if (<= t_0 -1000000.0) (+ x 1.0) (if (<= t_0 0.996) (cos y) (+ x 1.0)))))
double code(double x, double y, double z) {
double t_0 = (x + cos(y)) - (z * sin(y));
double tmp;
if (t_0 <= -1000000.0) {
tmp = x + 1.0;
} else if (t_0 <= 0.996) {
tmp = cos(y);
} else {
tmp = x + 1.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 = (x + cos(y)) - (z * sin(y))
if (t_0 <= (-1000000.0d0)) then
tmp = x + 1.0d0
else if (t_0 <= 0.996d0) then
tmp = cos(y)
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + Math.cos(y)) - (z * Math.sin(y));
double tmp;
if (t_0 <= -1000000.0) {
tmp = x + 1.0;
} else if (t_0 <= 0.996) {
tmp = Math.cos(y);
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + math.cos(y)) - (z * math.sin(y)) tmp = 0 if t_0 <= -1000000.0: tmp = x + 1.0 elif t_0 <= 0.996: tmp = math.cos(y) else: tmp = x + 1.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + cos(y)) - Float64(z * sin(y))) tmp = 0.0 if (t_0 <= -1000000.0) tmp = Float64(x + 1.0); elseif (t_0 <= 0.996) tmp = cos(y); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + cos(y)) - (z * sin(y)); tmp = 0.0; if (t_0 <= -1000000.0) tmp = x + 1.0; elseif (t_0 <= 0.996) tmp = cos(y); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1000000.0], N[(x + 1.0), $MachinePrecision], If[LessEqual[t$95$0, 0.996], N[Cos[y], $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \cos y\right) - z \cdot \sin y\\
\mathbf{if}\;t\_0 \leq -1000000:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;t\_0 \leq 0.996:\\
\;\;\;\;\cos y\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e6 or 0.996 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6469.8
Simplified69.8%
if -1e6 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.996Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6492.4
Simplified92.4%
Taylor expanded in x around 0
lower-cos.f6492.3
Simplified92.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (+ x (cos y)) (* z (sin y))))) (if (<= t_0 -0.1) x (if (<= t_0 2.0) 1.0 x))))
double code(double x, double y, double z) {
double t_0 = (x + cos(y)) - (z * sin(y));
double tmp;
if (t_0 <= -0.1) {
tmp = x;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = 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 + cos(y)) - (z * sin(y))
if (t_0 <= (-0.1d0)) then
tmp = x
else if (t_0 <= 2.0d0) then
tmp = 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + Math.cos(y)) - (z * Math.sin(y));
double tmp;
if (t_0 <= -0.1) {
tmp = x;
} else if (t_0 <= 2.0) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = (x + math.cos(y)) - (z * math.sin(y)) tmp = 0 if t_0 <= -0.1: tmp = x elif t_0 <= 2.0: tmp = 1.0 else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(Float64(x + cos(y)) - Float64(z * sin(y))) tmp = 0.0 if (t_0 <= -0.1) tmp = x; elseif (t_0 <= 2.0) tmp = 1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + cos(y)) - (z * sin(y)); tmp = 0.0; if (t_0 <= -0.1) tmp = x; elseif (t_0 <= 2.0) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.1], x, If[LessEqual[t$95$0, 2.0], 1.0, x]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \cos y\right) - z \cdot \sin y\\
\mathbf{if}\;t\_0 \leq -0.1:\\
\;\;\;\;x\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -0.10000000000000001 or 2 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
lift-cos.f64N/A
lift-+.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.6
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
Applied egg-rr99.6%
Taylor expanded in x around inf
lower-/.f6453.1
Simplified53.1%
remove-double-div53.2
Applied egg-rr53.2%
if -0.10000000000000001 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 2Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6476.8
Simplified76.8%
Taylor expanded in x around 0
Simplified76.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (+ x 1.0) (* z (sin y))))) (if (<= z -0.85) t_0 (if (<= z 0.88) (+ x (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (x + 1.0) - (z * sin(y));
double tmp;
if (z <= -0.85) {
tmp = t_0;
} else if (z <= 0.88) {
tmp = x + cos(y);
} 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 = (x + 1.0d0) - (z * sin(y))
if (z <= (-0.85d0)) then
tmp = t_0
else if (z <= 0.88d0) then
tmp = x + cos(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + 1.0) - (z * Math.sin(y));
double tmp;
if (z <= -0.85) {
tmp = t_0;
} else if (z <= 0.88) {
tmp = x + Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + 1.0) - (z * math.sin(y)) tmp = 0 if z <= -0.85: tmp = t_0 elif z <= 0.88: tmp = x + math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + 1.0) - Float64(z * sin(y))) tmp = 0.0 if (z <= -0.85) tmp = t_0; elseif (z <= 0.88) tmp = Float64(x + cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + 1.0) - (z * sin(y)); tmp = 0.0; if (z <= -0.85) tmp = t_0; elseif (z <= 0.88) tmp = x + cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.85], t$95$0, If[LessEqual[z, 0.88], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + 1\right) - z \cdot \sin y\\
\mathbf{if}\;z \leq -0.85:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.88:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.849999999999999978 or 0.880000000000000004 < z Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.3
Simplified99.3%
if -0.849999999999999978 < z < 0.880000000000000004Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6498.7
Simplified98.7%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.1e+204) (* (sin y) (- z)) (if (<= z 1.4e+128) (+ x (cos y)) (- 1.0 (* z (sin y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+204) {
tmp = sin(y) * -z;
} else if (z <= 1.4e+128) {
tmp = x + cos(y);
} else {
tmp = 1.0 - (z * sin(y));
}
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 <= (-1.1d+204)) then
tmp = sin(y) * -z
else if (z <= 1.4d+128) then
tmp = x + cos(y)
else
tmp = 1.0d0 - (z * sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+204) {
tmp = Math.sin(y) * -z;
} else if (z <= 1.4e+128) {
tmp = x + Math.cos(y);
} else {
tmp = 1.0 - (z * Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1e+204: tmp = math.sin(y) * -z elif z <= 1.4e+128: tmp = x + math.cos(y) else: tmp = 1.0 - (z * math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1e+204) tmp = Float64(sin(y) * Float64(-z)); elseif (z <= 1.4e+128) tmp = Float64(x + cos(y)); else tmp = Float64(1.0 - Float64(z * sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.1e+204) tmp = sin(y) * -z; elseif (z <= 1.4e+128) tmp = x + cos(y); else tmp = 1.0 - (z * sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1e+204], N[(N[Sin[y], $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[z, 1.4e+128], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+204}:\\
\;\;\;\;\sin y \cdot \left(-z\right)\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+128}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;1 - z \cdot \sin y\\
\end{array}
\end{array}
if z < -1.10000000000000006e204Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-neg.f6475.7
Simplified75.7%
if -1.10000000000000006e204 < z < 1.39999999999999991e128Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6487.4
Simplified87.4%
if 1.39999999999999991e128 < z Initial program 99.6%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.6
Simplified99.6%
Taylor expanded in x around 0
Simplified81.4%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (sin y) (- z)))) (if (<= z -1.1e+204) t_0 (if (<= z 8e+217) (+ x (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = sin(y) * -z;
double tmp;
if (z <= -1.1e+204) {
tmp = t_0;
} else if (z <= 8e+217) {
tmp = x + cos(y);
} 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 = sin(y) * -z
if (z <= (-1.1d+204)) then
tmp = t_0
else if (z <= 8d+217) then
tmp = x + cos(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) * -z;
double tmp;
if (z <= -1.1e+204) {
tmp = t_0;
} else if (z <= 8e+217) {
tmp = x + Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) * -z tmp = 0 if z <= -1.1e+204: tmp = t_0 elif z <= 8e+217: tmp = x + math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(sin(y) * Float64(-z)) tmp = 0.0 if (z <= -1.1e+204) tmp = t_0; elseif (z <= 8e+217) tmp = Float64(x + cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) * -z; tmp = 0.0; if (z <= -1.1e+204) tmp = t_0; elseif (z <= 8e+217) tmp = x + cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * (-z)), $MachinePrecision]}, If[LessEqual[z, -1.1e+204], t$95$0, If[LessEqual[z, 8e+217], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+204}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+217}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.10000000000000006e204 or 7.99999999999999968e217 < z Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-neg.f6483.3
Simplified83.3%
if -1.10000000000000006e204 < z < 7.99999999999999968e217Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6484.7
Simplified84.7%
Final simplification84.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (cos y))))
(if (<= y -0.88)
t_0
(if (<= y 0.18)
(fma
y
(-
(*
(* y y)
(* z (fma (* y y) -0.008333333333333333 0.16666666666666666)))
z)
(+ x 1.0))
t_0))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double tmp;
if (y <= -0.88) {
tmp = t_0;
} else if (y <= 0.18) {
tmp = fma(y, (((y * y) * (z * fma((y * y), -0.008333333333333333, 0.16666666666666666))) - z), (x + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + cos(y)) tmp = 0.0 if (y <= -0.88) tmp = t_0; elseif (y <= 0.18) tmp = fma(y, Float64(Float64(Float64(y * y) * Float64(z * fma(Float64(y * y), -0.008333333333333333, 0.16666666666666666))) - z), Float64(x + 1.0)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.88], t$95$0, If[LessEqual[y, 0.18], N[(y * N[(N[(N[(y * y), $MachinePrecision] * N[(z * N[(N[(y * y), $MachinePrecision] * -0.008333333333333333 + 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
\mathbf{if}\;y \leq -0.88:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.18:\\
\;\;\;\;\mathsf{fma}\left(y, \left(y \cdot y\right) \cdot \left(z \cdot \mathsf{fma}\left(y \cdot y, -0.008333333333333333, 0.16666666666666666\right)\right) - z, x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.880000000000000004 or 0.17999999999999999 < y Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6463.4
Simplified63.4%
if -0.880000000000000004 < y < 0.17999999999999999Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64100.0
Simplified100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified100.0%
Final simplification80.0%
(FPCore (x y z)
:precision binary64
(if (<= y -35.0)
(+ x 1.0)
(if (<= y 3.1)
(fma
y
(-
(*
(* y y)
(* z (fma (* y y) -0.008333333333333333 0.16666666666666666)))
z)
(+ x 1.0))
(+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -35.0) {
tmp = x + 1.0;
} else if (y <= 3.1) {
tmp = fma(y, (((y * y) * (z * fma((y * y), -0.008333333333333333, 0.16666666666666666))) - z), (x + 1.0));
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -35.0) tmp = Float64(x + 1.0); elseif (y <= 3.1) tmp = fma(y, Float64(Float64(Float64(y * y) * Float64(z * fma(Float64(y * y), -0.008333333333333333, 0.16666666666666666))) - z), Float64(x + 1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -35.0], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 3.1], N[(y * N[(N[(N[(y * y), $MachinePrecision] * N[(z * N[(N[(y * y), $MachinePrecision] * -0.008333333333333333 + 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -35:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 3.1:\\
\;\;\;\;\mathsf{fma}\left(y, \left(y \cdot y\right) \cdot \left(z \cdot \mathsf{fma}\left(y \cdot y, -0.008333333333333333, 0.16666666666666666\right)\right) - z, x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -35 or 3.10000000000000009 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6437.7
Simplified37.7%
if -35 < y < 3.10000000000000009Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64100.0
Simplified100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -360000.0)
(+ x 1.0)
(if (<= y 2.4)
(fma y (* z (fma 0.16666666666666666 (* y y) -1.0)) (+ x 1.0))
(+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -360000.0) {
tmp = x + 1.0;
} else if (y <= 2.4) {
tmp = fma(y, (z * fma(0.16666666666666666, (y * y), -1.0)), (x + 1.0));
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -360000.0) tmp = Float64(x + 1.0); elseif (y <= 2.4) tmp = fma(y, Float64(z * fma(0.16666666666666666, Float64(y * y), -1.0)), Float64(x + 1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -360000.0], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 2.4], N[(y * N[(z * N[(0.16666666666666666 * N[(y * y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -360000:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 2.4:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \mathsf{fma}\left(0.16666666666666666, y \cdot y, -1\right), x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -3.6e5 or 2.39999999999999991 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6437.7
Simplified37.7%
if -3.6e5 < y < 2.39999999999999991Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64100.0
Simplified100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.9
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (<= y -35.0) (+ x 1.0) (if (<= y 1.2e+57) (- x (fma y z -1.0)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -35.0) {
tmp = x + 1.0;
} else if (y <= 1.2e+57) {
tmp = x - fma(y, z, -1.0);
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -35.0) tmp = Float64(x + 1.0); elseif (y <= 1.2e+57) tmp = Float64(x - fma(y, z, -1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -35.0], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 1.2e+57], N[(x - N[(y * z + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -35:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+57}:\\
\;\;\;\;x - \mathsf{fma}\left(y, z, -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -35 or 1.20000000000000002e57 < y Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6436.2
Simplified36.2%
if -35 < y < 1.20000000000000002e57Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
lower--.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6494.8
Simplified94.8%
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + 1.0d0
end function
public static double code(double x, double y, double z) {
return x + 1.0;
}
def code(x, y, z): return x + 1.0
function code(x, y, z) return Float64(x + 1.0) end
function tmp = code(x, y, z) tmp = x + 1.0; end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6459.8
Simplified59.8%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6459.8
Simplified59.8%
Taylor expanded in x around 0
Simplified21.3%
herbie shell --seed 2024212
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))