Why is there so much symbolic computation in Matlab?

I have tested the Matlab symbolic toolbox. And wonder why it is so slow, even when just computed with symbolic numbers. To test this I wrote this

syms x

x = subs(x,1);
a = 1;

tic
for i=1:10000
    z_sym = x + 1;
end
toc

tic
for i=1:10000
    z_num = a + 1;
end
toc

      

The first cycle says Elapsed time is 4.358483 seconds.

, and the second - Elapsed time is 0.000029 seconds.

. I know that using the subs function gives me x = 1, but it still has a type sym

and I could convert it with cast to make things faster. But that's just the point.

Why does it take about 15000 times longer to compute a 1 + 1 character than a numeric one. What is slowing down Matlab?

+3


source to share





All Articles