3 deleted 60 characters in body; edited tags; edited title

# Define a function of a function of an arbitrary variable

I want to define a function called int that takes another function as an argument and yields an integral of that function from 0 to 1 (just for example).

So I tried:

int[f_]:= NIntegrate[f[x],{x,0,1}]


This now works like this:

int[Cos]
0.841471


Oror

int[Sin]
0.459698


However, if I want a specific function, like x Sin[E^x], I need to write this:

int[# Sin[Exp[#]]&]
0.411229


How do I define the function int so that it will work like

int[x Sin[Exp[x]]


or

int[t Sin[Exp[t]]


with any letter as an argument and yieldsyield the result? I can't wrap my head around it...

I tried also this:

int[f_[x_]] := NIntegrate[f[x], {x, 0, 1}]


While int[Sin[t]] yields the correct result, int[t Sin[t]] just returns int[t Sin[t]]. I am still missing something here.

# Define function of function

I want to define a function called int that takes another function as an argument and yields an integral of that function from 0 to 1 (just for example).

So I tried:

int[f_]:= NIntegrate[f[x],{x,0,1}]


This now works like this:

int[Cos]
0.841471


Or

int[Sin]
0.459698


However, if I want a specific function, like x Sin[E^x] I need to write this:

int[# Sin[Exp[#]]&]
0.411229


How do I define function int so that it will work like

int[x Sin[Exp[x]]


or

int[t Sin[Exp[t]]


with any letter as an argument and yields the result? I can't wrap my head around it...

I tried this:

int[f_[x_]] := NIntegrate[f[x], {x, 0, 1}]


While int[Sin[t]] yields the correct result, int[t Sin[t]] just returns int[t Sin[t]]. I am still missing something here.

# Define a function of a function of an arbitrary variable

I want to define a function called int that takes another function as an argument and yields an integral of that function from 0 to 1 (just for example).

So I tried:

int[f_]:= NIntegrate[f[x],{x,0,1}]


This now works like this:

int[Cos]
0.841471


or

int[Sin]
0.459698


However, if I want a specific function, like x Sin[E^x], I need to write this:

int[# Sin[Exp[#]]&]
0.411229


How do I define the function int so that it will work like

int[x Sin[Exp[x]]


or

int[t Sin[Exp[t]]


with any letter as an argument and yield the result?

I tried also this:

int[f_[x_]] := NIntegrate[f[x], {x, 0, 1}]


While int[Sin[t]] yields the correct result, int[t Sin[t]] just returns int[t Sin[t]].

2 deleted 33 characters in body

I want to do the following thing: I want to define a function called int that takes another function as an argument and yields an integral of that function from 0 to 1 (just for example).

So I tried:

int[f_]:=NIntegrate[f[x]= NIntegrate[f[x],{x,0,1}]


This now works like this:

int[Cos]
0.841471


Or

int[Sin]
0.459698


However, if I want a specific function, like x Sin[E^x] I need to write this:

int[# Sin[Exp[#]]&]
0.411229


How do I define function int so that it will work like

int[x Sin[Exp[x]]


or

int[t Sin[Exp[t]]


with any letter as an argument and yields the result? I can't wrap my head around it...

I tried this:

int[f_[x_]] := NIntegrate[f[x], {x, 0, 1}]


While int[Sin[t]] yields the correct result, int[t Sin[t]] just returns int[t Sin[t]]. I am still missing something here.

I want to do the following thing: I want to define a function called int that takes another function as an argument and yields an integral of that function from 0 to 1 (just for example).

So I tried:

int[f_]:=NIntegrate[f[x],{x,0,1}]


This now works like this:

int[Cos]
0.841471


Or

int[Sin]
0.459698


However, if I want a specific function, like x Sin[E^x] I need to write this:

int[# Sin[Exp[#]]&]
0.411229


How do I define function int so that it will work like

int[x Sin[Exp[x]]


or

int[t Sin[Exp[t]]


with any letter as an argument and yields the result? I can't wrap my head around it...

I tried this:

int[f_[x_]] := NIntegrate[f[x], {x, 0, 1}]


While int[Sin[t]] yields the correct result, int[t Sin[t]] just returns int[t Sin[t]]. I am still missing something here.

I want to define a function called int that takes another function as an argument and yields an integral of that function from 0 to 1 (just for example).

So I tried:

int[f_]:= NIntegrate[f[x],{x,0,1}]


This now works like this:

int[Cos]
0.841471


Or

int[Sin]
0.459698


However, if I want a specific function, like x Sin[E^x] I need to write this:

int[# Sin[Exp[#]]&]
0.411229


How do I define function int so that it will work like

int[x Sin[Exp[x]]


or

int[t Sin[Exp[t]]


with any letter as an argument and yields the result? I can't wrap my head around it...

I tried this:

int[f_[x_]] := NIntegrate[f[x], {x, 0, 1}]


While int[Sin[t]] yields the correct result, int[t Sin[t]] just returns int[t Sin[t]]. I am still missing something here.

1

# Define function of function

I want to do the following thing: I want to define a function called int that takes another function as an argument and yields an integral of that function from 0 to 1 (just for example).

So I tried:

int[f_]:=NIntegrate[f[x],{x,0,1}]


This now works like this:

int[Cos]
0.841471


Or

int[Sin]
0.459698


However, if I want a specific function, like x Sin[E^x] I need to write this:

int[# Sin[Exp[#]]&]
0.411229


How do I define function int so that it will work like

int[x Sin[Exp[x]]


or

int[t Sin[Exp[t]]


with any letter as an argument and yields the result? I can't wrap my head around it...

I tried this:

int[f_[x_]] := NIntegrate[f[x], {x, 0, 1}]


While int[Sin[t]] yields the correct result, int[t Sin[t]] just returns int[t Sin[t]]. I am still missing something here.