How do I integrate something like (x + y)
(or an expression with any number of variables) with respect to just one of the variables, let's say x
from 0
to 1
, and get a function of the other variable (1/2 + y
in this case) back?
If you mean symbolically, then use:
syms x y
f=int(x+y,x,0,1)
which gives
f =
y + 1/2
then get f(y=4)
from subs(f,4)
which gives
ans =
9/2
If you have more than two variables, use:
syms x y z
f=int(x+y+z,x,0,1)
which gives
f =
y + z + 1/2
then for f(y=4,z=5)
use subs(f,{y,z},[4,5])
gives
ans =
19/2