Using syms in Matlab R2010a

  • Follow


I am numerically integrating a function and I get the following. I am using it on 2 different versions of matlab. The code works fine in Matlab R2008a but shows this error on R2010a ... I look up on web but I cant find any solutions.

The variable y0 is predefined.
*********************************************
??? Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a
double array.

If the input expression contains a symbolic variable, use the VPA function
instead.

Error in ==> sym.sym>sym.double at 927
            Xstr = mupadmex('mllib::double', S.s, 0);

Error in ==> evalc_0_31_jan at 18
I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));

****************************************

Suggestions are appreciated.

Thanks
V
0
Reply VENU 1/31/2011 7:12:04 PM

On 11-01-31 01:12 PM, VENU wrote:
> I am numerically integrating a function and I get the following. I am using it
> on 2 different versions of matlab. The code works fine in Matlab R2008a but
> shows this error on R2010a ... I look up on web but I cant find any solutions.
>
> The variable y0 is predefined.
> *********************************************
> ??? Error using ==> mupadmex
> Error in MuPAD command: DOUBLE cannot convert the input expression into a
> double array.
>
> If the input expression contains a symbolic variable, use the VPA function
> instead.
>
> Error in ==> sym.sym>sym.double at 927
> Xstr = mupadmex('mllib::double', S.s, 0);
>
> Error in ==> evalc_0_31_jan at 18
> I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));

If you remove the I = double() layer and display the results of the double 
integration, what do you see output?

Would it not be safer in your two integration calls to specify the variable of 
integration?

0
Reply Think 1/31/2011 7:28:40 PM


"Think two, count blue." <roberson@hushmail.com> wrote in message <ii72hf$avv$1@nrc-news.nrc.ca>...
> On 11-01-31 01:12 PM, VENU wrote:
> > I am numerically integrating a function and I get the following. I am using it
> > on 2 different versions of matlab. The code works fine in Matlab R2008a but
> > shows this error on R2010a ... I look up on web but I cant find any solutions.
> >
> > The variable y0 is predefined.
> > *********************************************
> > ??? Error using ==> mupadmex
> > Error in MuPAD command: DOUBLE cannot convert the input expression into a
> > double array.
> >
> > If the input expression contains a symbolic variable, use the VPA function
> > instead.
> >
> > Error in ==> sym.sym>sym.double at 927
> > Xstr = mupadmex('mllib::double', S.s, 0);
> >
> > Error in ==> evalc_0_31_jan at 18
> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
> 
> If you remove the I = double() layer and display the results of the double 
> integration, what do you see output?
> 
> Would it not be safer in your two integration calls to specify the variable of 
> integration?

If I remove the double or use vpa instead of double, it wont evaluate the integral.
I tried specifying the variable and but it does not change anything.

Thanks
V
0
Reply VENU 1/31/2011 9:29:05 PM

On 11-01-31 03:29 PM, VENU wrote:
> "Think two, count blue." <roberson@hushmail.com> wrote in message
> <ii72hf$avv$1@nrc-news.nrc.ca>...
>> On 11-01-31 01:12 PM, VENU wrote:
>> > I am numerically integrating a function and I get the following. I am
>> using it
>> > on 2 different versions of matlab. The code works fine in Matlab R2008a but
>> > shows this error on R2010a ... I look up on web but I cant find any
>> solutions.
>> >
>> > The variable y0 is predefined.
>> > *********************************************
>> > ??? Error using ==> mupadmex
>> > Error in MuPAD command: DOUBLE cannot convert the input expression into a
>> > double array.
>> >
>> > If the input expression contains a symbolic variable, use the VPA function
>> > instead.
>> >
>> > Error in ==> sym.sym>sym.double at 927
>> > Xstr = mupadmex('mllib::double', S.s, 0);
>> >
>> > Error in ==> evalc_0_31_jan at 18
>> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
>>
>> If you remove the I = double() layer and display the results of the double
>> integration, what do you see output?
>>
>> Would it not be safer in your two integration calls to specify the variable
>> of integration?
>
> If I remove the double or use vpa instead of double, it wont evaluate the
> integral.
> I tried specifying the variable and but it does not change anything.

And is f(x,y,y0) defined? If not then the result of the double integration is 
going to be a symbolic expression in int() calls, and double() will not be 
able to force those expressions to evaluate.

Could you break it down to a specific example that works in R2008a but not in 
R2010a ?
0
Reply Think 1/31/2011 9:49:08 PM

"Think two, count blue." <roberson@hushmail.com> wrote in message <ii7aos$fcr$1@nrc-news.nrc.ca>...
> On 11-01-31 03:29 PM, VENU wrote:
> > "Think two, count blue." <roberson@hushmail.com> wrote in message
> > <ii72hf$avv$1@nrc-news.nrc.ca>...
> >> On 11-01-31 01:12 PM, VENU wrote:
> >> > I am numerically integrating a function and I get the following. I am
> >> using it
> >> > on 2 different versions of matlab. The code works fine in Matlab R2008a but
> >> > shows this error on R2010a ... I look up on web but I cant find any
> >> solutions.
> >> >
> >> > The variable y0 is predefined.
> >> > *********************************************
> >> > ??? Error using ==> mupadmex
> >> > Error in MuPAD command: DOUBLE cannot convert the input expression into a
> >> > double array.
> >> >
> >> > If the input expression contains a symbolic variable, use the VPA function
> >> > instead.
> >> >
> >> > Error in ==> sym.sym>sym.double at 927
> >> > Xstr = mupadmex('mllib::double', S.s, 0);
> >> >
> >> > Error in ==> evalc_0_31_jan at 18
> >> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
> >>
> >> If you remove the I = double() layer and display the results of the double
> >> integration, what do you see output?
> >>
> >> Would it not be safer in your two integration calls to specify the variable
> >> of integration?
> >
> > If I remove the double or use vpa instead of double, it wont evaluate the
> > integral.
> > I tried specifying the variable and but it does not change anything.
> 
> And is f(x,y,y0) defined? If not then the result of the double integration is 
> going to be a symbolic expression in int() calls, and double() will not be 
> able to force those expressions to evaluate.
> 
> Could you break it down to a specific example that works in R2008a but not in 
> R2010a ?

The function blows up at a point ... Here is an example where y0=0.5

*******************************************
f=inline('log((x).^2 + (y-0.5).^2)+ log ((y/2-1).^2 + (x/2).^2 )');
I=double(int(int(f(x,y),0,sqrt(1-y.^2)),-1,1))
*****************************************************

It works in the older version and I get I = -1.1781 but not it the new one.

Thanks
V
0
Reply VENU 2/1/2011 1:47:03 AM

On 31/01/11 7:47 PM, VENU wrote:

>> >> > ??? Error using ==> mupadmex
>> >> > Error in MuPAD command: DOUBLE cannot convert the input
>> expression into a
>> >> > double array.

>> >> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));

> The function blows up at a point ... Here is an example where y0=0.5
> *******************************************
> f=inline('log((x).^2 + (y-0.5).^2)+ log ((y/2-1).^2 + (x/2).^2 )');
> I=double(int(int(f(x,y),0,sqrt(1-y.^2)),-1,1))
> *****************************************************

When I transcribe this over to a new version of Maple, removing the 
periods (Maple does not have a .^ operator), and not using "inline", I 
encounter unexpected output from the first integration. The space after 
the "log" throws Maple off, causing it to treat "log" as a constant to 
be multiplied by the following term. When I remove that space that 
problem does not occur. This should not be an issue with your use of 
Matlab and inline().

Note, though, that when you use inline, the order of the arguments the 
inline function will expect is not necessarily going to be obvious: 
there is an algorithm that looks at the symbol names to determine the 
order of the arguments.


Maple is not able to evaluate the integration without assistance, 
warning that,

Warning, unable to determine if (-1/4-y^2+y)^(1/2) is between 0 and 
(1-y^2)^(1/2); try to use assumptions or use the AllSolutions option
Warning, unable to determine if -(-1/4-y^2+y)^(1/2) is between 0 and 
(1-y^2)^(1/2); try to use assumptions or use the AllSolutions option

Adding the assumptions that x and y are real-valued is enough to get rid 
of the warnings, but not enough for Maple to be able to find a value for 
the integration.

Maple is, however, able to process the inner integration if one adds the 
assumption that y>=-1 and y<=1 . It is not then able to find a closed 
form for the outer integration, but it is able to evaluate the outer 
integration numerically.

I would thus suggest that in Matlab, you use assume() to add assumptions 
on y before you attempt to process the integrations.
0
Reply Think 2/1/2011 5:51:11 PM

Thanks a lot for the analysis. I tried what you suggested but I don't know if matlab has a assume real function. And I want to do it matlab to able to integrate it with my other matlab files.

Venu

"Think blue, count two." <roberson@hushmail.com> wrote in message <kKX1p.56924$Y8.41406@newsfe06.iad>...
> On 31/01/11 7:47 PM, VENU wrote:
> 
> >> >> > ??? Error using ==> mupadmex
> >> >> > Error in MuPAD command: DOUBLE cannot convert the input
> >> expression into a
> >> >> > double array.
> 
> >> >> > I=double(int(int(f(x,y,y0),0,sqrt(1-y.^2)),-1,1));
> 
> > The function blows up at a point ... Here is an example where y0=0.5
> > *******************************************
> > f=inline('log((x).^2 + (y-0.5).^2)+ log ((y/2-1).^2 + (x/2).^2 )');
> > I=double(int(int(f(x,y),0,sqrt(1-y.^2)),-1,1))
> > *****************************************************
> 
> When I transcribe this over to a new version of Maple, removing the 
> periods (Maple does not have a .^ operator), and not using "inline", I 
> encounter unexpected output from the first integration. The space after 
> the "log" throws Maple off, causing it to treat "log" as a constant to 
> be multiplied by the following term. When I remove that space that 
> problem does not occur. This should not be an issue with your use of 
> Matlab and inline().
> 
> Note, though, that when you use inline, the order of the arguments the 
> inline function will expect is not necessarily going to be obvious: 
> there is an algorithm that looks at the symbol names to determine the 
> order of the arguments.
> 
> 
> Maple is not able to evaluate the integration without assistance, 
> warning that,
> 
> Warning, unable to determine if (-1/4-y^2+y)^(1/2) is between 0 and 
> (1-y^2)^(1/2); try to use assumptions or use the AllSolutions option
> Warning, unable to determine if -(-1/4-y^2+y)^(1/2) is between 0 and 
> (1-y^2)^(1/2); try to use assumptions or use the AllSolutions option
> 
> Adding the assumptions that x and y are real-valued is enough to get rid 
> of the warnings, but not enough for Maple to be able to find a value for 
> the integration.
> 
> Maple is, however, able to process the inner integration if one adds the 
> assumption that y>=-1 and y<=1 . It is not then able to find a closed 
> form for the outer integration, but it is able to evaluate the outer 
> integration numerically.
> 
> I would thus suggest that in Matlab, you use assume() to add assumptions 
> on y before you attempt to process the integrations.
0
Reply VENU 2/3/2011 10:50:06 PM

"VENU " <venuiitg@gmail.com> wrote in message <iifbeu$nff$1@fred.mathworks.com>...
> Thanks a lot for the analysis. I tried what you suggested but I don't know if matlab has a assume real function. And I want to do it matlab to able to integrate it with my other matlab files.
> 
> Venu

syms y real
0
Reply proecsm 2/4/2011 11:27:04 PM

That does not work either. Anyway thanks for the sugesstions.

Venu

"proecsm" wrote in message <iii208$jej$1@fred.mathworks.com>...
> "VENU " <venuiitg@gmail.com> wrote in message <iifbeu$nff$1@fred.mathworks.com>...
> > Thanks a lot for the analysis. I tried what you suggested but I don't know if matlab has a assume real function. And I want to do it matlab to able to integrate it with my other matlab files.
> > 
> > Venu
> 
> syms y real
0
Reply VENU 2/8/2011 8:47:04 PM

8 Replies
745 Views

(page loaded in 0.102 seconds)

Similiar Articles:













7/21/2012 11:57:53 PM


Reply: