Compute sin(X*pi) accurately
Calculate Sine of Multiples of π
Compare the accuracy of
Create a vector of values.
X = [0 1/2 1 3/2 2];
Calculate the sine of
X*pi using the normal
Y = sin(X*pi)
Y = 1×5 0 1.0000 0.0000 -1.0000 -0.0000
The results contain small numerical errors due to the fact that
pi is a floating-point approximation of the true value of . For instance,
Y(3) is not exactly zero even though .
ans = 1.2246e-16
sinpi to calculate the same values. In this case, the results are exact.
Z = sinpi(X)
Z = 1×5 0 1 0 -1 0
ans = 0
X — Input array
scalar | vector | matrix | multidimensional array
Input array, specified as a scalar, vector, matrix, or multidimensional array.
Complex Number Support: Yes
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).