Nanjing University of Posts and Telecommunications Matlab Mathematics Experiment Report

foreword

Mathematical experiments are really annoying...

Adhering to the spirit of " the back waves of the Yangtze River beat the front waves, and the front waves are beaten to death on the beach ".

I hereby record the problem-solving process of the mathematical experiment report I wrote myself in the form of a blog, for future self.

For reference only, not necessarily right!

Please come to this blog after you think for yourself. After all, in the future, mathematical research will really use matlab (although I guess I forgot how to operate it at that time, which is why I wrote this blog)

There is a certain difference between the function usage of the old and new versions! The specific difference can be Baidu, or directly use the same version as mine

  • The version used for this blog ismatlab R2022a

practice one

Note: m has special requirements , please check your experimental report for details

1.1

IMG_20220408_105804

>> syms x
>> limit((sqrt(1+m*x^2)-cos(m*x))/x^2,x,0)

Note that the range is different, the first is 0, the second is close to ∞

syms x
limit((sqrt(1+m*x^2)-cos(m*x))/x,x,inf)

1.2

IMG_20220408_105843

The e here should actually be exp(1)used to indicate

image-20220408111613808

1.3

IMG_20220408_110021

>> syms x
>> f=exp(1)^(-m*x^2)
>> int(f,x,0,inf)

1.4

image-20220408111132874

>> syms x
>> f=(m/1000)+x
>> f1=power(f,1/3)
>> taylor(f1,x,0,'Order',5)
>> pretty(ans)

1.5

image-20220408111501248

image-20220408112657933

1.6

image-20220408111933112

image-20220408112608184

1.7

IMG_20220408_105940

M file

function f=func1(x)
f=x.*2.*(x>=0&x<=1/2)+(2*(1-x)).*(x>=1/2&x<=1);
end

drawing commands

 >> x=linspace(0,1);
 >> y=func1(x);
 >> plot(x,y);

Question (2) is not required

1.8

image-20220408112244059

(1)
>> t=-m/10:0.1:m/10;
>> x=(m/20)*cos(t);
>> y=(m/20)*sin(t);
>> z=t;
>> plot3(x,y,z)

(2)
>> t=-m/10:0.1:m/10;
>> x=cos(t)+t.*sin(t);
>> y=sin(t)-t.*cos(t);
>> z=-t;
>> plot3(x,y,z)

1.9

IMG_20220408_110036

>> a=[1000/m,500/m,400/m,100/m];
col=['r','b','k','g'];
x=linspace(-0.1,1,1000);
for i=1:4
y=0.*(x<=0)+(a(i)*exp(-a(i)*x)).*(x>0);
plot(x,y,'color',col(i),'linewidth',1)
hold on;
end
>> legend('1000','500','400','100')

1.10

IMG_20220408_113906

>> syms x y;
>> f=sin(x^2+(m/1000)*y^2)-cos(x*y);
>> ezplot('f',[-6,6,-8,8])

1.11

IMG_20220408_113925

>> fmesh(@(x,y) m.*x.^2+y.^4);

1.12

image-20220408151851822

Drawing code, which grid on;is to grid the drawn picture

fplot(@(x) exp(x)-((3*m)/(m+100))*x.^2);
grid on;

Approximate root command (fsolve or fzero)

f=@(x) exp(x)-((3*m)/(m+100))*x.^2;
x=[-1 0 2 4];
arrayfun(@(x) fzero(f,x),x)

The range of x is obtained by looking at the picture, and the zero range is in the three ranges of -1~0, 0~2, and2~4

image-20220408152113871


Exercise 2

2.1

IMG_20220408_113826

>>f=inline('(x+m/x)/2');
x0=-3;
for i=1:10;
x0=f(x0);
fprintf('%g,%12.8f\n',i,x0)
end;

Change the value of x0 to get another result, the number is the same, the sign is different

The result printed at the end is the same, Xnthat is, it converges to that value

2.2

IMG_20220408_113830

Question (1)

>> f=inline('(x-1)/(x+m)');
>> x0=1;
>> for i=1:10;
x0=f(x0);
fprintf('%g,%12.8f\n',i,x0);
end;

Question (2)

Because the range of x needs to be used when judging the iterative sequence with the spider web graph, the function pair of question (1) needs to be used f2(x)for calculation, and the range of x that is finally written should include the calculated f2(x)convergence value

If the calculated convergence value is 316.2343564, the last written range can be[250,350]

>>  f=inline('(x+m*m)/(x+m)');
x=[];
y=[];
x(1)=0.5;
y(1)=0;
x(2)=x(1);
y(2)=f(x(1));
for i=1:100
x(1+2*i)=y(2*i);
x(2+2*i)=x(1+2*i);
y(1+2*i)=x(1+2*i);
y(2+2*i)=f(x(2+2*i));
end;
plot(x,y,'r')
hold on
syms x;
ezplot(x,[250,500]);
ezplot(f(x),[250,500]);
axis([250,500,250,500]);
hold off

As a result, the following picture appears, indicating that the function is convergent

image-20220408160134776

2.3

IMG_20220408_113837

M file

function y=func2(x)
if x>=0&&x<=1/2
    y=2*x;
elseif x>=1/2&&x<=1
    y=2*(1-x);
end

command line code

x(1)=rand();
for i=1:20
x(1)=func2(x(1))
fprintf('%g,%g\n',i,x(1));
end

The result is a mess, so it's chaotic

2.4

IMG_20220408_161530

f=inline('a*x*(1-x)');
x0=0.5;
for i=1:100
plot(i,f(x0),'.')
x0=f(x0);
hold on
end

The a in the inline function should be replaced with a specific value , otherwise an error will be reported

a 2.8 3.4 3.6 3.84
Sequence Convergence convergence T=2 chaos T=3

cuckoo cuckoo

I found that some seniors have already shared the complete experimental report, so I will not write it!

portal

image-20220409131504284

come on! Come on!

Guess you like

Origin blog.csdn.net/muxuen/article/details/124042753