is there any way to simplify a polynomial without using simplify from Symbolic Math Toolbox?

조회 수: 5 (최근 30일)
z=simplify(y)
set(handles.edit23,'String',inline(z))

채택된 답변

Walter Roberson
Walter Roberson 2017년 11월 7일
Yes. However, it is a lot of work. For example the code has to know details such as
sin(x)^3 + cos(x)*sin(x)*cos(x)
should simplify to sin(x)
I think you have forgotten, though, that your input is from the user, and the user is not restricted to entering polynomials.
  댓글 수: 2
Erwin Avendaño
Erwin Avendaño 2017년 11월 7일
How would it be? the user will have the restriction that only polynomials will be so x ^ 5, + x ^ 4 + 3x ^ 2 + 2x + 1 since my method only asks for points and (interpolation of newton) at the end my program prints the polynomial so it does not There will be problems that trigonometry will always be in the way I mentioned before the highest degree will be 5 what happens is that I use simplify because my polynomial is something like this 4 (x-1) +6 (x-1) (x-5) ) +9 (6-x) (1-x) (5-x)
Walter Roberson
Walter Roberson 2017년 11월 9일
How are you going to enforce that the user can only entry polynomials? You are reading a string from the user.
my polynomial is something like this 4 (x-1) +6 (x-1) (x-5) ) +9 (6-x) (1-x) (5-x)
That has an extra ")" in the middle of it, and is missing multiplication symbols. You are going to need to write a text parser to figure out what the user meant. With forms like that, you cannot even be immediately certain that the maximum degree is 5, since it would be legal for the user to enter a form in which higher order degrees cancelled out, such as the difference between two 6 degree polynomials.
simplify() is not even the correct operation for your purposes:
>> simplify((x+1)*(x+2))
ans =
(x + 1)*(x + 2)
what you want is expand()

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by