
(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 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -840000000000.0) (not (<= y 8.5))) (+ x (* z (cos y))) (+ z (+ x y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -840000000000.0) || !(y <= 8.5)) {
tmp = x + (z * cos(y));
} else {
tmp = z + (x + 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 ((y <= (-840000000000.0d0)) .or. (.not. (y <= 8.5d0))) then
tmp = x + (z * cos(y))
else
tmp = z + (x + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -840000000000.0) || !(y <= 8.5)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = z + (x + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -840000000000.0) or not (y <= 8.5): tmp = x + (z * math.cos(y)) else: tmp = z + (x + y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -840000000000.0) || !(y <= 8.5)) tmp = Float64(x + Float64(z * cos(y))); else tmp = Float64(z + Float64(x + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -840000000000.0) || ~((y <= 8.5))) tmp = x + (z * cos(y)); else tmp = z + (x + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -840000000000.0], N[Not[LessEqual[y, 8.5]], $MachinePrecision]], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -840000000000 \lor \neg \left(y \leq 8.5\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;z + \left(x + y\right)\\
\end{array}
\end{array}
if y < -8.4e11 or 8.5 < y Initial program 99.8%
Taylor expanded in x around inf 78.4%
if -8.4e11 < y < 8.5Initial program 100.0%
Taylor expanded in y around 0 99.4%
Taylor expanded in y around 0 98.0%
+-commutative98.0%
Simplified98.0%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -6600000000.0) (not (<= z 4.4))) (+ x (* z (cos y))) (+ (+ x (sin y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6600000000.0) || !(z <= 4.4)) {
tmp = x + (z * cos(y));
} else {
tmp = (x + sin(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 <= (-6600000000.0d0)) .or. (.not. (z <= 4.4d0))) then
tmp = x + (z * cos(y))
else
tmp = (x + sin(y)) + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6600000000.0) || !(z <= 4.4)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = (x + Math.sin(y)) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6600000000.0) or not (z <= 4.4): tmp = x + (z * math.cos(y)) else: tmp = (x + math.sin(y)) + z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6600000000.0) || !(z <= 4.4)) tmp = Float64(x + Float64(z * cos(y))); else tmp = Float64(Float64(x + sin(y)) + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6600000000.0) || ~((z <= 4.4))) tmp = x + (z * cos(y)); else tmp = (x + sin(y)) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6600000000.0], N[Not[LessEqual[z, 4.4]], $MachinePrecision]], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6600000000 \lor \neg \left(z \leq 4.4\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\end{array}
\end{array}
if z < -6.6e9 or 4.4000000000000004 < z Initial program 99.9%
Taylor expanded in x around inf 99.9%
if -6.6e9 < z < 4.4000000000000004Initial program 100.0%
Taylor expanded in y around 0 99.0%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.8e-111) (not (<= x 1.7e-9))) (+ x z) (+ (sin y) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e-111) || !(x <= 1.7e-9)) {
tmp = x + z;
} else {
tmp = sin(y) + z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-3.8d-111)) .or. (.not. (x <= 1.7d-9))) then
tmp = x + z
else
tmp = sin(y) + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e-111) || !(x <= 1.7e-9)) {
tmp = x + z;
} else {
tmp = Math.sin(y) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.8e-111) or not (x <= 1.7e-9): tmp = x + z else: tmp = math.sin(y) + z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.8e-111) || !(x <= 1.7e-9)) tmp = Float64(x + z); else tmp = Float64(sin(y) + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.8e-111) || ~((x <= 1.7e-9))) tmp = x + z; else tmp = sin(y) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.8e-111], N[Not[LessEqual[x, 1.7e-9]], $MachinePrecision]], N[(x + z), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-111} \lor \neg \left(x \leq 1.7 \cdot 10^{-9}\right):\\
\;\;\;\;x + z\\
\mathbf{else}:\\
\;\;\;\;\sin y + z\\
\end{array}
\end{array}
if x < -3.80000000000000022e-111 or 1.6999999999999999e-9 < x Initial program 99.9%
Taylor expanded in x around inf 95.8%
Taylor expanded in y around 0 80.8%
if -3.80000000000000022e-111 < x < 1.6999999999999999e-9Initial program 99.9%
Taylor expanded in x around 0 98.4%
Taylor expanded in y around 0 77.1%
Final simplification79.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.6e+28) (not (<= y 7.5e+97))) (+ x z) (+ z (+ x y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.6e+28) || !(y <= 7.5e+97)) {
tmp = x + z;
} else {
tmp = z + (x + 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 ((y <= (-4.6d+28)) .or. (.not. (y <= 7.5d+97))) then
tmp = x + z
else
tmp = z + (x + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.6e+28) || !(y <= 7.5e+97)) {
tmp = x + z;
} else {
tmp = z + (x + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.6e+28) or not (y <= 7.5e+97): tmp = x + z else: tmp = z + (x + y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.6e+28) || !(y <= 7.5e+97)) tmp = Float64(x + z); else tmp = Float64(z + Float64(x + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.6e+28) || ~((y <= 7.5e+97))) tmp = x + z; else tmp = z + (x + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.6e+28], N[Not[LessEqual[y, 7.5e+97]], $MachinePrecision]], N[(x + z), $MachinePrecision], N[(z + N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{+28} \lor \neg \left(y \leq 7.5 \cdot 10^{+97}\right):\\
\;\;\;\;x + z\\
\mathbf{else}:\\
\;\;\;\;z + \left(x + y\right)\\
\end{array}
\end{array}
if y < -4.59999999999999968e28 or 7.5000000000000004e97 < y Initial program 99.8%
Taylor expanded in x around inf 81.4%
Taylor expanded in y around 0 45.2%
if -4.59999999999999968e28 < y < 7.5000000000000004e97Initial program 100.0%
Taylor expanded in y around 0 94.2%
Taylor expanded in y around 0 87.8%
+-commutative87.8%
Simplified87.8%
Final simplification72.2%
(FPCore (x y z) :precision binary64 (+ x z))
double code(double x, double y, double z) {
return x + z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + z
end function
public static double code(double x, double y, double z) {
return x + z;
}
def code(x, y, z): return x + z
function code(x, y, z) return Float64(x + z) end
function tmp = code(x, y, z) tmp = x + z; end
code[x_, y_, z_] := N[(x + z), $MachinePrecision]
\begin{array}{l}
\\
x + z
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 84.1%
Taylor expanded in y around 0 67.3%
Final simplification67.3%
herbie shell --seed 2024115
(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))))