⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 solution_diophantine.m

📁 这是我用matlab编写的一个解不定方程的程序
💻 M
字号:
%the programe is used to gain the solution of diophantine
function solution_diophantine(n);
l=n/3;
m=floor(2*sqrt(l/3));
num_solution=0;%be used to denote the number of solution
value_solution=ones(3,0);%denote the value of every solution
% value_solution(1,1)=0.11111;
% value_solution(2,1)=0.11111;
% value_solution(3,1)=0.11111;
if l==floor(l);
    for i=-m:1:m;
        temp=0;
        temp=-i/2+sqrt(l-(3*i^2)/4);
        if temp==floor(temp);
            num_solution=num_solution+1;
            k_0=l+temp;
            k_1=l+i;
            k_2=l-i/2-sqrt(l-(3*i^2)/4);
            value_solution(1,num_solution)=0;%the step is very importent;
            value_solution(1,num_solution)=k_0;
            value_solution(2,num_solution)=k_1;
            value_solution(3,num_solution)=k_2;
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        else 
        end
    end
else
    disp(sprintf('!!!!!!!!!!!!!!!!!!!!!!!the nature number can not be divided exactly by 3!!!!!!!!!!!!!!!!!!!!!!!'));
    num_solution=0;
end;
 num_solution
 value_solution

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -