# Help with debugging my code [closed]

In order to descrive the multifractal behaviour of a set, Baumann provides a code based on the functions Dq and Tau, given below.

       Dq[p_List, r_List] :=
Block[{l1, l2, listrg = {}},(*----length of the lists---*)
l1 = Length[p];
l2 = Length[r];
If[l1 == l2,(*----variation of q and determination of D_q---*)
Do[gl1 = Sum[p[[j]]^q r[[j]]^((q - 1) Dfractal), {j, 1, l1}] - 1;
result = FindRoot[gl1 == 0, {Dfractal, -3, 3}];
result = -Dfractal /. result;
(*----collect the results in a list---*)
AppendTo[listrg, {q, result}], {q, -10, 10, .101}], Print[" "];
Print[" Lengths of lists are different!"];
listrg = {}];
listrg]

(*----calculate Tau---*)
Tau[result_list] :=
Block[{l1, listtau = {}},(*----lengths of the lists---*)
l1 = Length[result];
(*---calcultate Tau---*)
Do[AppendTo[
listtau, {result[[k, 1]],
result[[k, 2]] (1 - result[[k, 1]])}], {k, 1, l1}];
listtau];

p = {2/5, 2/5, 1/5};
r = {1/3, 1/3, 1/3};
ListDq = Dq[p, r];
ListLinePlot[ListDq, AxesLabel -> {"q", "Dq"}]
listTau = Tau[listDq];
ListLinePlot[listTau, Joined -> {True, False},
AxesLabel -> {"q", "\[Tau]"}, Prolog -> Thickness[0.001]]


The code above provides the plot of Dq but gives problems on Tau. In particular, the following errors are given: Any ideas?

• list -> List? – Kuba Jan 17 '19 at 12:32
• As I undestood, I should try with Tau[result_List] := in instead of Tau[result_list] :=. Can it work? – Spook82 Jan 17 '19 at 12:40
• It does not work. Any other idea? – Spook82 Jan 18 '19 at 9:16
• "I does not work" - is meaningless. Please update the question with correct code, test example and explanation why it does not fit your expectations. – Kuba Jan 18 '19 at 9:19
• I want to say that the package gives me the following error: "ListLinePlot: PrivatelistTau is not a list of numbers or pairs of numbers'." It seems that there is an error in listTau. If you want to see the whole code, see mathematica.stackexchange.com/questions/188070/… – Spook82 Jan 19 '19 at 12:30

Two simple mistakes.

Tau[result_list] := should be Tau[result_List] :=

and

listTau = Tau[listDq]; should be listTau = Tau[ListDq];`

Mathematica is case-sensitive. You must be careful about capitalization in identifiers.

• Thanks a lot. It finally works!!! – Spook82 Jan 20 '19 at 19:23
• @Spook82. I'm glad you find my answer useful. Please consider accepting it. You can do that by clicking on the check mark that appears on the left of the answer below the down arrow. – m_goldberg Jan 20 '19 at 23:21
• Is it correct? You solved a big problem! – Spook82 Jan 21 '19 at 20:01
• @Spook82. Yes, your acceptance has been registered. – m_goldberg Jan 21 '19 at 21:49