Question:
in matlab how do you solve this?
enhein
2007-06-21 23:47:15 UTC
divide 2*x^5-3*x^4-5*x^2+3*x-2 by 2*x^2+x-1


and
solve
16x^2+22x-15

and solve the system of linear equation
3x+2y=3
9x-8y=-2
Five answers:
сhееsеr1
2007-06-22 00:31:19 UTC
#1

Matlab is not a symbolic computing environment, and as such, you cannot "divide polynomials." But you're in luck: polynomials can be manipulated in Matlab as a vector of coefficients.



For example, the vector [1 0 1] is x^2 + 1. The vector [a b] is ax+b for any numbers a and b. I hope that explains it well enough. Multiplication of these vectors is called a convolution. Division is a deconvolution.



So the commands are:

p=[2 -3 0 -5 3 -2];

q=[2 1 -1];

[a b] = deconv(p,q);



Note that the first polynomial is not divisible by the second. The "whole" part is stored in the vector a, the remainder is left in the vector b. a represents a 4th degree polynomial, while b represents a linear one. The answer to the division is of the form a + b/q, like any other division-with-remainder problem.





#2

To solve the roots of a polynomial, there's a simple command.



p = [16 22 -15];

r = roots(p)



#3

Here we have to use a little bit of Matrix theory. Again, Matlab is not a symbolic computational environment, it's a numerical one. We make a coefficient matrix, a constant vector, and do the matrix division. Note that the constant vector is a column, as is the output vector X = [x ; y]



A = [3 2;9 -8];

b = [3; 2];

X = A\b



Note that you have to divide by A on the left (and use a backslash instead of a slash). For matrices, division and multiplication are not commutative, so be careful.





However, I will again note that this is not a symbolic computing environment, and for some of these things, you might find a symbolic environment (e.g. Mathematica) much easier. See: http://wolfram.com/ . In Mathematica, these problems would be much simpler and intuitive:



#1

(2*x^5-3*x^4-5*x^2+3*x-2) / (2*x^2+x-1)



#2

Solve[16x^2+22x-15==0]



#3

Solve[ {3x+2y == 3 , 9x-8y == -2} ]
?
2016-12-08 21:35:18 UTC
Matlab Polynomial Solver
2007-06-21 23:58:29 UTC
2*(x^5)-3*(x^4)-5*(x^2)+3*(x-2)



16*(x^2)+22*x-15



A=[3,2;9,8];B=[3;2]

A\B

for the last one pay attention to the commas and semicolons i have typed down. everything is right.matlab gives precedence to exponentials,then multiplication and division and rest addition and subtraction.

oops sorry, i didn't know u wanted to divide one polynomial by another. u cannot do that in matlab.
?
2016-05-17 12:19:08 UTC
you can't just use it as a constant..... you need to define it first . i mean before the program . then you can us eit throughout the program.... by the way which version you use???? i use matlab 6.5
Lady_Marmalade
2007-06-21 23:52:04 UTC
Go ask your math teacher for that!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...