
(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 14 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 (- (+ (cos y) x) (* (sin y) z)))
double code(double x, double y, double z) {
return (cos(y) + x) - (sin(y) * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cos(y) + x) - (sin(y) * z)
end function
public static double code(double x, double y, double z) {
return (Math.cos(y) + x) - (Math.sin(y) * z);
}
def code(x, y, z): return (math.cos(y) + x) - (math.sin(y) * z)
function code(x, y, z) return Float64(Float64(cos(y) + x) - Float64(sin(y) * z)) end
function tmp = code(x, y, z) tmp = (cos(y) + x) - (sin(y) * z); end
code[x_, y_, z_] := N[(N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\cos y + x\right) - \sin y \cdot z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (cos y) x) (* (sin y) z))) (t_1 (- x (fma z y -1.0))))
(if (<= t_0 -40000000000.0)
t_1
(if (<= t_0 0.9996554221240338)
(cos y)
(if (<= t_0 5e+151) t_1 (+ 1.0 x))))))
double code(double x, double y, double z) {
double t_0 = (cos(y) + x) - (sin(y) * z);
double t_1 = x - fma(z, y, -1.0);
double tmp;
if (t_0 <= -40000000000.0) {
tmp = t_1;
} else if (t_0 <= 0.9996554221240338) {
tmp = cos(y);
} else if (t_0 <= 5e+151) {
tmp = t_1;
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(cos(y) + x) - Float64(sin(y) * z)) t_1 = Float64(x - fma(z, y, -1.0)) tmp = 0.0 if (t_0 <= -40000000000.0) tmp = t_1; elseif (t_0 <= 0.9996554221240338) tmp = cos(y); elseif (t_0 <= 5e+151) tmp = t_1; else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -40000000000.0], t$95$1, If[LessEqual[t$95$0, 0.9996554221240338], N[Cos[y], $MachinePrecision], If[LessEqual[t$95$0, 5e+151], t$95$1, N[(1.0 + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos y + x\right) - \sin y \cdot z\\
t_1 := x - \mathsf{fma}\left(z, y, -1\right)\\
\mathbf{if}\;t\_0 \leq -40000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.9996554221240338:\\
\;\;\;\;\cos y\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+151}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -4e10 or 0.999655422124033799 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 5.0000000000000002e151Initial 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
*-commutativeN/A
metadata-evalN/A
lower-fma.f6477.1
Applied rewrites77.1%
if -4e10 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.999655422124033799Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6496.3
Applied rewrites96.3%
Taylor expanded in x around 0
Applied rewrites93.7%
if 5.0000000000000002e151 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6471.9
Applied rewrites71.9%
Final simplification78.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (cos y) x))
(t_1 (* (sin y) z))
(t_2 (- t_0 t_1))
(t_3 (- (+ 1.0 x) t_1)))
(if (<= t_2 -40000000000.0) t_3 (if (<= t_2 0.9996554221240338) t_0 t_3))))
double code(double x, double y, double z) {
double t_0 = cos(y) + x;
double t_1 = sin(y) * z;
double t_2 = t_0 - t_1;
double t_3 = (1.0 + x) - t_1;
double tmp;
if (t_2 <= -40000000000.0) {
tmp = t_3;
} else if (t_2 <= 0.9996554221240338) {
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 = cos(y) + x
t_1 = sin(y) * z
t_2 = t_0 - t_1
t_3 = (1.0d0 + x) - t_1
if (t_2 <= (-40000000000.0d0)) then
tmp = t_3
else if (t_2 <= 0.9996554221240338d0) 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 = Math.cos(y) + x;
double t_1 = Math.sin(y) * z;
double t_2 = t_0 - t_1;
double t_3 = (1.0 + x) - t_1;
double tmp;
if (t_2 <= -40000000000.0) {
tmp = t_3;
} else if (t_2 <= 0.9996554221240338) {
tmp = t_0;
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z): t_0 = math.cos(y) + x t_1 = math.sin(y) * z t_2 = t_0 - t_1 t_3 = (1.0 + x) - t_1 tmp = 0 if t_2 <= -40000000000.0: tmp = t_3 elif t_2 <= 0.9996554221240338: tmp = t_0 else: tmp = t_3 return tmp
function code(x, y, z) t_0 = Float64(cos(y) + x) t_1 = Float64(sin(y) * z) t_2 = Float64(t_0 - t_1) t_3 = Float64(Float64(1.0 + x) - t_1) tmp = 0.0 if (t_2 <= -40000000000.0) tmp = t_3; elseif (t_2 <= 0.9996554221240338) tmp = t_0; else tmp = t_3; end return tmp end
function tmp_2 = code(x, y, z) t_0 = cos(y) + x; t_1 = sin(y) * z; t_2 = t_0 - t_1; t_3 = (1.0 + x) - t_1; tmp = 0.0; if (t_2 <= -40000000000.0) tmp = t_3; elseif (t_2 <= 0.9996554221240338) tmp = t_0; else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(1.0 + x), $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -40000000000.0], t$95$3, If[LessEqual[t$95$2, 0.9996554221240338], t$95$0, t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y + x\\
t_1 := \sin y \cdot z\\
t_2 := t\_0 - t\_1\\
t_3 := \left(1 + x\right) - t\_1\\
\mathbf{if}\;t\_2 \leq -40000000000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0.9996554221240338:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -4e10 or 0.999655422124033799 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites99.9%
if -4e10 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.999655422124033799Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6496.3
Applied rewrites96.3%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (cos y) x))
(t_1 (- t_0 (* (sin y) z)))
(t_2 (fma (- (sin y)) z x)))
(if (<= t_1 -40000000000.0) t_2 (if (<= t_1 2.0) t_0 t_2))))
double code(double x, double y, double z) {
double t_0 = cos(y) + x;
double t_1 = t_0 - (sin(y) * z);
double t_2 = fma(-sin(y), z, x);
double tmp;
if (t_1 <= -40000000000.0) {
tmp = t_2;
} else if (t_1 <= 2.0) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(cos(y) + x) t_1 = Float64(t_0 - Float64(sin(y) * z)) t_2 = fma(Float64(-sin(y)), z, x) tmp = 0.0 if (t_1 <= -40000000000.0) tmp = t_2; elseif (t_1 <= 2.0) tmp = t_0; else tmp = t_2; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Sin[y], $MachinePrecision]) * z + x), $MachinePrecision]}, If[LessEqual[t$95$1, -40000000000.0], t$95$2, If[LessEqual[t$95$1, 2.0], t$95$0, t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y + x\\
t_1 := t\_0 - \sin y \cdot z\\
t_2 := \mathsf{fma}\left(-\sin y, z, x\right)\\
\mathbf{if}\;t\_1 \leq -40000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -4e10 or 2 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6483.5
Applied rewrites83.5%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in z around inf
Applied rewrites99.6%
if -4e10 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 2Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6498.3
Applied rewrites98.3%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- z) (sin y)))) (if (<= z -4.2e+105) t_0 (if (<= z 5.5e+152) (+ (cos y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = -z * sin(y);
double tmp;
if (z <= -4.2e+105) {
tmp = t_0;
} else if (z <= 5.5e+152) {
tmp = cos(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 = -z * sin(y)
if (z <= (-4.2d+105)) then
tmp = t_0
else if (z <= 5.5d+152) then
tmp = cos(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 = -z * Math.sin(y);
double tmp;
if (z <= -4.2e+105) {
tmp = t_0;
} else if (z <= 5.5e+152) {
tmp = Math.cos(y) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -z * math.sin(y) tmp = 0 if z <= -4.2e+105: tmp = t_0 elif z <= 5.5e+152: tmp = math.cos(y) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-z) * sin(y)) tmp = 0.0 if (z <= -4.2e+105) tmp = t_0; elseif (z <= 5.5e+152) tmp = Float64(cos(y) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -z * sin(y); tmp = 0.0; if (z <= -4.2e+105) tmp = t_0; elseif (z <= 5.5e+152) tmp = cos(y) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+105], t$95$0, If[LessEqual[z, 5.5e+152], N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) \cdot \sin y\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{+152}:\\
\;\;\;\;\cos y + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.2000000000000002e105 or 5.4999999999999999e152 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f6470.7
Applied rewrites70.7%
if -4.2000000000000002e105 < z < 5.4999999999999999e152Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6492.1
Applied rewrites92.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (cos y) x)))
(if (<= y -0.0098)
t_0
(if (<= y 55000000.0)
(fma (- (* (fma 0.16666666666666666 (* z y) -0.5) y) z) y (+ 1.0 x))
t_0))))
double code(double x, double y, double z) {
double t_0 = cos(y) + x;
double tmp;
if (y <= -0.0098) {
tmp = t_0;
} else if (y <= 55000000.0) {
tmp = fma(((fma(0.16666666666666666, (z * y), -0.5) * y) - z), y, (1.0 + x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(cos(y) + x) tmp = 0.0 if (y <= -0.0098) tmp = t_0; elseif (y <= 55000000.0) tmp = fma(Float64(Float64(fma(0.16666666666666666, Float64(z * y), -0.5) * y) - z), y, Float64(1.0 + x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -0.0098], t$95$0, If[LessEqual[y, 55000000.0], N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision] + -0.5), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y + x\\
\mathbf{if}\;y \leq -0.0098:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 55000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5\right) \cdot y - z, y, 1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0097999999999999997 or 5.5e7 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6470.0
Applied rewrites70.0%
if -0.0097999999999999997 < y < 5.5e7Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6499.3
Applied rewrites99.3%
(FPCore (x y z)
:precision binary64
(if (<= y -6e+26)
(+ 1.0 x)
(if (<= y 1.4e+25)
(fma (- (* (fma 0.16666666666666666 (* z y) -0.5) y) z) y (+ 1.0 x))
(fma (/ 1.0 x) x x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e+26) {
tmp = 1.0 + x;
} else if (y <= 1.4e+25) {
tmp = fma(((fma(0.16666666666666666, (z * y), -0.5) * y) - z), y, (1.0 + x));
} else {
tmp = fma((1.0 / x), x, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6e+26) tmp = Float64(1.0 + x); elseif (y <= 1.4e+25) tmp = fma(Float64(Float64(fma(0.16666666666666666, Float64(z * y), -0.5) * y) - z), y, Float64(1.0 + x)); else tmp = fma(Float64(1.0 / x), x, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6e+26], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 1.4e+25], N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision] + -0.5), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+26}:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5\right) \cdot y - z, y, 1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{x}, x, x\right)\\
\end{array}
\end{array}
if y < -5.99999999999999994e26Initial program 99.8%
Taylor expanded in y around 0
lower-+.f6444.5
Applied rewrites44.5%
if -5.99999999999999994e26 < y < 1.4000000000000001e25Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6495.7
Applied rewrites95.7%
if 1.4000000000000001e25 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6473.2
Applied rewrites73.2%
Taylor expanded in x around inf
Applied rewrites73.1%
Taylor expanded in y around 0
Applied rewrites43.5%
(FPCore (x y z) :precision binary64 (if (<= y -460000.0) (+ 1.0 x) (if (<= y 2.4e+21) (fma (- (* -0.5 y) z) y (+ 1.0 x)) (fma (/ 1.0 x) x x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -460000.0) {
tmp = 1.0 + x;
} else if (y <= 2.4e+21) {
tmp = fma(((-0.5 * y) - z), y, (1.0 + x));
} else {
tmp = fma((1.0 / x), x, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -460000.0) tmp = Float64(1.0 + x); elseif (y <= 2.4e+21) tmp = fma(Float64(Float64(-0.5 * y) - z), y, Float64(1.0 + x)); else tmp = fma(Float64(1.0 / x), x, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -460000.0], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 2.4e+21], N[(N[(N[(-0.5 * y), $MachinePrecision] - z), $MachinePrecision] * y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -460000:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot y - z, y, 1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{x}, x, x\right)\\
\end{array}
\end{array}
if y < -4.6e5Initial program 99.8%
Taylor expanded in y around 0
lower-+.f6445.1
Applied rewrites45.1%
if -4.6e5 < y < 2.4e21Initial program 100.0%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6497.6
Applied rewrites97.6%
if 2.4e21 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6472.2
Applied rewrites72.2%
Taylor expanded in x around inf
Applied rewrites72.1%
Taylor expanded in y around 0
Applied rewrites42.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (/ 1.0 x) x x))) (if (<= y -0.026) t_0 (if (<= y 2e-9) (fma (- y) z (+ 1.0 x)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((1.0 / x), x, x);
double tmp;
if (y <= -0.026) {
tmp = t_0;
} else if (y <= 2e-9) {
tmp = fma(-y, z, (1.0 + x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(1.0 / x), x, x) tmp = 0.0 if (y <= -0.026) tmp = t_0; elseif (y <= 2e-9) tmp = fma(Float64(-y), z, Float64(1.0 + x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] * x + x), $MachinePrecision]}, If[LessEqual[y, -0.026], t$95$0, If[LessEqual[y, 2e-9], N[((-y) * z + N[(1.0 + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{1}{x}, x, x\right)\\
\mathbf{if}\;y \leq -0.026:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(-y, z, 1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0259999999999999988 or 2.00000000000000012e-9 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f6470.0
Applied rewrites70.0%
Taylor expanded in x around inf
Applied rewrites69.9%
Taylor expanded in y around 0
Applied rewrites44.6%
if -0.0259999999999999988 < y < 2.00000000000000012e-9Initial program 100.0%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-+.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= y -0.026) (+ 1.0 x) (if (<= y 2e-9) (fma (- y) z (+ 1.0 x)) (+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -0.026) {
tmp = 1.0 + x;
} else if (y <= 2e-9) {
tmp = fma(-y, z, (1.0 + x));
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -0.026) tmp = Float64(1.0 + x); elseif (y <= 2e-9) tmp = fma(Float64(-y), z, Float64(1.0 + x)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -0.026], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 2e-9], N[((-y) * z + N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.026:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(-y, z, 1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -0.0259999999999999988 or 2.00000000000000012e-9 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6444.6
Applied rewrites44.6%
if -0.0259999999999999988 < y < 2.00000000000000012e-9Initial program 100.0%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-+.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= y -0.026) (+ 1.0 x) (if (<= y 2e-9) (- x (fma z y -1.0)) (+ 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -0.026) {
tmp = 1.0 + x;
} else if (y <= 2e-9) {
tmp = x - fma(z, y, -1.0);
} else {
tmp = 1.0 + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -0.026) tmp = Float64(1.0 + x); elseif (y <= 2e-9) tmp = Float64(x - fma(z, y, -1.0)); else tmp = Float64(1.0 + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -0.026], N[(1.0 + x), $MachinePrecision], If[LessEqual[y, 2e-9], N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.026:\\
\;\;\;\;1 + x\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-9}:\\
\;\;\;\;x - \mathsf{fma}\left(z, y, -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if y < -0.0259999999999999988 or 2.00000000000000012e-9 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6444.6
Applied rewrites44.6%
if -0.0259999999999999988 < y < 2.00000000000000012e-9Initial 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
*-commutativeN/A
metadata-evalN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= z -9.6e+188) (* (- y) z) (+ 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.6e+188) {
tmp = -y * z;
} else {
tmp = 1.0 + 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) :: tmp
if (z <= (-9.6d+188)) then
tmp = -y * z
else
tmp = 1.0d0 + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9.6e+188) {
tmp = -y * z;
} else {
tmp = 1.0 + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9.6e+188: tmp = -y * z else: tmp = 1.0 + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9.6e+188) tmp = Float64(Float64(-y) * z); else tmp = Float64(1.0 + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9.6e+188) tmp = -y * z; else tmp = 1.0 + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9.6e+188], N[((-y) * z), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.6 \cdot 10^{+188}:\\
\;\;\;\;\left(-y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if z < -9.5999999999999997e188Initial program 99.9%
Taylor expanded in y around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6448.4
Applied rewrites48.4%
Taylor expanded in z around inf
Applied rewrites35.1%
if -9.5999999999999997e188 < z Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6467.3
Applied rewrites67.3%
Final simplification64.5%
(FPCore (x y z) :precision binary64 (+ 1.0 x))
double code(double x, double y, double z) {
return 1.0 + x;
}
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 + x
end function
public static double code(double x, double y, double z) {
return 1.0 + x;
}
def code(x, y, z): return 1.0 + x
function code(x, y, z) return Float64(1.0 + x) end
function tmp = code(x, y, z) tmp = 1.0 + x; end
code[x_, y_, z_] := N[(1.0 + x), $MachinePrecision]
\begin{array}{l}
\\
1 + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6462.8
Applied rewrites62.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
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in x around 0
Applied rewrites21.9%
herbie shell --seed 2024235
(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))))