Cody

Solution 1563724

Submitted on 18 Jun 2018 by reema ziada
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
filetext = fileread('myCos.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
filetext = fileread('myCos.m'); trigUsed = any(strfind(filetext, 'cos')) || any(strfind(filetext, 'sin')) ||... any(strfind(filetext, 'exp')); assert(~trigUsed, 'Cannot use MATLAB trigonometric functions')

3   Pass
x = 0; assert(abs(myCos(x)-cos(x)) < 0.0001)

j = 1 y = 1 j = 2 y = 1 j = 3 y = 1 j = 4 y = 1 j = 5 y = 1 j = 6 y = 1 j = 7 y = 1 j = 8 y = 1 j = 9 y = 1 j = 10 y = 1 j = 11 y = 1

4   Pass
x = pi; assert(abs(myCos(x)-cos(x)) < 0.0001)

j = 1 y = 1 j = 2 y = -3.9348 j = 3 y = 0.1239 j = 4 y = -1.2114 j = 5 y = -0.9760 j = 6 y = -1.0018 j = 7 y = -0.9999 j = 8 y = -1.0000 j = 9 y = -1.0000 j = 10 y = -1.0000 j = 11 y = -1.0000

5   Pass
x = pi/2; assert(abs(myCos(x)-cos(x)) < 0.0001)

j = 1 y = 1 j = 2 y = -0.2337 j = 3 y = 0.0200 j = 4 y = -8.9452e-04 j = 5 y = 2.4737e-05 j = 6 y = -4.6477e-07 j = 7 y = 6.3215e-09 j = 8 y = -6.5134e-11 j = 9 y = 5.2606e-13 j = 10 y = -3.3769e-15 j = 11 y = 6.0818e-17

6   Pass
x = 5*pi/3; assert(abs(myCos(x)-cos(x)) < 0.0001)

j = 1 y = 1 j = 2 y = -12.7078 j = 3 y = 18.6094 j = 4 y = -10.0099 j = 5 y = 4.0011 j = 6 y = -0.2669 j = 7 y = 0.6195 j = 8 y = 0.4860 j = 9 y = 0.5013 j = 10 y = 0.4999 j = 11 y = 0.5000