
(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 (fma z (cos y) (+ x (sin y))))
double code(double x, double y, double z) {
return fma(z, cos(y), (x + sin(y)));
}
function code(x, y, z) return fma(z, cos(y), Float64(x + sin(y))) end
code[x_, y_, z_] := N[(z * N[Cos[y], $MachinePrecision] + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \cos y, x + \sin y\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (<= z -3.6e+32) (fma z (cos y) x) (if (<= z 9e-40) (+ z (+ x (sin y))) (+ x (* z (cos y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.6e+32) {
tmp = fma(z, cos(y), x);
} else if (z <= 9e-40) {
tmp = z + (x + sin(y));
} else {
tmp = x + (z * cos(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3.6e+32) tmp = fma(z, cos(y), x); elseif (z <= 9e-40) tmp = Float64(z + Float64(x + sin(y))); else tmp = Float64(x + Float64(z * cos(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3.6e+32], N[(z * N[Cos[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 9e-40], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(z, \cos y, x\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-40}:\\
\;\;\;\;z + \left(x + \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \cos y\\
\end{array}
\end{array}
if z < -3.5999999999999997e32Initial program 99.7%
+-commutative99.7%
fma-define99.7%
Simplified99.7%
Taylor expanded in x around inf 99.7%
if -3.5999999999999997e32 < z < 9.0000000000000002e-40Initial program 100.0%
Taylor expanded in y around 0 99.6%
if 9.0000000000000002e-40 < z Initial program 99.9%
Taylor expanded in x around inf 97.0%
Final simplification99.0%
(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 (* z (cos y))))
(if (<= z -1.65e+167)
t_0
(if (<= z -3.4e-258)
(+ z x)
(if (<= z 1.6e-223)
(+ z (+ y x))
(if (<= z 1.15e-204) (sin y) (if (<= z 7.2e+115) (+ z x) t_0)))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -1.65e+167) {
tmp = t_0;
} else if (z <= -3.4e-258) {
tmp = z + x;
} else if (z <= 1.6e-223) {
tmp = z + (y + x);
} else if (z <= 1.15e-204) {
tmp = sin(y);
} else if (z <= 7.2e+115) {
tmp = z + 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 * cos(y)
if (z <= (-1.65d+167)) then
tmp = t_0
else if (z <= (-3.4d-258)) then
tmp = z + x
else if (z <= 1.6d-223) then
tmp = z + (y + x)
else if (z <= 1.15d-204) then
tmp = sin(y)
else if (z <= 7.2d+115) then
tmp = z + 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.cos(y);
double tmp;
if (z <= -1.65e+167) {
tmp = t_0;
} else if (z <= -3.4e-258) {
tmp = z + x;
} else if (z <= 1.6e-223) {
tmp = z + (y + x);
} else if (z <= 1.15e-204) {
tmp = Math.sin(y);
} else if (z <= 7.2e+115) {
tmp = z + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -1.65e+167: tmp = t_0 elif z <= -3.4e-258: tmp = z + x elif z <= 1.6e-223: tmp = z + (y + x) elif z <= 1.15e-204: tmp = math.sin(y) elif z <= 7.2e+115: tmp = z + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -1.65e+167) tmp = t_0; elseif (z <= -3.4e-258) tmp = Float64(z + x); elseif (z <= 1.6e-223) tmp = Float64(z + Float64(y + x)); elseif (z <= 1.15e-204) tmp = sin(y); elseif (z <= 7.2e+115) tmp = Float64(z + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -1.65e+167) tmp = t_0; elseif (z <= -3.4e-258) tmp = z + x; elseif (z <= 1.6e-223) tmp = z + (y + x); elseif (z <= 1.15e-204) tmp = sin(y); elseif (z <= 7.2e+115) tmp = z + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.65e+167], t$95$0, If[LessEqual[z, -3.4e-258], N[(z + x), $MachinePrecision], If[LessEqual[z, 1.6e-223], N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e-204], N[Sin[y], $MachinePrecision], If[LessEqual[z, 7.2e+115], N[(z + x), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -1.65 \cdot 10^{+167}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.4 \cdot 10^{-258}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-223}:\\
\;\;\;\;z + \left(y + x\right)\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-204}:\\
\;\;\;\;\sin y\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+115}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.65000000000000009e167 or 7.2000000000000001e115 < z Initial program 99.7%
Taylor expanded in z around inf 85.8%
if -1.65000000000000009e167 < z < -3.3999999999999998e-258 or 1.15e-204 < z < 7.2000000000000001e115Initial program 99.9%
Taylor expanded in y around 0 70.1%
+-commutative70.1%
Simplified70.1%
if -3.3999999999999998e-258 < z < 1.6e-223Initial program 100.0%
Taylor expanded in y around 0 78.5%
+-commutative78.5%
+-commutative78.5%
associate-+l+78.5%
Simplified78.5%
if 1.6e-223 < z < 1.15e-204Initial program 100.0%
Taylor expanded in z around 0 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 84.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -1.7e+35)
t_0
(if (<= z -0.000245)
(+ z x)
(if (<= z 2.3e-39) (+ x (sin y)) (if (<= z 9.5e+118) (+ z x) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -1.7e+35) {
tmp = t_0;
} else if (z <= -0.000245) {
tmp = z + x;
} else if (z <= 2.3e-39) {
tmp = x + sin(y);
} else if (z <= 9.5e+118) {
tmp = z + 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 * cos(y)
if (z <= (-1.7d+35)) then
tmp = t_0
else if (z <= (-0.000245d0)) then
tmp = z + x
else if (z <= 2.3d-39) then
tmp = x + sin(y)
else if (z <= 9.5d+118) then
tmp = z + 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.cos(y);
double tmp;
if (z <= -1.7e+35) {
tmp = t_0;
} else if (z <= -0.000245) {
tmp = z + x;
} else if (z <= 2.3e-39) {
tmp = x + Math.sin(y);
} else if (z <= 9.5e+118) {
tmp = z + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -1.7e+35: tmp = t_0 elif z <= -0.000245: tmp = z + x elif z <= 2.3e-39: tmp = x + math.sin(y) elif z <= 9.5e+118: tmp = z + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -1.7e+35) tmp = t_0; elseif (z <= -0.000245) tmp = Float64(z + x); elseif (z <= 2.3e-39) tmp = Float64(x + sin(y)); elseif (z <= 9.5e+118) tmp = Float64(z + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -1.7e+35) tmp = t_0; elseif (z <= -0.000245) tmp = z + x; elseif (z <= 2.3e-39) tmp = x + sin(y); elseif (z <= 9.5e+118) tmp = z + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.7e+35], t$95$0, If[LessEqual[z, -0.000245], N[(z + x), $MachinePrecision], If[LessEqual[z, 2.3e-39], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.5e+118], N[(z + x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -1.7 \cdot 10^{+35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -0.000245:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-39}:\\
\;\;\;\;x + \sin y\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+118}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.7000000000000001e35 or 9.49999999999999974e118 < z Initial program 99.8%
Taylor expanded in z around inf 82.0%
if -1.7000000000000001e35 < z < -2.4499999999999999e-4 or 2.30000000000000008e-39 < z < 9.49999999999999974e118Initial program 99.9%
Taylor expanded in y around 0 83.7%
+-commutative83.7%
Simplified83.7%
if -2.4499999999999999e-4 < z < 2.30000000000000008e-39Initial program 100.0%
Taylor expanded in z around 0 92.3%
+-commutative92.3%
Simplified92.3%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (<= z -9.5e-263) (+ z x) (if (<= z 2.25e-223) (+ z (+ y x)) (if (<= z 2.05e-209) (sin y) (+ z x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e-263) {
tmp = z + x;
} else if (z <= 2.25e-223) {
tmp = z + (y + x);
} else if (z <= 2.05e-209) {
tmp = sin(y);
} else {
tmp = z + 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.5d-263)) then
tmp = z + x
else if (z <= 2.25d-223) then
tmp = z + (y + x)
else if (z <= 2.05d-209) then
tmp = sin(y)
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e-263) {
tmp = z + x;
} else if (z <= 2.25e-223) {
tmp = z + (y + x);
} else if (z <= 2.05e-209) {
tmp = Math.sin(y);
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9.5e-263: tmp = z + x elif z <= 2.25e-223: tmp = z + (y + x) elif z <= 2.05e-209: tmp = math.sin(y) else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9.5e-263) tmp = Float64(z + x); elseif (z <= 2.25e-223) tmp = Float64(z + Float64(y + x)); elseif (z <= 2.05e-209) tmp = sin(y); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9.5e-263) tmp = z + x; elseif (z <= 2.25e-223) tmp = z + (y + x); elseif (z <= 2.05e-209) tmp = sin(y); else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9.5e-263], N[(z + x), $MachinePrecision], If[LessEqual[z, 2.25e-223], N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.05e-209], N[Sin[y], $MachinePrecision], N[(z + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{-263}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{-223}:\\
\;\;\;\;z + \left(y + x\right)\\
\mathbf{elif}\;z \leq 2.05 \cdot 10^{-209}:\\
\;\;\;\;\sin y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -9.5000000000000005e-263 or 2.04999999999999989e-209 < z Initial program 99.9%
Taylor expanded in y around 0 65.0%
+-commutative65.0%
Simplified65.0%
if -9.5000000000000005e-263 < z < 2.24999999999999984e-223Initial program 100.0%
Taylor expanded in y around 0 78.5%
+-commutative78.5%
+-commutative78.5%
associate-+l+78.5%
Simplified78.5%
if 2.24999999999999984e-223 < z < 2.04999999999999989e-209Initial program 100.0%
Taylor expanded in z around 0 98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 84.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.6e+32) (not (<= z 9e-40))) (+ x (* z (cos y))) (+ z (+ x (sin y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.6e+32) || !(z <= 9e-40)) {
tmp = x + (z * cos(y));
} else {
tmp = z + (x + 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 <= (-3.6d+32)) .or. (.not. (z <= 9d-40))) then
tmp = x + (z * cos(y))
else
tmp = z + (x + sin(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.6e+32) || !(z <= 9e-40)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = z + (x + Math.sin(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.6e+32) or not (z <= 9e-40): tmp = x + (z * math.cos(y)) else: tmp = z + (x + math.sin(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.6e+32) || !(z <= 9e-40)) tmp = Float64(x + Float64(z * cos(y))); else tmp = Float64(z + Float64(x + sin(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.6e+32) || ~((z <= 9e-40))) tmp = x + (z * cos(y)); else tmp = z + (x + sin(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.6e+32], N[Not[LessEqual[z, 9e-40]], $MachinePrecision]], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{+32} \lor \neg \left(z \leq 9 \cdot 10^{-40}\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z + \left(x + \sin y\right)\\
\end{array}
\end{array}
if z < -3.5999999999999997e32 or 9.0000000000000002e-40 < z Initial program 99.8%
Taylor expanded in x around inf 98.3%
if -3.5999999999999997e32 < z < 9.0000000000000002e-40Initial program 100.0%
Taylor expanded in y around 0 99.6%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.2e-19) (not (<= z 1.26e-39))) (+ x (* z (cos y))) (+ x (sin y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.2e-19) || !(z <= 1.26e-39)) {
tmp = x + (z * cos(y));
} else {
tmp = x + 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 <= (-8.2d-19)) .or. (.not. (z <= 1.26d-39))) then
tmp = x + (z * cos(y))
else
tmp = x + sin(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8.2e-19) || !(z <= 1.26e-39)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = x + Math.sin(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.2e-19) or not (z <= 1.26e-39): tmp = x + (z * math.cos(y)) else: tmp = x + math.sin(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.2e-19) || !(z <= 1.26e-39)) tmp = Float64(x + Float64(z * cos(y))); else tmp = Float64(x + sin(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8.2e-19) || ~((z <= 1.26e-39))) tmp = x + (z * cos(y)); else tmp = x + sin(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.2e-19], N[Not[LessEqual[z, 1.26e-39]], $MachinePrecision]], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{-19} \lor \neg \left(z \leq 1.26 \cdot 10^{-39}\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + \sin y\\
\end{array}
\end{array}
if z < -8.1999999999999997e-19 or 1.26e-39 < z Initial program 99.8%
Taylor expanded in x around inf 98.5%
if -8.1999999999999997e-19 < z < 1.26e-39Initial program 100.0%
Taylor expanded in z around 0 93.2%
+-commutative93.2%
Simplified93.2%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.75e+62) (not (<= y 4.1e-63))) (+ z x) (+ z (+ y x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.75e+62) || !(y <= 4.1e-63)) {
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) :: tmp
if ((y <= (-1.75d+62)) .or. (.not. (y <= 4.1d-63))) 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 tmp;
if ((y <= -1.75e+62) || !(y <= 4.1e-63)) {
tmp = z + x;
} else {
tmp = z + (y + x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.75e+62) or not (y <= 4.1e-63): tmp = z + x else: tmp = z + (y + x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.75e+62) || !(y <= 4.1e-63)) tmp = Float64(z + x); else tmp = Float64(z + Float64(y + x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.75e+62) || ~((y <= 4.1e-63))) tmp = z + x; else tmp = z + (y + x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.75e+62], N[Not[LessEqual[y, 4.1e-63]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+62} \lor \neg \left(y \leq 4.1 \cdot 10^{-63}\right):\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;z + \left(y + x\right)\\
\end{array}
\end{array}
if y < -1.74999999999999992e62 or 4.0999999999999998e-63 < y Initial program 99.8%
Taylor expanded in y around 0 40.9%
+-commutative40.9%
Simplified40.9%
if -1.74999999999999992e62 < y < 4.0999999999999998e-63Initial program 100.0%
Taylor expanded in y around 0 92.4%
+-commutative92.4%
+-commutative92.4%
associate-+l+92.4%
Simplified92.4%
Final simplification67.0%
(FPCore (x y z) :precision binary64 (if (<= x -1.25e+60) x (if (<= x 2.9e-67) (+ z y) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.25e+60) {
tmp = x;
} else if (x <= 2.9e-67) {
tmp = z + y;
} 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) :: tmp
if (x <= (-1.25d+60)) then
tmp = x
else if (x <= 2.9d-67) then
tmp = z + y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.25e+60) {
tmp = x;
} else if (x <= 2.9e-67) {
tmp = z + y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.25e+60: tmp = x elif x <= 2.9e-67: tmp = z + y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.25e+60) tmp = x; elseif (x <= 2.9e-67) tmp = Float64(z + y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.25e+60) tmp = x; elseif (x <= 2.9e-67) tmp = z + y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.25e+60], x, If[LessEqual[x, 2.9e-67], N[(z + y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+60}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-67}:\\
\;\;\;\;z + y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.24999999999999994e60 or 2.90000000000000005e-67 < x Initial program 99.9%
+-commutative99.9%
add-cube-cbrt99.7%
associate-*r*99.7%
fma-define99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 75.4%
if -1.24999999999999994e60 < x < 2.90000000000000005e-67Initial program 99.9%
Taylor expanded in x around 0 93.1%
Taylor expanded in y around 0 45.9%
Final simplification59.7%
(FPCore (x y z) :precision binary64 (if (<= x -2.1e+60) x (if (<= x 8.1e-84) z x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e+60) {
tmp = x;
} else if (x <= 8.1e-84) {
tmp = z;
} 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) :: tmp
if (x <= (-2.1d+60)) then
tmp = x
else if (x <= 8.1d-84) then
tmp = z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e+60) {
tmp = x;
} else if (x <= 8.1e-84) {
tmp = z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.1e+60: tmp = x elif x <= 8.1e-84: tmp = z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.1e+60) tmp = x; elseif (x <= 8.1e-84) tmp = z; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.1e+60) tmp = x; elseif (x <= 8.1e-84) tmp = z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.1e+60], x, If[LessEqual[x, 8.1e-84], z, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+60}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 8.1 \cdot 10^{-84}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.1000000000000001e60 or 8.0999999999999997e-84 < x Initial program 99.9%
+-commutative99.9%
add-cube-cbrt99.7%
associate-*r*99.7%
fma-define99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 74.2%
if -2.1000000000000001e60 < x < 8.0999999999999997e-84Initial program 99.9%
+-commutative99.9%
add-cube-cbrt99.4%
associate-*r*99.4%
fma-define99.4%
pow299.4%
Applied egg-rr99.4%
Taylor expanded in z around inf 62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in y around 0 39.1%
(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 63.5%
+-commutative63.5%
Simplified63.5%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
+-commutative99.9%
add-cube-cbrt99.6%
associate-*r*99.5%
fma-define99.5%
pow299.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 40.4%
herbie shell --seed 2024107
(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))))