
(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}
\\
x \cdot \sin y + 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}
\\
x \cdot \sin y + 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}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z 3.4e+116) (+ (* x (sin y)) z) (+ (* z (cos y)) (* x y))))
double code(double x, double y, double z) {
double tmp;
if (z <= 3.4e+116) {
tmp = (x * sin(y)) + z;
} else {
tmp = (z * cos(y)) + (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 (z <= 3.4d+116) then
tmp = (x * sin(y)) + z
else
tmp = (z * cos(y)) + (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 3.4e+116) {
tmp = (x * Math.sin(y)) + z;
} else {
tmp = (z * Math.cos(y)) + (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 3.4e+116: tmp = (x * math.sin(y)) + z else: tmp = (z * math.cos(y)) + (x * y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 3.4e+116) tmp = Float64(Float64(x * sin(y)) + z); else tmp = Float64(Float64(z * cos(y)) + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 3.4e+116) tmp = (x * sin(y)) + z; else tmp = (z * cos(y)) + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 3.4e+116], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.4 \cdot 10^{+116}:\\
\;\;\;\;x \cdot \sin y + z\\
\mathbf{else}:\\
\;\;\;\;z \cdot \cos y + x \cdot y\\
\end{array}
\end{array}
if z < 3.40000000000000023e116Initial program 99.9%
Taylor expanded in y around 0 86.7%
if 3.40000000000000023e116 < z Initial program 99.8%
Taylor expanded in y around 0 84.1%
Final simplification86.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.3e-6) (not (<= y 520000000000.0))) (* x (sin y)) (+ (* -0.5 (* y (* y z))) (+ z (* x y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.3e-6) || !(y <= 520000000000.0)) {
tmp = x * sin(y);
} else {
tmp = (-0.5 * (y * (y * z))) + (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 <= (-2.3d-6)) .or. (.not. (y <= 520000000000.0d0))) then
tmp = x * sin(y)
else
tmp = ((-0.5d0) * (y * (y * z))) + (z + (x * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.3e-6) || !(y <= 520000000000.0)) {
tmp = x * Math.sin(y);
} else {
tmp = (-0.5 * (y * (y * z))) + (z + (x * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.3e-6) or not (y <= 520000000000.0): tmp = x * math.sin(y) else: tmp = (-0.5 * (y * (y * z))) + (z + (x * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.3e-6) || !(y <= 520000000000.0)) tmp = Float64(x * sin(y)); else tmp = Float64(Float64(-0.5 * Float64(y * Float64(y * z))) + Float64(z + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.3e-6) || ~((y <= 520000000000.0))) tmp = x * sin(y); else tmp = (-0.5 * (y * (y * z))) + (z + (x * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.3e-6], N[Not[LessEqual[y, 520000000000.0]], $MachinePrecision]], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(y * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-6} \lor \neg \left(y \leq 520000000000\right):\\
\;\;\;\;x \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(y \cdot \left(y \cdot z\right)\right) + \left(z + x \cdot y\right)\\
\end{array}
\end{array}
if y < -2.3e-6 or 5.2e11 < y Initial program 99.7%
Taylor expanded in y around 0 63.5%
Taylor expanded in x around inf 60.8%
if -2.3e-6 < y < 5.2e11Initial program 100.0%
Taylor expanded in y around 0 98.9%
expm1-log1p-u96.0%
expm1-udef95.8%
unpow295.8%
associate-*l*95.8%
Applied egg-rr95.8%
expm1-def96.0%
expm1-log1p98.9%
Simplified98.9%
Final simplification81.8%
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) z))
double code(double x, double y, double z) {
return (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 = (x * sin(y)) + z
end function
public static double code(double x, double y, double z) {
return (x * Math.sin(y)) + z;
}
def code(x, y, z): return (x * math.sin(y)) + z
function code(x, y, z) return Float64(Float64(x * sin(y)) + z) end
function tmp = code(x, y, z) tmp = (x * sin(y)) + z; end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sin y + z
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 82.9%
Final simplification82.9%
(FPCore (x y z) :precision binary64 (+ z (* x y)))
double code(double x, double y, double z) {
return z + (x * y);
}
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 * y)
end function
public static double code(double x, double y, double z) {
return z + (x * y);
}
def code(x, y, z): return z + (x * y)
function code(x, y, z) return Float64(z + Float64(x * y)) end
function tmp = code(x, y, z) tmp = z + (x * y); end
code[x_, y_, z_] := N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + x \cdot y
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 56.8%
Final simplification56.8%
(FPCore (x y z) :precision binary64 (* x y))
double code(double x, double y, double z) {
return x * 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 * y
end function
public static double code(double x, double y, double z) {
return x * y;
}
def code(x, y, z): return x * y
function code(x, y, z) return Float64(x * y) end
function tmp = code(x, y, z) tmp = x * y; end
code[x_, y_, z_] := N[(x * y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 56.8%
Taylor expanded in y around inf 17.1%
Final simplification17.1%
herbie shell --seed 2023238
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
:precision binary64
(+ (* x (sin y)) (* z (cos y))))