解方程组:'x^2 + x*y + y = 3','x^2 - 4*x + 3 = 0'
[x,y] = solve('x^2 + x*y + y = 3','x^2 - 4*x + 3 = 0')
x =
1
3
y =
-3/2
>>
绘制参数方程:x=sin(p)+p;y=cos(p) 程序内容为:ezplot('x+sin(x)','cos(x)') 绘制成的图形为:
求一个二次方程的根:
>> clear
>> a[3.3,2,3,4,5];
a=[3,5.4,1];
>> x1=(-1*a(2)+sqrt(a(2)^2-4*a(1)*a(3)))/(2*a(1));x2=(-1*a(2)-sqrt(a(2)^2-4*a(1)*a(3)))/(2*a(1));
>> x1,x2
x1 =
x2 =
对于积分 ,数值对比说明舍入误差与算法的数值稳定性的关系。
>> clear
a(1)=0.6321;
for i=2:10
a(i)=1-(i-1)*a(i-1);
end
>> a
a =
Columns 1 through 9
0.6321 0.3679 0.2642 0.2074 0.1704 0.1480 0.1120 0.2160 -0.7280
Column 10
clear
a(10)=0.0684;
for i=9:-1:2
a(i)=(1-a(i+1))/i;
end
a(1)=0.6321;
>> a
a =
Columns 1 through 9
0.6321 0.3679 0.2642 0.2073 0.1709 0.1455 0.1268 0.1121 0.1035
Column 10
> E(1)=0.5*10^4;
>> for i=2:9
E(i)=-1*i*E(i-1);
end
>> E
E =
1.0e+009 *
Columns 1 through 8
0.0000 -0.0000 0.0000 -0.0001 0.0006 -0.0036 0.0252 -0.2016
Column 9
1.8144
>> E(10)=0.1-exp(-1)/10;
for i=9:-1:1
E(i)=-1/(i+1)*E(i+1);
end
>> E
E =
Columns 1 through 8
-0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0001 0.0007
Columns 9 through 10
更多回帖