Nested Summation Computation for M_K with MATLAB

  • Context: MATLAB 
  • Thread starter Thread starter omer21
  • Start date Start date
  • Tags Tags
    Computing Summation
Click For Summary
SUMMARY

The discussion focuses on computing the nested summation for M_K using MATLAB, specifically the formula M_{K}=\frac{1}{2^{k+1}-2}\sum_{i=0}^{L-1}\sum_{l=1}^{K}\binom{K}{l}h_{i}i^{l}M_{K-l}. The user provided MATLAB code to implement this computation with K=4 and L=4, initializing M_0 to 1 and defining h_i values. The code was confirmed to be correct after review, successfully calculating the desired summation.

PREREQUISITES
  • Understanding of nested summations in mathematical computations
  • Familiarity with MATLAB programming language and syntax
  • Knowledge of combinatorial functions, specifically binomial coefficients
  • Basic concepts of matrix manipulation in MATLAB
NEXT STEPS
  • Explore advanced MATLAB functions for combinatorial calculations
  • Learn about MATLAB's vectorization techniques to optimize performance
  • Study the implications of varying K and L on the summation results
  • Investigate numerical stability and error handling in MATLAB computations
USEFUL FOR

Mathematicians, data scientists, and engineers involved in computational mathematics or algorithm development using MATLAB.

omer21
Messages
24
Reaction score
0
<br /> M_{K}=\frac{1}{2^{k+1}-2}\sum_{i=0}^{L-1}\sum_{l=1}^{K}\binom{K}{l}h_{i}i^{l}M_{K-l}<br />

M_0=1 and the size of h_i is L.

I tried to compute this summation in matlab, my attempt is as following:
Code:
clear
h=[ (1+sqrt(3))/4 (3+sqrt(3))/4 (3-sqrt(3))/4 (1-sqrt(3))/4]'; 
% for simplicity i take K=4 and L=4 
K=4;
L=4;
k=1;
M=zeros(1,K+1);
M(1)=1;

for l=1:K
    for i=1:L
        for j=1:k
            M(l+1)=M(l+1)+nchoosek(k,j)*h(i)*((i-1)^l)*M(l);
        end
    end
    k=k+1;
    M(l+1)=(1/(2^(K+1)-2))*M(l+1);
end

But I'm not sure whether the codes are correct or not. If the codes are not correct how can i fix them?
 
Physics news on Phys.org
problem is solved.
 

Similar threads

Replies
0
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
0
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K