
(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 17 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 (+ x (cos y)))
(t_1 (* z (sin y)))
(t_2 (- t_0 t_1))
(t_3 (- x t_1)))
(if (<= t_2 -200000.0) t_3 (if (<= t_2 2000000.0) t_0 t_3))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double t_1 = z * sin(y);
double t_2 = t_0 - t_1;
double t_3 = x - t_1;
double tmp;
if (t_2 <= -200000.0) {
tmp = t_3;
} else if (t_2 <= 2000000.0) {
tmp = t_0;
} else {
tmp = t_3;
}
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) :: t_3
real(8) :: tmp
t_0 = x + cos(y)
t_1 = z * sin(y)
t_2 = t_0 - t_1
t_3 = x - t_1
if (t_2 <= (-200000.0d0)) then
tmp = t_3
else if (t_2 <= 2000000.0d0) then
tmp = t_0
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + Math.cos(y);
double t_1 = z * Math.sin(y);
double t_2 = t_0 - t_1;
double t_3 = x - t_1;
double tmp;
if (t_2 <= -200000.0) {
tmp = t_3;
} else if (t_2 <= 2000000.0) {
tmp = t_0;
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.cos(y) t_1 = z * math.sin(y) t_2 = t_0 - t_1 t_3 = x - t_1 tmp = 0 if t_2 <= -200000.0: tmp = t_3 elif t_2 <= 2000000.0: tmp = t_0 else: tmp = t_3 return tmp
function code(x, y, z) t_0 = Float64(x + cos(y)) t_1 = Float64(z * sin(y)) t_2 = Float64(t_0 - t_1) t_3 = Float64(x - t_1) tmp = 0.0 if (t_2 <= -200000.0) tmp = t_3; elseif (t_2 <= 2000000.0) tmp = t_0; else tmp = t_3; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + cos(y); t_1 = z * sin(y); t_2 = t_0 - t_1; t_3 = x - t_1; tmp = 0.0; if (t_2 <= -200000.0) tmp = t_3; elseif (t_2 <= 2000000.0) tmp = t_0; else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(x - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -200000.0], t$95$3, If[LessEqual[t$95$2, 2000000.0], t$95$0, t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
t_1 := z \cdot \sin y\\
t_2 := t\_0 - t\_1\\
t_3 := x - t\_1\\
\mathbf{if}\;t\_2 \leq -200000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 2000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -2e5 or 2e6 < (-.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.6
Applied rewrites99.6%
Taylor expanded in x around 0
sub-negN/A
associate-+r+N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
associate-+l-N/A
lower--.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-sin.f6499.1
Applied rewrites99.1%
if -2e5 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 2e6Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6497.5
Applied rewrites97.5%
Final simplification98.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ x (cos y)) (* z (sin y))))
(t_1
(fma (/ y (+ -1.0 (/ (* y (fma (/ y z) -0.25 0.5)) z))) z (+ x 1.0))))
(if (<= t_0 -50.0) t_1 (if (<= t_0 0.99999) (cos y) t_1))))
double code(double x, double y, double z) {
double t_0 = (x + cos(y)) - (z * sin(y));
double t_1 = fma((y / (-1.0 + ((y * fma((y / z), -0.25, 0.5)) / z))), z, (x + 1.0));
double tmp;
if (t_0 <= -50.0) {
tmp = t_1;
} else if (t_0 <= 0.99999) {
tmp = cos(y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + cos(y)) - Float64(z * sin(y))) t_1 = fma(Float64(y / Float64(-1.0 + Float64(Float64(y * fma(Float64(y / z), -0.25, 0.5)) / z))), z, Float64(x + 1.0)) tmp = 0.0 if (t_0 <= -50.0) tmp = t_1; elseif (t_0 <= 0.99999) tmp = cos(y); else tmp = t_1; end return 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]}, Block[{t$95$1 = N[(N[(y / N[(-1.0 + N[(N[(y * N[(N[(y / z), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50.0], t$95$1, If[LessEqual[t$95$0, 0.99999], N[Cos[y], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + \cos y\right) - z \cdot \sin y\\
t_1 := \mathsf{fma}\left(\frac{y}{-1 + \frac{y \cdot \mathsf{fma}\left(\frac{y}{z}, -0.25, 0.5\right)}{z}}, z, x + 1\right)\\
\mathbf{if}\;t\_0 \leq -50:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.99999:\\
\;\;\;\;\cos y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -50 or 0.999990000000000046 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6461.8
Applied rewrites61.8%
lift-*.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6461.8
Applied rewrites61.8%
Taylor expanded in y around 0
Applied rewrites72.4%
Applied rewrites72.4%
if -50 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.999990000000000046Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6496.2
Applied rewrites96.2%
Taylor expanded in x around 0
lower-cos.f6493.6
Applied rewrites93.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- x (fma z (sin y) -1.0)))) (if (<= x -8e-12) t_0 (if (<= x 4e-13) (- (cos y) (* z (sin y))) t_0))))
double code(double x, double y, double z) {
double t_0 = x - fma(z, sin(y), -1.0);
double tmp;
if (x <= -8e-12) {
tmp = t_0;
} else if (x <= 4e-13) {
tmp = cos(y) - (z * sin(y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x - fma(z, sin(y), -1.0)) tmp = 0.0 if (x <= -8e-12) tmp = t_0; elseif (x <= 4e-13) tmp = Float64(cos(y) - Float64(z * sin(y))); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(z * N[Sin[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8e-12], t$95$0, If[LessEqual[x, 4e-13], N[(N[Cos[y], $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \mathsf{fma}\left(z, \sin y, -1\right)\\
\mathbf{if}\;x \leq -8 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-13}:\\
\;\;\;\;\cos y - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.99999999999999984e-12 or 4.0000000000000001e-13 < x Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.2
Applied rewrites99.2%
Taylor expanded in x around 0
sub-negN/A
associate-+r+N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
associate-+l-N/A
lower--.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
lower-sin.f6499.2
Applied rewrites99.2%
if -7.99999999999999984e-12 < x < 4.0000000000000001e-13Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- x (fma z (sin y) -1.0)))) (if (<= z -1.6e+35) t_0 (if (<= z 0.000465) (+ x (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = x - fma(z, sin(y), -1.0);
double tmp;
if (z <= -1.6e+35) {
tmp = t_0;
} else if (z <= 0.000465) {
tmp = x + cos(y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x - fma(z, sin(y), -1.0)) tmp = 0.0 if (z <= -1.6e+35) tmp = t_0; elseif (z <= 0.000465) tmp = Float64(x + cos(y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(z * N[Sin[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.6e+35], t$95$0, If[LessEqual[z, 0.000465], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \mathsf{fma}\left(z, \sin y, -1\right)\\
\mathbf{if}\;z \leq -1.6 \cdot 10^{+35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.000465:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.59999999999999991e35 or 4.6500000000000003e-4 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
sub-negN/A
associate-+r+N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
associate-+l-N/A
lower--.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
if -1.59999999999999991e35 < z < 4.6500000000000003e-4Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6499.0
Applied rewrites99.0%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (sin y) (- z)))) (if (<= z -1.1e+159) t_0 (if (<= z 3.8e+110) (+ 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+159) {
tmp = t_0;
} else if (z <= 3.8e+110) {
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+159)) then
tmp = t_0
else if (z <= 3.8d+110) 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+159) {
tmp = t_0;
} else if (z <= 3.8e+110) {
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+159: tmp = t_0 elif z <= 3.8e+110: 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+159) tmp = t_0; elseif (z <= 3.8e+110) 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+159) tmp = t_0; elseif (z <= 3.8e+110) 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+159], t$95$0, If[LessEqual[z, 3.8e+110], 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^{+159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+110}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.1e159 or 3.79999999999999989e110 < z Initial program 99.9%
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.f6470.4
Applied rewrites70.4%
if -1.1e159 < z < 3.79999999999999989e110Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6488.4
Applied rewrites88.4%
Final simplification81.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (cos y))))
(if (<= y -3200000000.0)
t_0
(if (<= y 2600000000.0)
(-
x
(fma
y
(fma
(* y y)
(* z (fma (* y y) 0.008333333333333333 -0.16666666666666666))
z)
-1.0))
t_0))))
double code(double x, double y, double z) {
double t_0 = x + cos(y);
double tmp;
if (y <= -3200000000.0) {
tmp = t_0;
} else if (y <= 2600000000.0) {
tmp = x - fma(y, fma((y * y), (z * fma((y * y), 0.008333333333333333, -0.16666666666666666)), z), -1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + cos(y)) tmp = 0.0 if (y <= -3200000000.0) tmp = t_0; elseif (y <= 2600000000.0) tmp = Float64(x - fma(y, fma(Float64(y * y), Float64(z * fma(Float64(y * y), 0.008333333333333333, -0.16666666666666666)), z), -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, -3200000000.0], t$95$0, If[LessEqual[y, 2600000000.0], N[(x - N[(y * N[(N[(y * y), $MachinePrecision] * N[(z * N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \cos y\\
\mathbf{if}\;y \leq -3200000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2600000000:\\
\;\;\;\;x - \mathsf{fma}\left(y, \mathsf{fma}\left(y \cdot y, z \cdot \mathsf{fma}\left(y \cdot y, 0.008333333333333333, -0.16666666666666666\right), z\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.2e9 or 2.6e9 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6452.7
Applied rewrites52.7%
if -3.2e9 < y < 2.6e9Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
associate--l+N/A
div-subN/A
distribute-rgt-inN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
unsub-negN/A
lower--.f64N/A
associate-*r*N/A
Applied rewrites97.7%
Taylor expanded in y around 0
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.6
Applied rewrites98.6%
Final simplification76.4%
(FPCore (x y z) :precision binary64 (fma (/ y (+ -1.0 (/ (* y (fma (/ y z) -0.25 0.5)) z))) z (+ x 1.0)))
double code(double x, double y, double z) {
return fma((y / (-1.0 + ((y * fma((y / z), -0.25, 0.5)) / z))), z, (x + 1.0));
}
function code(x, y, z) return fma(Float64(y / Float64(-1.0 + Float64(Float64(y * fma(Float64(y / z), -0.25, 0.5)) / z))), z, Float64(x + 1.0)) end
code[x_, y_, z_] := N[(N[(y / N[(-1.0 + N[(N[(y * N[(N[(y / z), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{-1 + \frac{y \cdot \mathsf{fma}\left(\frac{y}{z}, -0.25, 0.5\right)}{z}}, z, x + 1\right)
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6455.1
Applied rewrites55.1%
lift-*.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6455.1
Applied rewrites55.1%
Taylor expanded in y around 0
Applied rewrites65.5%
Applied rewrites65.5%
(FPCore (x y z)
:precision binary64
(if (<= y -1.35e+17)
(+ x 1.0)
(if (<= y 15500000000.0)
(-
x
(fma
y
(fma
(* y y)
(* z (fma (* y y) 0.008333333333333333 -0.16666666666666666))
z)
-1.0))
(+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+17) {
tmp = x + 1.0;
} else if (y <= 15500000000.0) {
tmp = x - fma(y, fma((y * y), (z * fma((y * y), 0.008333333333333333, -0.16666666666666666)), z), -1.0);
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.35e+17) tmp = Float64(x + 1.0); elseif (y <= 15500000000.0) tmp = Float64(x - fma(y, fma(Float64(y * y), Float64(z * fma(Float64(y * y), 0.008333333333333333, -0.16666666666666666)), z), -1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.35e+17], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 15500000000.0], N[(x - N[(y * N[(N[(y * y), $MachinePrecision] * N[(z * N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+17}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 15500000000:\\
\;\;\;\;x - \mathsf{fma}\left(y, \mathsf{fma}\left(y \cdot y, z \cdot \mathsf{fma}\left(y \cdot y, 0.008333333333333333, -0.16666666666666666\right), z\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -1.35e17 or 1.55e10 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6433.0
Applied rewrites33.0%
if -1.35e17 < y < 1.55e10Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6499.3
Applied rewrites99.3%
Taylor expanded in x around inf
associate--l+N/A
div-subN/A
distribute-rgt-inN/A
*-lft-identityN/A
*-lft-identityN/A
metadata-evalN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
unsub-negN/A
lower--.f64N/A
associate-*r*N/A
Applied rewrites97.0%
Taylor expanded in y around 0
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.9
Applied rewrites97.9%
(FPCore (x y z)
:precision binary64
(if (<= y -2.05e+17)
(+ x 1.0)
(if (<= y 7.5e+28)
(+ 1.0 (fma y (- (* y (fma y (* z 0.16666666666666666) -0.5)) z) x))
(+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e+17) {
tmp = x + 1.0;
} else if (y <= 7.5e+28) {
tmp = 1.0 + fma(y, ((y * fma(y, (z * 0.16666666666666666), -0.5)) - z), x);
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2.05e+17) tmp = Float64(x + 1.0); elseif (y <= 7.5e+28) tmp = Float64(1.0 + fma(y, Float64(Float64(y * fma(y, Float64(z * 0.16666666666666666), -0.5)) - z), x)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2.05e+17], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 7.5e+28], N[(1.0 + N[(y * N[(N[(y * N[(y * N[(z * 0.16666666666666666), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{+17}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+28}:\\
\;\;\;\;1 + \mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y, z \cdot 0.16666666666666666, -0.5\right) - z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -2.05e17 or 7.4999999999999998e28 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6432.7
Applied rewrites32.7%
if -2.05e17 < y < 7.4999999999999998e28Initial program 100.0%
Taylor expanded in y around 0
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
(FPCore (x y z)
:precision binary64
(if (<= y -6.4)
(+ x 1.0)
(if (<= y 35000.0)
(+ x (fma y (* z (fma 0.16666666666666666 (* y y) -1.0)) 1.0))
(+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.4) {
tmp = x + 1.0;
} else if (y <= 35000.0) {
tmp = x + fma(y, (z * fma(0.16666666666666666, (y * y), -1.0)), 1.0);
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6.4) tmp = Float64(x + 1.0); elseif (y <= 35000.0) tmp = Float64(x + fma(y, Float64(z * fma(0.16666666666666666, Float64(y * y), -1.0)), 1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6.4], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 35000.0], N[(x + N[(y * N[(z * N[(0.16666666666666666 * N[(y * y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 35000:\\
\;\;\;\;x + \mathsf{fma}\left(y, z \cdot \mathsf{fma}\left(0.16666666666666666, y \cdot y, -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -6.4000000000000004 or 35000 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6433.3
Applied rewrites33.3%
if -6.4000000000000004 < y < 35000Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
sub-negN/A
associate-+r+N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
associate-+l-N/A
lower--.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
lower-sin.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/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-*.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.6e+17) (+ x 1.0) (if (<= y 5.8e+118) (fma y (- (* y -0.5) z) (+ x 1.0)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.6e+17) {
tmp = x + 1.0;
} else if (y <= 5.8e+118) {
tmp = fma(y, ((y * -0.5) - z), (x + 1.0));
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.6e+17) tmp = Float64(x + 1.0); elseif (y <= 5.8e+118) tmp = fma(y, Float64(Float64(y * -0.5) - z), Float64(x + 1.0)); else tmp = Float64(x + 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.6e+17], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 5.8e+118], N[(y * N[(N[(y * -0.5), $MachinePrecision] - z), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{+17}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+118}:\\
\;\;\;\;\mathsf{fma}\left(y, y \cdot -0.5 - z, x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -1.6e17 or 5.80000000000000032e118 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6434.7
Applied rewrites34.7%
if -1.6e17 < y < 5.80000000000000032e118Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6488.5
Applied rewrites88.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.9e+78) (+ x 1.0) (if (<= y 5.8e+118) (- x (fma y z -1.0)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e+78) {
tmp = x + 1.0;
} else if (y <= 5.8e+118) {
tmp = x - fma(y, z, -1.0);
} else {
tmp = x + 1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2.9e+78) tmp = Float64(x + 1.0); elseif (y <= 5.8e+118) 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, -2.9e+78], N[(x + 1.0), $MachinePrecision], If[LessEqual[y, 5.8e+118], N[(x - N[(y * z + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{+78}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+118}:\\
\;\;\;\;x - \mathsf{fma}\left(y, z, -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if y < -2.90000000000000017e78 or 5.80000000000000032e118 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6438.0
Applied rewrites38.0%
if -2.90000000000000017e78 < y < 5.80000000000000032e118Initial 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.f6481.2
Applied rewrites81.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.12e-11) (+ x 1.0) (if (<= x 1.1e+22) (- 1.0 (* y z)) (+ x 1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.12e-11) {
tmp = x + 1.0;
} else if (x <= 1.1e+22) {
tmp = 1.0 - (y * z);
} 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) :: tmp
if (x <= (-1.12d-11)) then
tmp = x + 1.0d0
else if (x <= 1.1d+22) then
tmp = 1.0d0 - (y * z)
else
tmp = x + 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.12e-11) {
tmp = x + 1.0;
} else if (x <= 1.1e+22) {
tmp = 1.0 - (y * z);
} else {
tmp = x + 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.12e-11: tmp = x + 1.0 elif x <= 1.1e+22: tmp = 1.0 - (y * z) else: tmp = x + 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.12e-11) tmp = Float64(x + 1.0); elseif (x <= 1.1e+22) tmp = Float64(1.0 - Float64(y * z)); else tmp = Float64(x + 1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.12e-11) tmp = x + 1.0; elseif (x <= 1.1e+22) tmp = 1.0 - (y * z); else tmp = x + 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.12e-11], N[(x + 1.0), $MachinePrecision], If[LessEqual[x, 1.1e+22], N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{-11}:\\
\;\;\;\;x + 1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+22}:\\
\;\;\;\;1 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if x < -1.1200000000000001e-11 or 1.1e22 < x Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6477.9
Applied rewrites77.9%
if -1.1200000000000001e-11 < x < 1.1e22Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6498.1
Applied rewrites98.1%
Taylor expanded in y around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6448.8
Applied rewrites48.8%
Final simplification62.6%
(FPCore (x y z) :precision binary64 (if (<= z 2.5e+261) (+ x 1.0) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.5e+261) {
tmp = x + 1.0;
} 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 (z <= 2.5d+261) then
tmp = x + 1.0d0
else
tmp = y * -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.5e+261) {
tmp = x + 1.0;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.5e+261: tmp = x + 1.0 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.5e+261) tmp = Float64(x + 1.0); else tmp = Float64(y * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.5e+261) tmp = x + 1.0; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.5e+261], N[(x + 1.0), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.5 \cdot 10^{+261}:\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 2.5e261Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6459.8
Applied rewrites59.8%
if 2.5e261 < z Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
(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-+.f6457.4
Applied rewrites57.4%
(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-+.f6457.4
Applied rewrites57.4%
Taylor expanded in x around 0
Applied rewrites21.1%
herbie shell --seed 2024214
(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))))