Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: integral that includes symbols
Replies: 4   Last Post: Aug 6, 2013 1:50 PM

 Messages: [ Previous | Next ]
 Alan Weiss Posts: 1,430 Registered: 11/27/08
Re: integral that includes symbols
Posted: Aug 6, 2013 1:50 PM

On 8/6/2013 10:21 AM, Torsten wrote:
> "Young " <ryuyr77@gmail.com> wrote in message
> <ktqvqm\$4lk\$1@newscl01ah.mathworks.com>...

>> "Torsten" wrote in message <ktqpcf\$ga0\$1@newscl01ah.mathworks.com>...
>> > "Young " <ryuyr77@gmail.com> wrote in message
>> <ktql9j\$6n2\$1@newscl01ah.mathworks.com>...
>> > > Hi
>> > > > > I have an equation: F=L*cos(theL). L is a constant. Integral
>> of F over zero to (1/2)pi should give L. But I could not make that
>> answer Please see below my code and help me how to fix this problem.
>> I have much more complex equation but simplified my problem to this
>> example. > > > > syms L;

>> > > theL=[0+0.001:pi/1000:pi/2-0.001]
>> > > F=L*cos(theL);
>> > > trapz(theL,F)

>> > > > > ans:
>> (21828504695225120901251714223243*L)/162259276829213363391578010288128 +
>> (634496096455597832693*pi*L)/2305843009213693952000

>> > > If you know the explicit formula for the function you want to
>> integrate, then > for symbolic integration use MATLAB's "int", for
>> numerical integration use MATLAB's "quad".

>> > > Best wishes
>> > Torsten.
>>
>> Hi Torsten
>>
>> Thanks for your help! But it did not work... Please see below. It
>> looks "quad" does not allow to use sym... I need to use numerical
>> solution.
>> -------------------------------------------------------------------------------------
>>
>> syms L;
>> y=@(theL) (L*cos(theL));
>>
>> ans: Undefined function 'isfinite' for input arguments of type 'sym'.
>> Error in quad (line 79)
>> if ~isfinite(y(1))

>
> As I wrote above:
> If symbolic variables are involved, try "int", else use "quad".
> E.g.
>
> L=1;
> y=@(theL) (L*cos(theL));
>
> should work as well as
>
> syms L,theL;
> int(L*cos(theL),theL);
>
> Best wishes
> Torsten.

Just correcting a small typo:

syms L theL % no comma in between
wt = int(L*cos(theL),theL)
or
wt = int(L*cos(theL),theL,0,pi/2)

Alan Weiss
MATLAB mathematical toolbox documentation

Date Subject Author
8/6/13 Young Ryu
8/6/13 Torsten
8/6/13 Young Ryu
8/6/13 Torsten
8/6/13 Alan Weiss