2
$\begingroup$

The following quits with message $Failed and no other information on Mathematica 13.2 (also on cloud), are there any debugging tricks to find the source of the error?

d = 10; R2toSpectrum[R_, d_] := Module[{h, dd, decay}, decay = If[R < 1.001, 100., dd /. FindRoot[ HarmonicNumber[d, dd]^2/HarmonicNumber[d, 2 dd] == R, {dd, 2, 0, 100}]]; h = Table[i^-decay, {i, 1, d}]; h/Total[h] ]; rrPlot2[R_] := Plot[Max[R2toSpectrum[R, d]], {R, 1, d}] rrPlot2[5] 
$\endgroup$
2
  • 1
    $\begingroup$ rrPlot2[5] returns $Failed, so looking at the definition for rrPlot2[R_], we replace the instances of R with 5, and see what happens. Plot[Max[R2toSpectrum[5, d]], {5, 1, d}] returns $Failed. But that variable specification is weird. Did you mean to use rrPlot2[d_] := when defining the function? $\endgroup$ Commented Feb 9, 2023 at 20:01
  • $\begingroup$ Ah yes that was the problem. Wish that error message was more informative though, like " incorrect specification for plot" $\endgroup$ Commented Feb 9, 2023 at 23:01

1 Answer 1

1
$\begingroup$

To follow from Brett's suggestion:

rrPlot[d_] := ListLinePlot[Table[{i, Max[R2toSpectrum[i, d]]}, {i, 1, d}]]

rrPlot[10] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.