• 我最喜欢的 RNA 将在医疗领域发挥更重大的作用（不止是疫苗）。
• 如何让其他星球产生含氧且适宜人类生存的大气层是个研究方向，感觉还没准能成功呢。
• 人机接口这东西，最近还最好先关注一些肢体神经，饶了大脑吧。

$\begin{cases} y^{'}=f(x,y)\\ y(x_{0})=y_{0} \end{cases}$

$\begin{cases} y_{i+1}=y_{i}+hK_{1}\\ K_{1}=f(x_{i},y_{i}) \end{cases}$

$\begin{cases} y_{i+1}=y_{i}+\frac{h}{2}(K_{1}+K_{2})\\ K_{1}=f(x_{i},y_{i})\\ K_{2}=f(x_{i+1},y_{i}+hK_{1}) \end{cases}$

$\begin{cases} K_{1}=f(x,y)\\ K_{2}=f(x_{i+\frac{1}{2}},y_{i}+\frac{h}{2}K_{1})\\ K_{3}=f(x_{i+\frac{1}{2}},y_{i}+\frac{h}{2}K_{2})\\ K_{4}=f(x_{i+1},y_{i}+hK_{3})\\ y_{i+1}=y_{i}+\frac{h}{6}(K_{1}+2K_{2}+2K_{3}+K_{4}) \end{cases}$

#include"stdio.h"
#include"stdlib.h"
void fun1(double a,double b,double h)
{  double x,y=0,i,k1,k2,k3,k4;
for(i=1;i<=((b-a)/h)+1;i++)
{ x=i*h;
k1=h*(1-y);
k2=h*(1-(y+1/2.0*k1));
k3=h*(1-(y+1/2.0*k2));
k4=h*(1-(y+k3));
y=y+1/6.0*(k1+2*k2+2*k3+k4);
}
printf("%lf\n",y);
}

void fun2(double a,double b,double h)
{  double x,y=1,i,k1,k2,k3,k4;
for(i=0;i<=((b-a)/h);i++)
{ x=i*h;
k1=h*(x*y*y);
k2=h*((x+h/2)*(y+1/2.0*k1)*(y+1/2.0*k1));
k3=h*((x+h/2)*(y+1/2.0*k2)*(y+1/2.0*k2));
k4=h*((x+h)*(y+k3)*(y+k3));
y=y+1/6.0*(k1+2*k2+2*k3+k4);
}
printf("%lf\n",y);
}

int main()
{double a=0,b=1,h=0.1;
fun1(a,b,h);
fun2(a,b,h);
}


## 1. 雅克比(Jacobi)迭代法求方程组的根

$\displaystyle A={\begin{bmatrix}a_{11}a_{12}\cdots a_{1n}\\a_{21}a_{22}\cdots a_{2n}\\\vdots \vdots \ddots \vdots \\a_{n1}a_{n2}\cdots a_{nn}\end{bmatrix}},\qquad \mathbf {x} ={\begin{bmatrix}x_{1}\\x_{2}\\\vdots \\x_{n}\end{bmatrix}},\qquad \mathbf {b} ={\begin{bmatrix}b_{1}\\b_{2}\\\vdots \\b_{n}\end{bmatrix}}.$

$\displaystyle A=D+R\qquad \qquad D={\begin{bmatrix}a_{11}0\cdots 0\\0a_{22}\cdots 0\\\vdots \vdots \ddots \vdots \\00\cdots a_{nn}\end{bmatrix}},\qquad R={\begin{bmatrix}0a_{12}\cdots a_{1n}\\a_{21}0\cdots a_{2n}\\\vdots \vdots \ddots \vdots \\a_{n1}a_{n2}\cdots 0\end{bmatrix}}$

#include"math.h"
#include"stdio.h"
#include"stdlib.h"
void main()
{
double x1,x2,x3,x11,x22,x33;
int i=0;
printf("No.0008雅克比迭代法求方程组的根\n\n输入初值：");
scanf("%lf %lf %lf",&x1,&x2,&x3);
while(fabs(x11-(1-x2-x3)/(-8.0))>0.001 && fabs(x22-(16-x1-x3)/(-5.0))>0.001 && fabs(x33-(7-x1-x2)/(-4.0))>0.001)
{
x11=(1-x2-x3)/(-8.0);//写迭代式
x22=(16-x1-x3)/(-5.0);//写迭代式
x33=(7-x1-x2)/(-4.0);//写迭代式
x1=x11;
x2=x22;
x3=x33;
i++;
}
printf("解为：\nx1=%lf\nx2=%lf \nx3=%lf\n迭代次数：%d\n",x1,x2,x3,i);
system("pause");
}



## 2. 高斯-赛德尔(Gauss-Seidel)迭代法求方程组的根

$\displaystyle A=L_{*}+U\qquad {\text{其中}}\qquad L_{*}={\begin{bmatrix}a_{11}0\cdots 0\\a_{21}a_{22}\cdots 0\\\vdots \vdots \ddots \vdots \\a_{n1}a_{n2}\cdots a_{nn}\end{bmatrix}},\quad U={\begin{bmatrix}0a_{12}\cdots a_{1n}\\00\cdots a_{2n}\\\vdots \vdots \ddots \vdots \\00\cdots 0\end{bmatrix}}$

$\displaystyle L_{*}\mathbf {x} =\mathbf {b} -U\mathbf {x}$ $\displaystyle \mathbf {x} ^{(k+1)}=L_{*}^{-1}(\mathbf {b} -U\mathbf {x} ^{(k)})$

#include"math.h"
#include"stdio.h"
#include"stdlib.h"
main()
{
double x1,x2,x3,x11,x22,x33;
int i=0;
printf("No.0009高斯赛德尔(Gauss-Seidel)迭代法求方程组的根\n\n输入初值：");
scanf("%lf %lf %lf",&x1,&x2,&x3);
while(fabs(x11-(1-x2-x3)/(-8.0))>0.01 && fabs(x22-(16-x1-x3)/(-5.0))>0.01 && fabs(x33-(7-x1-x2)/(-4.0))>0.01)
{
x11=x1;x22=x2;x33=x3;
x1=(1-x2-x3)/(-8.0);//写迭代式
x2=(16-x1-x3)/(-5.0);//写迭代式
x3=(7-x1-x2)/(-4.0);//写迭代式
i++;
}
printf("解为：\nx1=%lf\nx2=%lf \nx3=%lf\n迭代次数：%d\n",x1,x2,x3,i);
system("pause");
}


## 3. 牛顿迭代法求方程组的根

$\displaystyle x_{n+1}=x_{n}-J_{F}(x_{n})^{-1}F(x_{n})$

#include"math.h"
#include"stdio.h"
#include"stdlib.h"
main()
{
double x1,x2,x11,x22;
int i=0;
printf("No.0010牛顿迭代法求方程组的根\n\n输入初值：");
scanf("%lf %lf",&x1,&x2);
x11=x1-(2*x2/(2*x2-8*x1)*(x1+2*x2-3)-2/(2*x2-8*x1)*(2*x1*x1+x2*x2-5));//写迭代式
x22=x2-(-4*x1/(2*x2-8*x1)*(x1+2*x2-3)+1/(2*x2-8*x1)*(2*x1*x1+x2*x2-5));
i++;//写迭代式
while(fabs(x11-x1)>0.001 && fabs(x22-x2)>0.001)
{ x1=x11;
x2=x22;
x11=x1-(2*x2/(2*x2-8*x1)*(x1+2*x2-3)-2/(2*x2-8*x1)*(2*x1*x1+x2*x2-5));//写迭代式
x22=x2-(-4*x1/(2*x2-8*x1)*(x1+2*x2-3)+1/(2*x2-8*x1)*(2*x1*x1+x2*x2-5));//写迭代式
i++;
}
printf("解为：\nx1=%lf\nx2=%lf \n迭代次数：%d\n",x11,x22,i);
system("pause");
}


## 1. 二分法求方程的根

#include"math.h"
#include"stdio.h"
#include"stdlib.h"
double fun(double k)
{return 1-k-sin(k);//所求方程
}
void main()
{double a,b,x;int i=0;
printf("No.0004二分法求方程的根\n\n输入区间左端点：");
scanf("%lf",&a);
printf("输入区间右端点：");
scanf("%lf",&b);
x=(a+b)/2.0;
while(/*fabs(fun(x))>0.00005||*/fabs(a-b)>0.00005)//近似范围
{
if(fun(a)*fun(x)<0) b=x;
if(fun(b)*fun(x)<0) a=x;
x=(a+b)/2.0;
i++;}
printf("方程的根：%lf\n",x);
printf("迭代次数：%d\n\n",i);
system("pause");
}


## 2. 迭代法求方程的根

#include"math.h"
#include"stdio.h"
#include"stdlib.h"
double fun(double k)
{
return pow(1+k*k,1/3.0);//所求方程
}
void main()
{double a,b,x,x1,l=1;
int i=0,p;
printf("No.0005迭代法方程的根\n\n选择输入数据种类：\n1.数值\n2.区间\n");
printf("\n");
while(l==1)
{scanf("%d",&p);
if(p!=1&&p!=2) printf("请输入指定序号\n\n");//判断输入的序号是否正确
else l=0;
}
switch(p)
{
case 1:
printf("数据种类\n1.数值\n输入数值：");
scanf("%lf",&x);
x1=fun(x);i=i+1;
break;
case 2:printf("数据种类\n2.区间\n");
printf("输入区间左端点：");
scanf("%lf",&x);
printf("输入区间右端点：");
scanf("%lf",&x1);x1=fun((x+x1)/2.);i=i+1;
break;
}
while(fabs(x-x1)>0.00005)
{
x=fun(x1);
i=i+1;
x1=fun(x);
i=i+1;
}
printf("方程的根：%lf\n",x1);
printf("迭代次数：%d\n\n",i);
system("pause");
}


## 3.牛顿迭代法

$f(x_0)$点的切线是$f(x)$的线性逼近。离$f(x_0)$点距离越近，这种逼近的效果也就越好，也就是说，切线与曲线之间的误差越小。所以我们可以说在$f(x_0)$点附近，$切线\approx f(x)$。

#include"math.h"
#include"stdio.h"
#include"stdlib.h"
double fun(double k)
{
return k*k*k-k*k-1;//所求方程
}
double fun1(double k)
{
return 3*k*k-2*k;//所求方程的一阶导函数
}
void main()
{double a,b,x,x1,l=1;
int i=0,p;
printf("No.0006牛顿迭代法求方程的根\n\n选择输入数据种类：\n1.数值\n2.区间\n");
printf("\n");
while(l==1)
{scanf("%d",&p);
if(p!=1&&p!=2) printf("请输入指定序号\n\n");//判断输入的序号是否正确
else l=0;
}
switch(p)
{
case 1:
printf("数据种类\n1.数值\n输入数值：");
scanf("%lf",&x1);
break;
case 2:printf("数据种类\n2.区间\n");
printf("输入区间左端点：");
scanf("%lf",&x);
printf("输入区间右端点：");
scanf("%lf",&x1);x1=(x+x1)/2.;
break;
}
while(fabs(fun(x1)/fun1(x1))>0.00005)
{
x=x1-fun(x1)/fun1(x1);
x1=x;
i++;
}
printf("方程的根：%lf\n",x1);
printf("迭代次数：%d\n\n",i);
system("pause");
}


## 4. 弦割法

#include"math.h"
#include"stdio.h"
#include"stdlib.h"
double fun(double k)
{
return k*k*k-k*k-1;//所求方程
}
main()
{double a,b,x,x1,l=1,x0,x2;
int i=0,p;
printf("No.0007弦割法求方程的根\n\n选择输入种类：\n1.单点\n2.双点\n");
printf("\n");
while(l==1)
{scanf("%d",&p);
if(p!=1&&p!=2) printf("请输入指定序号\n\n");//判断输入的序号是否正确
else l=0;
}
switch(p)
{
case 1:
printf("种类\n1.单点\n");
printf("输入点1：");
scanf("%lf",&x);
printf("输入点2：");
scanf("%lf",&x1);
while(fabs(fun(x1)*(x1-x)/(fun(x1)-fun(x)))>0.00005)
{
x2=x1-fun(x1)*(x1-x)/(fun(x1)-fun(x));
x1=x2;
i++;
}
printf("方程的根：%lf\n",x1);
printf("迭代次数：%d\n\n",i);
break;
case 2:printf("种类\n2.双点\n");
printf("输入点1：");
scanf("%lf",&x);
printf("输入点2：");
scanf("%lf",&x1);
while(fabs(fun(x1)*(x1-x)/(fun(x1)-fun(x)))>0.00005)
{
x2=x1-fun(x1)*(x1-x)/(fun(x1)-fun(x));
x=x1;
x1=x2;
i++;
}
printf("方程的根：%lf\n",x1);
printf("迭代次数：%d\n\n",i);
break;
}
system("pause");