Simple squaring of expression

2 views (last 30 days)
It has been some time since I last used MatLab, and I can't remember how to solve this simple problem. Given the expression:
(1*a+2*b+3*c+4*d+5*e-8)^2
How do you return an answer that actually multiples out the expression and puts like terms together?
I wrote the attached code, but this only returns:
(a + 2*b + 3*c + 4*d + 5*e - 8)^2
syms a
syms b
syms c
syms d
syms e
(1*a+2*b+3*c+4*d+5*e-8)*(1*a+2*b+3*c+4*d+5*e-8)

Accepted Answer

David Goodmanson
David Goodmanson on 11 Jul 2019
HI Wesley,
syms a
syms b
syms c
syms d
syms e
f = expand((1*a+2*b+3*c+4*d+5*e-8)*(1*a+2*b+3*c+4*d+5*e-8))

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!