Backslash "\" operator is slow for symbolic matrices with diagonal numeric matrices
Show older comments
Why is using the backslash "\" operator with a diagonal numeric matrix and a symbolic matrix slow?
In the following example we want to solve A*x = B. A is a diagonal numeric matrix and B is a symbolic matrix. Note that using inv(A)*B is much faster than A\B even though mathematically these statements are identical:
%Setup. A is type double, B is symbolic
syms x y z
I = eye(3);
B = [x;y;z];
B = B.^2 - 3;
%%Test A\B
tic
for i = 1:100
A = I*i;
A\B;
end
toc
%%Test inv(A)*B
tic
for i = 1:100
A = I*i;
inv(A)*B;
end
toc
Accepted Answer
More Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!