using polyval(a,x)

2 views (last 30 days)
Dwyane  Wade
Dwyane Wade on 15 Aug 2011
Hi guys please help me I cant seem to figure out how to use polyval(a,x), I need to use it to solve the following problem:
1.) Confirm that 6x^3+4x^2-5/12x^3-7x^2+3x+9=0.7108 when x=2;
please help me. thanks

Answers (2)

Sean de Wolski
Sean de Wolski on 15 Aug 2011
It doesn't
fzero(@(x)6*x^3+4*x^2-5/12*x^3-7*x^2+3*x+8.2892,pi)

Paulo Silva
Paulo Silva on 15 Aug 2011
%first way to find if the equality is correct
f=@(x) (-5/12+6)*x^3+(-7+4)*x^2+3*x+9;
f(2)
%second way
polyval([-5/12+6 -7+4 3 9],2)
%yet another way that only works if you have the symbolic toolbox
syms x
f=6*x^3+4*x^2-5/12*x^3-7*x^2+3*x+9;
subs(f,x,2)
every way gives the value 47.666666666666664 not 0.7108, so it's not confirmed, the assumption is wrong.
f=@(x) (-5/12+6)*x^3+(-7+4)*x^2+3*x+9;
ezplot(f,[0 4])
hold on
line(xlim,[0.7108 0.7108],'color',[1 0 0])
line([2 2],ylim,'color',[1 0 0])
plot(2,f(2),'o','linewidth',4,'markersize',10)
text(2,f(2),['\leftarrow' 'x=2 and y=' num2str(f(2))],'FontSize',18)
text(2,0.7108,['\leftarrow' 'x=2 and y=' '0.7108'],'FontSize',18)
  2 Comments
Sean de Wolski
Sean de Wolski on 15 Aug 2011
And ezplot makes a pretty picture to confirm:
ezplot(f)
Paulo Silva
Paulo Silva on 15 Aug 2011
yes it does :)

Sign in to comment.

Categories

Find more on Polynomials 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!