Cody

# Problem 1465. Generalized Laguerre polynomials

Solution 1938626

Submitted on 16 Sep 2019
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
user_solution = fileread('genLaguerrePoly.m'); assert(isempty(strfind(user_solution,'regexp'))); assert(isempty(strfind(user_solution,'2str'))); assert(isempty(strfind(user_solution,'str2'))); assert(isempty(strfind(user_solution,'interp'))); assert(isempty(strfind(user_solution,'printf'))); assert(isempty(strfind(user_solution,'assert')));

2   Pass
n = 0; a = 0; P_correct = [1]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = 1

3   Pass
n = 1; a = 0; P_correct = [-1 1]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = -1 1

4   Pass
n = 2; a = 0; P_correct = [1 -4 2]/2; assert(isequal(round(genLaguerrePoly(n,a)*2),round(P_correct*2)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} ans = 0.2500 -2.0000 1.0000

5   Fail
n = 3; a = 0; P_correct = [-1 9 -18 6]/6; assert(isequal(round(genLaguerrePoly(n,a)*6),round(P_correct*6)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} ans = -0.0500 0.8500 -3.0000 1.0000

Assertion failed.

6   Fail
n = 4; a = 0; P_correct = [1 -16 72 -96 24]/24; assert(isequal(round(genLaguerrePoly(n,a)*24),round(P_correct*24)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} ans = 0.0083 -0.2333 1.8500 -4.0000 1.0000

Assertion failed.

7   Fail
n = 5; a = 0; P_correct = [-1 25 -200 600 -600 120]/120; assert(isequal(round(genLaguerrePoly(n,a)*120),round(P_correct*120)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} ans = -0.0012 0.0488 -0.6548 3.2786 -5.0000 1.0000

Assertion failed.

8   Fail
n = 6; a = 0; P_correct = [1 -36 450 -2400 5400 -4320 720]/720; assert(isequal(round(genLaguerrePoly(n,a)*720),round(P_correct*720)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} P = 1×7 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} {1×7 double} ans = 0.0001 -0.0083 0.1661 -1.4333 5.1536 -6.0000 1.0000

Assertion failed.

9   Pass
n = 0; a = 1; P_correct = [1]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = 1

10   Pass
n = 1; a = 1; P_correct = [-1 2]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = -1 2

11   Fail
n = 2; a = 1; P_correct = [1 -6 6]/2; assert(isequal(round(genLaguerrePoly(n,a)*2),round(P_correct*2)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} ans = 0.2500 -2.5000 3.0000

Assertion failed.

12   Fail
n = 3; a = 1; P_correct = [-1 12 -36 24]/6; assert(isequal(round(genLaguerrePoly(n,a)*6),round(P_correct*6)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} ans = -0.0500 1.0000 -4.6000 4.0000

Assertion failed.

13   Fail
n = 4; a = 1; P_correct = [1 -20 120 -240 120]/24; assert(isequal(round(genLaguerrePoly(n,a)*24),round(P_correct*24)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} ans = 0.0083 -0.2667 2.5167 -7.3667 5.0000

Assertion failed.

14   Fail
n = 5; a = 1; P_correct = [-1 30 -300 1200 -1800 720]/120; assert(isequal(round(genLaguerrePoly(n,a)*120),round(P_correct*120)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} ans = -0.0012 0.0548 -0.8429 5.0857 -10.8476 6.0000

Assertion failed.

15   Fail
n = 6; a = 1; P_correct = [1 -42 630 -4200 12600 -15120 5040]/720; assert(isequal(round(genLaguerrePoly(n,a)*720),round(P_correct*720)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} P = 1×7 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} {1×7 double} ans = 0.0001 -0.0092 0.2065 -2.0548 9.0107 -15.0786 7.0000

Assertion failed.

16   Pass
n = 0; a = 2; P_correct = [1]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = 1

17   Pass
n = 1; a = 2; P_correct = [-1 3]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = -1 3

18   Fail
n = 2; a = 2; P_correct = [1 -8 12]/2; assert(isequal(round(genLaguerrePoly(n,a)*2),round(P_correct*2)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} ans = 0.2500 -3.0000 5.5000

Assertion failed.

19   Fail
n = 3; a = 2; P_correct = [-1 15 -60 60]/6; assert(isequal(round(genLaguerrePoly(n,a)*6),round(P_correct*6)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} ans = -0.0500 1.1500 -6.5000 8.5000

Assertion failed.

20   Fail
n = 4; a = 2; P_correct = [1 -24 180 -480 360]/24; assert(isequal(round(genLaguerrePoly(n,a)*24),round(P_correct*24)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} ans = 0.0083 -0.3000 3.2833 -12.0000 12.0000

Assertion failed.

21   Fail
n = 5; a = 2; P_correct = [-1 35 -420 2100 -4200 2520]/120; assert(isequal(round(genLaguerrePoly(n,a)*120),round(P_correct*120)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} ans = -0.0012 0.0607 -1.0548 7.4357 -20.0000 16.0000

Assertion failed.

22   Fail
n = 6; a = 2; P_correct = [1 -48 840 -6720 25200 -40320 20160]/720; assert(isequal(round(genLaguerrePoly(n,a)*720),round(P_correct*720)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} P = 1×7 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} {1×7 double} ans = 0.0001 -0.0101 0.2515 -2.8333 14.6071 -31.0000 20.5000

Assertion failed.

23   Pass
n = 0; a = 3; P_correct = [1]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = 1

24   Pass
n = 1; a = 3; P_correct = [-1 4]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = -1 4

25   Fail
n = 2; a = 3; P_correct = [1 -10 20]/2; assert(isequal(round(genLaguerrePoly(n,a)*2),round(P_correct*2)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} ans = 0.2500 -3.5000 8.5000

Assertion failed.

26   Fail
n = 3; a = 3; P_correct = [-1 18 -90 120]/6; assert(isequal(round(genLaguerrePoly(n,a)*6),round(P_correct*6)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} ans = -0.0500 1.3000 -8.7000 14.8000

Assertion failed.

27   Fail
n = 4; a = 3; P_correct = [1 -28 252 -840 840]/24; assert(isequal(round(genLaguerrePoly(n,a)*24),round(P_correct*24)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} ans = 0.0083 -0.3333 4.1500 -18.1000 23.2000

Assertion failed.

28   Fail
n = 5; a = 3; P_correct = [-1 40 -560 3360 -8400 6720]/120; assert(isequal(round(genLaguerrePoly(n,a)*120),round(P_correct*120)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} ans = -0.0012 0.0667 -1.2905 10.4000 -33.5000 34.0000

Assertion failed.

29   Fail
n = 6; a = 3; P_correct = [1 -54 1080 -10080 45360 -90720 60480]/720; assert(isequal(round(genLaguerrePoly(n,a)*720),round(P_correct*720)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} P = 1×7 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} {1×7 double} ans = 0.0001 -0.0110 0.3009 -3.7869 22.4000 -57.0000 47.5000

Assertion failed.

30   Pass
n = 0; a = 4; P_correct = [1]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = 1

31   Pass
n = 1; a = 4; P_correct = [-1 5]/1; assert(isequal(round(genLaguerrePoly(n,a)*1),round(P_correct*1)));

ans = -1 5

32   Fail
n = 2; a = 4; P_correct = [1 -12 30]/2; assert(isequal(round(genLaguerrePoly(n,a)*2),round(P_correct*2)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} ans = 0.2500 -4.0000 12.0000

Assertion failed.

33   Fail
n = 3; a = 4; P_correct = [-1 21 -126 210]/6; assert(isequal(round(genLaguerrePoly(n,a)*6),round(P_correct*6)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} ans = -0.0500 1.4500 -11.2000 23.2000

Assertion failed.

34   Fail
n = 4; a = 4; P_correct = [1 -32 336 -1344 1680]/24; assert(isequal(round(genLaguerrePoly(n,a)*24),round(P_correct*24)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} ans = 0.0083 -0.3667 5.1167 -25.8667 40.0000

Assertion failed.

35   Fail
n = 5; a = 4; P_correct = [-1 45 -720 5040 -15120 15120]/120; assert(isequal(round(genLaguerrePoly(n,a)*120),round(P_correct*120)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} ans = -0.0012 0.0726 -1.5500 14.0500 -52.5333 64.0000

Assertion failed.

36   Fail
n = 6; a = 4; P_correct = [1 -60 1350 -14400 75600 -181440 151200]/720; assert(isequal(round(genLaguerrePoly(n,a)*720),round(P_correct*720)));

P = 1×3 cell array {[1]} {1×2 double} {1×3 double} P = 1×4 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} P = 1×5 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} P = 1×6 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} P = 1×7 cell array {[1]} {1×2 double} {1×3 double} {1×4 double} {1×5 double} {1×6 double} {1×7 double} ans = 0.0001 -0.0119 0.3548 -4.9333 32.9000 -97.2000 97.0000

Assertion failed.