I have a Sturm-Liouville operator:
$$\mathcal{Ly(x)}=-\frac{\mathrm{d}}{\mathrm{d}x}\left(p(x)\frac{\mathrm{d}}{\mathrm{d}x}y(x)\right)-q(x)y(x)$$
but I do not yet know the parameter functions $p(x)$ and $q(x)$, nor the arbitrary function $y(x)$. I define the operator in Mathematica:
sl[x_]:=-D[p[x]*D[y[x],x],x]-q[x]*y[x]
What if now I want to specify what $p$, $q$ and $y$ should be? Let's say $p(x)=1$, $q(x)=1$ and $y(x)=\sin(x)$. I do:
res[x_]:=sl[x]/.{p[x]->1,q[x]->0}/.{y[x]->Sin[x]}
To check if this is correct and I can plot res, I do:
Plot[res[x],{x,0,Pi}]
I am getting an empty plot:
but I expected a $-\frac{\mathrm{d}^2}{\mathrm{d}^2x}\left(\sin(x)\right)=\sin(x)$ plot.
What am I doing wrong?
Seemingly reasonable another failed attempts:
1)
sl[p_, q_, y_,x_]:=-D[p[x]*D[y[x],x],x]-q[x]*y[x]
res[x_]:=sl[p[x], q[x], y[x], x]/.{p[x]->1,q[x]->0}/.{y[x]->Sin[x]}
Based on the Currying part of this answer:
sl[x_][p_,q_]:=-D[p[x]*D[y[x],x],x]-q[x]*y[x]
p[x_]:=1
q[x_]:=0
res[x_]:=sl[x][p, q]
Based on comments:
sl[x_]:=((-D[p[x]*D[y[x],x],x]-q[x]*y[x])/.{p[x]->1,q[x]->0})
res[x_]:=sl/.{y[x]->Sin[x]}
Specifying y as well in the first line:
sl[x_]:=((-D[p[x]*D[y[x],x],x]-q[x]*y[x])/.{p[x]->1,q[x]->0,y[x]->Sin[x]})
when plotting it (Plot[sl[x],{x,0,Pi}]), I still get errors and no plot.



res[x]for an unspecifiedx? Does the result help you explain the behavior? $\endgroup$-p'[x]y'[x]-y''[x], which suggests I think that I couldn't pass the value forpproperly for some reason, otherwise it would not be shown asp. $\endgroup$res:= ...according to this answer. Instead ofVariationalD[(a[x] - s[x])^2, s[x], x], I havesl[x]. Maybe the problem is that thepandqdependence is not explicitly statet in myresdefinition, trying to fix that... $\endgroup$resdefinitionsl[x]is evaluated before the substitution with/.happens, both whenxis a number and when it is a symbol. In my opinion it isslthat should takepandqas input functions, perhaps as pureFunctions? $\endgroup$