Home > Archive > Matlab > August 2005 > definite integration
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
definite integration
|
|
|
| Hi,
I am just trying to figure out of the method of integration I found
is the correct and most efficient one. Here is how I do it:
lets say I need a definite inegral of e^x * sin(x) from 1 to 3.
syms x;
value = int((e^x)*sin(x),x,1,3);
ans = double(value);
This seems to have yielded the right answer before, but I am
currently having some problems with it and was wondering if there is
a better way of doing it.
Thanks
| |
|
| Ilya wrote:
>
>
> Hi,
> I am just trying to figure out of the method of integration I found
> is the correct and most efficient one. Here is how I do it:
>
> lets say I need a definite inegral of e^x * sin(x) from 1 to 3.
>
> syms x;
> value = int((e^x)*sin(x),x,1,3);
> ans = double(value);
>
> This seems to have yielded the right answer before, but I am
> currently having some problems with it and was wondering if there
> is
> a better way of doing it.
>
> Thanks
Now you are integrating using the symbolic toolbox.
The part using e^x will most likely generate an error since you
havenīt defined the variable e. I assume you meant to use the
exponential.
Matlab real strenght is numerical computing. To use one of the
numerical integration routines, try e.g. quad, see help quad.
Your specific integral in this post can be solved using quad &
anonymous functions, like this:
myfun = @(x) exp(x).*sin(x);
I1=quad(myfun,1,3)
To solve it using the symbolic toolbox, use:
I2 = double(int((exp^x)*sin(x),x,1,3))
HTH
PB
| |
| Nasser Abbasi 2005-08-31, 7:01 pm |
|
"Ilya" <theweremonkey@hotmail.com> wrote in message
news:ef12a1a.-1@webx.raydaftYaTP...
> Hi,
> I am just trying to figure out of the method of integration I found
> is the correct and most efficient one. Here is how I do it:
>
> lets say I need a definite inegral of e^x * sin(x) from 1 to 3.
>
> syms x;
> value = int((e^x)*sin(x),x,1,3);
> ans = double(value);
>
> This seems to have yielded the right answer before, but I am
> currently having some problems with it and was wondering if there is
> a better way of doing it.
>
> Thanks
>
as was alluded to by another poster, change e to exp:
[color=darkred]
value = int((exp(x))*sin(x),x,1,3);
ans = double(value)
ans =
10.9502
[color=darkred]
|
|
|
|
|