Cody

# Problem 44492. Approximate the cosine function

Solution 1563587

Submitted on 18 Jun 2018 by tamir zinger
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)

[Warning: Too many FOR loop iterations. Stopping after 9223372036854775806 iterations.] [> In myCos (line 5) In ScoringEngineTestPoint3 (line 2) In solutionTest (line 7)]

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

[Warning: Too many FOR loop iterations. Stopping after 9223372036854775806 iterations.] [> In myCos (line 5) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)]

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

[Warning: Too many FOR loop iterations. Stopping after 9223372036854775806 iterations.] [> In myCos (line 5) In ScoringEngineTestPoint5 (line 2) In solutionTest (line 11)]

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

[Warning: Too many FOR loop iterations. Stopping after 9223372036854775806 iterations.] [> In myCos (line 5) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)]