# Change the definition of an interpolated function

I have a little question. I used the built in function 'NDEigensystem' to solve a differential equation; the results of this operation give me several functions; so I type in imput one of this like:

funcs[1][2][3]


and the output is the following:

To evaluate this x-dependent function, in a particular value of x, I have to use the following:

funcs[1][2][3]/.x->0.5


Is there a way to create a new function that has explicit x-dependence like:

newfuncs[1][2][3][x]


Thanks for any tips and helps!

There is my code that find the functions mentioned previously:

For[i = 0, i < passiL + 1, i++,For[j = 0, j < passiw + 1, j++,H:=(-Laplacian[#,{x}]+V[x, a, Lin + incrementoL i] #) &; {{energies[1][i][j],energies[2][i][j]},{funcs[1][i][j],funcs[2][i][j]}}=NDEigensystem[{H@\[Psi][x],DirichletCondition[\[Psi][x]==0,True]},\[Psi][x],{x,0,a+Lin+incrementoL i + win + incrementow j },dim,Method->{"SpatialDiscretization"->{"FiniteElement",\"MeshOptions" ->"MaxCellMeasure" -> 0.05}}},"Eigensystem" -> {"FEAST","Interval"->{0,a+Lin + incrementoL i + win + incrementow j }}}]]]


I don't think it is all necessary, but I post all of it.

• You mention that these functions come from NDEigensystem[]; you might only need to specify its second argument in the form {u} instead of {u[t, x]} to get what you want. (And if you want a more definite answer, you need to disclose the code that generates these functions of yours.) Dec 17, 2021 at 10:16
• Ok, I edit the question so you can see my code to evaluate that functions. Dec 17, 2021 at 10:19

I can't get your code to work due to missing brackets. However, if we pull an example out of Help we can work with an alternative.

ℒ = -Laplacian[u[x, y], {x, y}];
{vals, funs} =
NDEigensystem[ℒ,
u[x, y], {x, 0, π}, {y, 0, π}, 4];


Looking at one of the funs we see

funs[[4]]


Now to get something more usable which is what I think you want we can do

f4 = Head[funs[[4]]]


which strips off the square brackets at the end and gives

We now have a name for our interpolation function and we can put back the square brackets with the notation we need.

Plot3D[f4[x, y], {x, 0, π}, {y, 0, π}]


Does that help?

• Yes! It helps me! Thank you.Is there a difference between the interpolating function with '[x,y]' and without '[x,y]'? Dec 17, 2021 at 15:45
• What I was trying to say in the comments to @Lorenzo is that if you instead evaluate {vals, funs} = NDEigensystem[ℒ, u, {x, 0, π}, {y, 0, π}, 4];, you wouldn't need to fiddle with heads. Dec 17, 2021 at 16:10
• Yes, I understand it. My question is if there are differences between thath two type of interpolating functions. Dec 17, 2021 at 16:18
• No difference at all to the interpolation function.
– Hugh
Dec 17, 2021 at 16:29