GRAM-SCHMIDT FUNCTION IS NOT GIVING CORRECT VALUES
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Scott MacKenzie
le 8 Mai 2021
It would be helpful if you posted your code as MATLAB code, not question text.
2 commentaires
Scott MacKenzie
le 8 Mai 2021
You could have just done this in your original question: select the code and click the code button. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611670/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611670/image.jpeg)
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.
Voir également
Catégories
En savoir plus sur Number Theory dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!