Cody

# Problem 44492. Approximate the cosine function

Solution 2173517

Submitted on 24 Mar 2020
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   Fail
filetext = fileread('myCos.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

Error using fileread (line 23) Could not open file myCos.m. No such file or directory. Error in Test1 (line 1) filetext = fileread('myCos.m');

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

Error using fileread (line 23) Could not open file myCos.m. No such file or directory. Error in Test2 (line 1) filetext = fileread('myCos.m');

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

Undefined function 'myCos' for input arguments of type 'double'. Error in Test3 (line 2) assert(abs(myCos(x)-cos(x)) < 0.0001)

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

Undefined function 'myCos' for input arguments of type 'double'. Error in Test4 (line 2) assert(abs(myCos(x)-cos(x)) < 0.0001)

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

Undefined function 'myCos' for input arguments of type 'double'. Error in Test5 (line 2) assert(abs(myCos(x)-cos(x)) < 0.0001)

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

Undefined function 'myCos' for input arguments of type 'double'. Error in Test6 (line 2) assert(abs(myCos(x)-cos(x)) < 0.0001)