Cody

# Problem 44848. Approximate the inverse tangent by power series

Solution 2277899

Submitted on 13 May 2020 by Binbin Qi
• Size: 35
• This is the leading solution.
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
ff = 'fileread'; assert(nargin(ff)~=-1, 'empty file forbidden') filetext = fileread('myfun.m'); assert(isempty(strfind(filetext, '''')),'string forbidden') assert(isempty(strfind(filetext, 'varargin')),'varargin forbidden') assert(isempty(strfind(filetext, 'ans')),'ans forbidden') assert(isempty(strfind(filetext, 'atan')),'atan forbidden') assert(isempty(strfind(filetext, 'atan2')),'atan2 forbidden') assert(isempty(strfind(filetext, 'atand')),'atand forbidden') assert(isempty(strfind(filetext, 'atan2d')),'atan2d forbidden') assert(isempty(strfind(filetext, 'tan')),'tan forbidden') assert(~isempty(filetext),'empty file forbidden')

2   Pass
b = 0.1; n = 3; y_correct = 0.09966667; assert(abs(myfun(b,n)-y_correct)<1e-6)

r = 0.0997

3   Pass
b = 0.01; n = 5; y_correct = 0.00999967; assert(abs(myfun(b,n)-y_correct)<1e-6)

r = 0.0100

4   Pass
b = 0.2; n = 3; y_correct = 0.19733333; assert(abs(myfun(b,n)-y_correct)<1e-6)

r = 0.1973

5   Pass
b = 0.2; n = 1; y_correct = 0.20000000; assert(abs(myfun(b,n)-y_correct)<1e-6)

r = 0.2000

6   Pass
b = 0.2; n = 7; y_correct = 0.19739550; assert(abs(myfun(b,n)-y_correct)<1e-6)

r = 0.1974