GRAM-SCHMIDT FUNCTION IS NOT GIVING CORRECT VALUES

조회 수: 1 (최근 30일)
nikhil mahar
nikhil mahar 2021년 5월 8일
편집: nikhil mahar 2021년 5월 9일
Hello everyone,
I am trying to obtain equations of phi. I am getting wrong value of phi{3}. There is somthing wrong, which I am unable to figure out.
here is code:
clc
clear all;
initial_function=@(x,y)x.^2;
m=3;
for i=1:m;
r=floor(sqrt(i-1));
t=i-1-r.^2;
if t/2==0;
s=t/2;
fm{i}=@(x,y)(x.^r).*(y.^s)
else
s=(t-1)/2;
fm{i}=@(x,y)(x.^s).*(y.^r);
end
end
for i=1:1
phi{i}=@(x,y)fm{1}(x,y).*initial_function(x,y);
end
xmin=@(y) y;
syms x y;
for i=2:m
phi{i}=@(x,y)fm{i}(x,y).*phi{1}(x,y);
for j=1:i-1;
a{i}{j} = integral2(@(y,x)fm{i}(x,y).*phi{1}(x,y).*phi{j}(x,y),0,1,xmin,1)./integral2(@(y,x)phi{j}(x,y).*phi{j}(x,y),0,1,xmin,1);
phi{i}=@(x,y)phi{i}(x,y)-a{i}{j}.*phi{j}(x,y);
end
phi1{i}=phi{i}(x,y);
end
phi{1} and phi{2} are correct.
phi{3} which i am getting from matlab is: x^2*y - (29645651611899925216907*x^2)/81129638414606681695789005144064 - (4503599623397961*x^3)/9007199254740992
while correct phi{3} is: x^2*y- 3.328*10^(-3) - 0.504x^3.
I shall be very thankful if somone can help.

답변 (1개)

Scott MacKenzie
Scott MacKenzie 2021년 5월 8일
It would be helpful if you posted your code as MATLAB code, not question text.
  댓글 수: 2
Scott MacKenzie
Scott MacKenzie 2021년 5월 8일
You could have just done this in your original question: select the code and click the code button.
Not to worry. I just tried to execute the code, but it requires the Symbolic Math Toolbox, which I don't have. Hopefully, someone else will weight in and assist. Good luck.
nikhil mahar
nikhil mahar 2021년 5월 8일
편집: nikhil mahar 2021년 5월 8일
these are the functions(phi) which i am trying to get from first 2 formule.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by