# Why does Table returns values but Plot doesn't plot them?

The Table function works fine and return a nice list of values

n = 200000200;
k = 2 n - 50200;
\[Mu] = 10200^-5;
\[Nu] = 10200^-5;
qhat = k/(2 n);

Table[Log[(
E^(4 n qhat s) (1 - qhat)^(-1 + 4 n \[Mu]) qhat^(-1 + 4 n \[Nu]))/
NIntegrate[
E^(4 n qhat s) (1 - qhat)^(-1 + 4 n \[Mu]) qhat^(-1 +
4 n \[Nu]), {qhat, 1/(4 n + 1), 1 - 1/(4 n + 1)},
MaxRecursion -> 12]], {s, 0, 1, 0.01}]


but the Plot function shows an empty plot.

Plot[Log[(
E^(4 n qhat s) (1 - qhat)^(-1 + 4 n \[Mu]) qhat^(-1 + 4 n \[Nu]))/
NIntegrate[
E^(4 n qhat s) (1 - qhat)^(-1 + 4 n \[Mu]) qhat^(-1 +
4 n \[Nu]), {qhat, 1/(4 n + 1), 1 - 1/(4 n + 1)},
MaxRecursion -> 12]], {s, 0, 1}, AxesLabel -> {"s", "P(qhat | s)"}, PlotRange -> All]


Why?

• what version are you running? It works fine on the latest sources. – rcollyer Jan 21 '15 at 18:02
• Version 10.0.1.0 (Mac OSX). I tried to restart the Kernel and to restart Mathematica but it still does not work. Can you really see the function on the plot? Note that other plots work fine for me. For example Plot[2 x^2, {x, 0, 1}] works fine. – Remi.b Jan 21 '15 at 18:04

as I can see the problem is that in NIntegrate s is localised. define a function for your expression

f[s_] := Log[(E^(4 n qhat s) (1 - qhat)^(-1 + 4 n \[Mu]) qhat^(-1 +
4 n \[Nu]))/NIntegrate[E^(4 n qhat s) (1 - qhat)^(-1 + 4 n \[Mu]) qhat^(-1 +
4 n \[Nu]), {qhat, 1/(4 n + 1), 1 - 1/(4 n + 1)}, MaxRecursion -> 12]]


and then the plot works normally

Plot[f[s], {s, 0, 1}, AxesLabel -> {"s", "P(qhat | s)"}, PlotRange -> All]

• It is the solution indeed! Thanks. +1. Can you tell me a bit more of why this happens? Why is s localized in the Plot case but not in the Table case? And what does it exactly mean? Does it mean that in the Plot case shas no value associated to it in the NIntegrate function? Why does it work using a function? – Remi.b Jan 21 '15 at 18:15
• I just can suppose that it happens becouse of NIntegrate can't process undefined variables like "s". It contributes all the vars to be numerically defined or to be integrating parameters. If you try to evaluate NIntegrate expression separately you will see the message of non-numerick evaluation – k_v Jan 21 '15 at 18:32
• the difference between Table and Plot looks like Table firstly defines the list of "s" values and then calculates expression on this list, but Plot works inside some another way – k_v Jan 21 '15 at 18:39