Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to do a LogLogPlot of the following function:

fun[t_, n_, ρ_, λ_, μ_] := (
    1 - NIntegrate[(E^(s*(-λ - μ))*BesselI[1, 2*s*Sqrt[λ*μ]])/(s*Sqrt[ρ]),
   {s, 0, t}]^(n))

Which works only when I use Plot. For example,

Manipulate[Plot[fun[t, j, 1/2, 0.5, 1], {t, 0, 50}, PlotRange -> {0, 1}],
           {{j, 0.5, "n"}, 1.0, 1000, Appearance -> "Labeled"}]

But when I try to do a LogLogPlot, which is done with this code,

Manipulate[LogLogPlot[fun[t, j, 1/2, 0.5, 1], {t, 0.0001, 50}, PlotRange -> {0, 1}],
           {{j, 0.5, "n"}, 1.0, 1000, Appearance -> "Labeled"}]

then things get crazy and Mathematica outputs a bunch of errors.

I'm not sure what I am doing wrong and any help with this matter would be much appreciated.

share|improve this question

closed as off-topic by m_goldberg, bobthechemist, Michael E2, Artes, Oleksandr R. Mar 3 at 7:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, bobthechemist, Michael E2, Artes, Oleksandr R.
If this question can be reworded to fit the rules in the help center, please edit the question.

Clear[fun];fun[t_?NumericQ, n_, \[Rho]_, \[Lambda]_, \[Mu]_] := .. –  george2079 Feb 27 at 19:01
I think you will get a better plot with LogPlot. –  m_goldberg Feb 27 at 21:00
Well then genius. What's the "error"??? LOL! You simply don't know the answer so you close it as "off-topic". LOL! –  Pierre M Fiorini Mar 16 at 17:07

1 Answer 1

up vote 0 down vote accepted

I suggest you tabulate and plot rather than using plot (as function is numerical rather than analytic/closed), e.g.

llp[j_] := Table[{t, fun[t, j, 1/2, 0.5, 1]}, {t, 0.0001, 50, 0.1}];
 ListLogLogPlot[llp[j], Joined -> True, PlotRange -> {0, 1}], {j, 1, 
  1000, Appearance -> "Labeled"}]

You can choose whatever increment suits your quality/speed trade-off:

enter image description here

share|improve this answer
Thanks - this seems the way to go even though this should work as I do this in MatLab all the time. –  Pierre M Fiorini Mar 2 at 16:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.