compute a geomtric series with matrices


by brad sue
Tags: compute, geomtric, matrices, series
brad sue
brad sue is offline
#1
Feb25-06, 02:29 PM
P: 284
Hi ,
I want to compute a geomtric series with matrices. I have the following functions:

add (matrix1,matix2)=function to add 2 matrices.
mult(matirx1,matrix2) =function to multiply two matrices.

I want to create this function in C that computes the following.

I(indentity matrix)

I+A+A^2+A^3+....A^k

I tried

sum=I;
for(i=0;i<k;i++)
{
intermediary=mult(I,A);
sum+=intermediary;
intermediary=mult(intermediary,A)
}


Am I right?
Please, What is wrong here?

Thank you for yout help
B
Phys.Org News Partner Science news on Phys.org
Going nuts? Turkey looks to pistachios to heat new eco-city
Space-tested fluid flow concept advances infectious disease diagnoses
SpaceX launches supplies to space station (Update)
TenaliRaman
TenaliRaman is offline
#2
Feb25-06, 03:10 PM
P: 646
//This should have been the code
sum=I;
intermediary = I;
for(i=0;i<k;i++)
{
intermediary=mult(intermediary,A)
sum+=intermediary;
}

Now what was wrong in your code?
sum=I;
for(i=0;i<k;i++)
{
intermediary=mult(I,A); <---- Look at this, intermediary is set to IxA everytime here
sum+=intermediary;
intermediary=mult(intermediary,A)
}

-- AI
brad sue
brad sue is offline
#3
Feb25-06, 04:57 PM
P: 284
Quote Quote by TenaliRaman
//This should have been the code
sum=I;
intermediary = I;
for(i=0;i<k;i++)
{
intermediary=mult(intermediary,A)
sum+=intermediary;
}

Now what was wrong in your code?
sum=I;
for(i=0;i<k;i++)
{
intermediary=mult(I,A); <---- Look at this, intermediary is set to IxA everytime here
sum+=intermediary;
intermediary=mult(intermediary,A)
}

-- AI
Yes !I see now what I have done wrong.
thanks a lot.


Register to reply