# Manipulate problem with long expression (wrong function definition?)

I have got a long expression called h, which I don't think is relevant to define here for the issue I have. Just know that it was defined through symbols, like

 h=C1*Sin[...]*Integrate[...] etc.


So my definition has no [x_] or := It seems to work well until here (I get the long expression for h in terms of the symbols) Then, what I would like to do is defining a function with all the undefined parameters that appear in h, that is, in my case:

h1[x_,alpha_,beta_,L_,Lc_]=h;


After that, I would like to make a Manipulate plot such as, for example:

Manipulate[
Plot[Re[h1[x, alpha, beta, L, Lc]], {x, 0.1, 1},
PlotLegends -> {"h(x)"}], {beta, 0, 1},{alpha, 0, 1},{L, 0, 1},{Lc, 0, 1}]


However, it doesnt work. Where are my mistakes?

## 1 Answer

Model your code on the following:

Block[{x, a, b}, h[x_, a_, b_] = a Sin[b x]];
Manipulate[
Plot[h[x, a, b], {x, 0, 10},
PlotRange -> {-1, 1}],
{a, -1, 1},
{b, π/4, 2 π, π/4}]


• What is the block function doing? I would like to remind you also that on the rhs of h[x_,a_,b_] I dont want to right the expression but to state simply h Is that allowed? – Andrea G Mar 27 '17 at 7:54
• I am getting \$Aborted or an empty Plot. I read somewhere else that this is due to long expressions inside Manipulate. Some sort of bug/crash? – Andrea G Mar 27 '17 at 9:07
• @AndreaG. Blockprotects the rhs of the definition from being contaminated by global definitions of x, a and b. Sorry but I can't answer the additional questions. The one about h being allowed make no sense. The one about your crashes/aborts can't be tested without knowing the expression you are using. – m_goldberg Mar 27 '17 at 13:38