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: symbolic variables + symbolic numerical manipulations?
Replies: 7   Last Post: Jun 14, 2013 4:23 AM

 Messages: [ Previous | Next ]
 Alan Weiss Posts: 1,430 Registered: 11/27/08
Re: symbolic variables + symbolic numerical manipulations?
Posted: Jun 12, 2013 8:24 AM

On 6/12/2013 4:44 AM, Uwe Brauer wrote:
> Hello
>
> I thought that when using symbolic variables, Matlab treats numbers,
> which are multiplied by this variables also in a "symbolic" way.
>
> Look at the following.
>
> A=[1/4, 1/4 - sqrt(3)/6;1/4 + sqrt(3)/6, 1/4 ]
> b=[1/2, 1/2]
>
>
> I=eye(2);
> e=ones(2,1);
> r= 1 + z*b*inv((I-z*A))*e;
>
> Now when doing the calculations by hand r should be:
> r= (1 + 0.5*z + 1/12*z.^2)./(1 - 0.5*z + 1/12*z.^2);
>
> Matlab gives me:
> (20282409603651670423947251286016
> +10141204801825835211973625643008*z +
> 1690200800304305672809963274929*z^2)/
> (20282409603651670423947251286016 -
> 10141204801825835211973625643008*z
> +1690200800304305672809963274929*z^2)
>
> So it seems that Matlab did the calculations with finite arithmetic in
> digital representation and later converts the result to fractions.
>
> There is no way that Matlab would do the calculations from the starts
> in fractions doing "symbolic" manipulations with numbers?
>
> thanks
>
> Uwe Brauer

It depends on how you make A. You probably did something like

A=sym([1/4, 1/4 - sqrt(3)/6;1/4 + sqrt(3)/6, 1/4 ]);

which gives

A =

[ 1/4, -174177321749703/4503599627370496]
[ 2425977135434951/4503599627370496, 1/4]

A = sym('[1/4,1/4 - sqrt(3)/6;1/4 + sqrt(3)/6, 1/4]');

which gives

A =

[ 1/4, 1/4 - 3^(1/2)/6]
[ 3^(1/2)/6 + 1/4, 1/4]

Then if you follow through with the rest of your calculations you get

r =

(z^2*(2*3^(1/2) + 3))/(2*(z^2 - 6*z + 12)) - (z^2*(2*3^(1/2) -
3))/(2*(z^2 - 6*z + 12)) - (3*z*(z - 4))/(z^2 - 6*z + 12) + 1

as you wanted.

Alan Weiss
MATLAB mathematical toolbox documentation

Date Subject Author
6/12/13 Uwe Brauer
6/12/13 Nasser Abbasi
6/12/13 Uwe Brauer
6/12/13 Alan Weiss
6/12/13 Uwe Brauer
6/12/13 Alan Weiss
6/13/13 Steven Lord
6/14/13 Uwe Brauer