
(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 5 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 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -7.8e-106) (not (<= x 2.8e-205))) (+ x (* z (cos y))) (+ (sin y) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7.8e-106) || !(x <= 2.8e-205)) {
tmp = x + (z * cos(y));
} 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 <= (-7.8d-106)) .or. (.not. (x <= 2.8d-205))) then
tmp = x + (z * cos(y))
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 <= -7.8e-106) || !(x <= 2.8e-205)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = Math.sin(y) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7.8e-106) or not (x <= 2.8e-205): tmp = x + (z * math.cos(y)) else: tmp = math.sin(y) + z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7.8e-106) || !(x <= 2.8e-205)) tmp = Float64(x + Float64(z * cos(y))); else tmp = Float64(sin(y) + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -7.8e-106) || ~((x <= 2.8e-205))) tmp = x + (z * cos(y)); else tmp = sin(y) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7.8e-106], N[Not[LessEqual[x, 2.8e-205]], $MachinePrecision]], N[(x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{-106} \lor \neg \left(x \leq 2.8 \cdot 10^{-205}\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;\sin y + z\\
\end{array}
\end{array}
if x < -7.80000000000000019e-106 or 2.79999999999999991e-205 < x Initial program 99.9%
Taylor expanded in x around inf 90.3%
if -7.80000000000000019e-106 < x < 2.79999999999999991e-205Initial program 100.0%
Taylor expanded in x around 0 93.8%
Taylor expanded in y around 0 86.6%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.65e+44) (not (<= z 8.4e-22))) (+ x (* z (cos y))) (+ (+ x (sin y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.65e+44) || !(z <= 8.4e-22)) {
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 <= (-1.65d+44)) .or. (.not. (z <= 8.4d-22))) 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 <= -1.65e+44) || !(z <= 8.4e-22)) {
tmp = x + (z * Math.cos(y));
} else {
tmp = (x + Math.sin(y)) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.65e+44) or not (z <= 8.4e-22): 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 <= -1.65e+44) || !(z <= 8.4e-22)) 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 <= -1.65e+44) || ~((z <= 8.4e-22))) tmp = x + (z * cos(y)); else tmp = (x + sin(y)) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.65e+44], N[Not[LessEqual[z, 8.4e-22]], $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 -1.65 \cdot 10^{+44} \lor \neg \left(z \leq 8.4 \cdot 10^{-22}\right):\\
\;\;\;\;x + z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\end{array}
\end{array}
if z < -1.65000000000000007e44 or 8.40000000000000031e-22 < z Initial program 99.9%
Taylor expanded in x around inf 99.9%
if -1.65000000000000007e44 < z < 8.40000000000000031e-22Initial program 100.0%
Taylor expanded in y around 0 99.5%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.1e-12) (not (<= x 2.05e-78))) (+ x z) (+ (sin y) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e-12) || !(x <= 2.05e-78)) {
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 <= (-2.1d-12)) .or. (.not. (x <= 2.05d-78))) 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 <= -2.1e-12) || !(x <= 2.05e-78)) {
tmp = x + z;
} else {
tmp = Math.sin(y) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.1e-12) or not (x <= 2.05e-78): tmp = x + z else: tmp = math.sin(y) + z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.1e-12) || !(x <= 2.05e-78)) 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 <= -2.1e-12) || ~((x <= 2.05e-78))) tmp = x + z; else tmp = sin(y) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.1e-12], N[Not[LessEqual[x, 2.05e-78]], $MachinePrecision]], N[(x + z), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-12} \lor \neg \left(x \leq 2.05 \cdot 10^{-78}\right):\\
\;\;\;\;x + z\\
\mathbf{else}:\\
\;\;\;\;\sin y + z\\
\end{array}
\end{array}
if x < -2.09999999999999994e-12 or 2.0499999999999999e-78 < x Initial program 99.9%
Taylor expanded in x around inf 96.5%
Taylor expanded in y around 0 79.9%
if -2.09999999999999994e-12 < x < 2.0499999999999999e-78Initial program 100.0%
Taylor expanded in x around 0 92.1%
Taylor expanded in y around 0 75.9%
Final simplification78.1%
(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 100.0%
Taylor expanded in x around inf 82.7%
Taylor expanded in y around 0 66.3%
Final simplification66.3%
herbie shell --seed 2024024
(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))))