Search code examples
recursionwolfram-mathematicamathematical-expressions

SetDelayed::Write ... is protected in module for recursively declared function


The following code results in a SetDelayed::write: "Tag Beta in Beta[row_Integer,col_Integer] is Protected." output by Mathematica. I cannot see the reason.

Is the function definition I chose appropriate for the three different and recursively declared cases for 'b' or is it the reason for the error?

Beta[row_Integer, col_Integer] := Module[
    {l1, l2},
    l1 = -1;
    l2 = 2;

    b[m_, r_] := Which[m == 0 && r == 0, 1,
                       m == 0 && r != 0, Sum[a[[k]]*Sum[b[0, s]*k^(r - s)*Binomial[r, s], {s, 0, r - 1}],{k, l1,l2}]/(2^(r + 1) - 2)
                       m != 0 && r != 0, Sum[Binomial[r, i]*m^i*b[0, r - i], {i, 0, r}]];
    b[row,col]
];

Solution

  • There is a builtin function named Beta.

    Try calling your function Bet and see if it works.