# Nested function problem [closed]

I have trouble defining the following function in Mathematica

sp[M_, u_] := 1/Sum[u^k M!/(M - k)!, {k, 0, M}]


After defining it Mathematica displays an error. And in fact it prints a pair of values, but my application requires only one, i.e 2 argument function. As the result I need to plot this function in 3D with u changing from 0.01 to 1, and M changing 1 to 100. Any suggestions?

-

## closed as off-topic by Kuba, m_goldberg, Sjoerd C. de Vries, Pinguin Dirk, ArtesSep 13 '13 at 7:32

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

• "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." – Kuba, Artes
• "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Sjoerd C. de Vries, Pinguin Dirk
If this question can be reworded to fit the rules in the help center, please edit the question.

What error? It's possible you have some old definition of sp around, try ClearAll[sp] and see if it works. –  ssch Sep 12 '13 at 21:58

sp[m_, u_] := 1/Sum[u^k*(m!/(m - k)!), {k, 0, m}];
c = Table[sp[m, u], {m, 1, 100, 1}, {u, 0.01, 1, 0.01}];
ListPlot3D[c,
DataRange -> {{1, 100}, {0.1, 1}},
PlotRange -> All,
PlotRange -> All,
Boxed -> False,
AxesLabel -> {m, n, "sp"}]


Here is a version with Plot3D

Plot3D[sp[m, u], {m, 1, 100}, {u, 0.01, 1},
PlotRange -> All,

I used ListPlot3D also since I assumed the OP wanted only to sample the function at those specific points (0.01 for u and 1 increments for m) and it was easier to control those using Table. But whatever works for the OP.
You have a dislike for Plot3D? :) –  Pickett Sep 12 '13 at 22:02
Like so: Plot3D[sp[M, u], {M, 1, 100}, {u, 0.01, 1}, ColorFunction -> "Rainbow"] –  Pickett Sep 12 '13 at 22:02
@Anon add PlotRange->All :) –  Kuba Sep 12 '13 at 22:04
@Kuba That's it! Plot3D[sp[M, u], {M, 1, 100}, {u, 0.01, 1}, PlotRange -> All]. –  Pickett Sep 12 '13 at 22:09