www.kluid.comKluid Home | Contact Us  | FAQFAQ    | SearchSearch | DownloadAttachment Manager  | Private messagesPrivate messages  | RegisterRegister  | Log inLog in   
Kluid Forum Index
Forum for Computational Languages & Techniques
 
 Please help us to develop!

Calendar
a problem to solve

 
Post new topic   Reply to topic       Kluid Forum Index -> Octave : Problems & Solutions
Author Message
thandu3
----
----


Joined: 20 Oct 2008
Posts: 2
Feedback Score: 0


Medals: None

PostPosted: Mon Oct 20, 2008 10:35 pm    Post subject: a problem to solve Reply with quote

hi i have a porgraming project.the porblem is
"let agm(a,b) indicate the arithmetic-geometric mean of a and b.
1) plot the solution of agm(a,b)=1.
2) how can we use the result of part 1) to graph agm(a,b)=k for a given k>0?"

arithmatic mean=(a+b)/2 and geometric mean=(a*b)^(1/2). there is a program that calculate the arithmatic-geometric mean.that is

function[i,p,q]=agm(x,y)
format long
fprintf('i p q\n\n')
for i=1:50
p=(x+y)/2;
q=((x*y))^(1/2);
x=p;
y=q;
fprintf('%d %2.14f %2.14f\n',i,p,q)
if (abs(p-q)<10^(-14)),break,end
end
fprintf('\nthe agm is = %2.14f\n',q)
end

if we calculate the program then we will find once that both p and q are equal.then we will call any of the value of p or q as the agm of p and q.
but my program is to find the value of q for a given value of p such that both the arithmatic and the geomatric mean are equal.that mean if (a+b)/2=?? then (p*q)^(1/2)=?? that means the same value. like if we put a fixed value p=1 then for q=1 both (a+b)/2=1 and (p*q))^(1/2)=1.; that means for 1 value of p i will get only one value of q so that both arithmatic and geomatric mean will be equal.if we put p=2 then there is a certain value of q so that both arithmatic and geomatric mena mean have the same value(that is 1).
but if we dont know for a fixed value of p waht is the value of q for which both arithmatic and geomatric mean are equal then how will i calculate.there is 1 related program

function root=pro(a,b)
k=1;
for i=1:100
m=(a+b)/2;
if(agm(2,m)-1)*(agm(2,a)-1)<0
b=m;
else
a=m;
end
if abs(agm(2,m)-k)<10^(-10),break,end
end
fprintf('value is %4.7f\n',m)
end
combining these two program i need to calculate the pair of values of p
and q so that both p and q will give the same arithmatic and geomatric
value
summary: that mean the summary is to find those values of p and q
for those the arithmatic and geomatric mean will be same.and
then keep those values in an array.i dont need the values of
p and q that will give another value of agm that is not 1.how
it can be done? first program is to find agm.and the second program
is to find the pair which will giev the same arithmatic and geomatric
mean.
Back to top
Display posts from previous:   
Post new topic   Reply to topic       Kluid Forum Index -> Octave : Problems & Solutions All times are GMT - 12 Hours
Page 1 of 1

 


Kluid © 2006, Kluid Management      php.B.B © 2006
www.kluid.comKluid Home | FAQFAQ    | RegisterRegister  | Log inLog in