0

I have a little question.

Let me define the function:

f[k_]:=k

So 'k' in the argument of 'f' is a blank variable.

Is there a way to define a part of array as a blank variable like:

g[x[1]_]:=x[1]

Note that x[1] is not previously defined.

For example if I write:

g[x_[i_]]:=x[i]

and if I write g[x[1]] the output is

x[1]

and it is correct.

But if I define

h1[x_[i_]?NumericQ]:=NIntegrate[y,{y,0,x[i]}]

and now I evaluate

NIntegrate[h1[x[1]],{x[1],0,1}]

I obtain error messages like (I post a figure for a more clear visulization): enter image description here

Thanks for any tips and helps.

1 Answers1

0

If I understand what you are trying to do, observe that dummy variables can be anything, including indexed variables. To be concrete, if you define your h1 using "z":

h1[z_?NumericQ] := NIntegrate[y, {y, 0, z}];
y[k] := k^2;

Then for defined y, you can write:

NIntegrate[h1[x[i]], {x[i], 0, 1}]

and it returns a numerical value. Here the dummy variable "x[i]" in the NIntegrate is playing the role of "z" in the function definition.

bill s
  • 68,936
  • 4
  • 101
  • 191