MATLAB课后2.4实验练习

1、

function y=exam3(m,n,er)
syms x xk
a=m;b=n;k=0;
ff=x^5+sin(x)-1;
while b-a>er
    xk=(a+b)/2;
    fx=subs(ff,x,xk);
    fa=subs(ff,x,a);
    k=k+1;
    if fx==0
        y(k)=xk;
        break;
    elseif fa*fx<0
        b=xk;
    else
        a=xk;
    end
    y(k)=xk;
end
plot(y,'.-');
grid on
>> ab=exam3(0,1,1e-5);
>> vpa(ab,8)

3、

>> syms x
>> ff=x^3-2*x^2-5*x+12;
>> solve(ff)

4、

>> solve('exp(x)-2*x^2-1','x')

5、

>>  solve('x^4+x-16','x')

9、

function f=exam6(x)
f(1)=2*x(1)-x(2)-2*sin(x(1));
f(2)=x(1)+3*x(2)-cos(x(2));

10、

>> syms x
>> a=[1,5,-1,6,-5,8];
>> roots(a)

 

你可能感兴趣的:(MATLAB)