I need to split a number into N parts such that the difference between each part is exponentially increasing

3 ビュー (過去 30 日間)
Hi, I need to split a number into N parts, for eg. number 1058 should be divided into 6 numbers (the sum of the 6 numbers will be equal to 1058) such that the difference between the numbers is exponentially increasing.
To elaborate if the 6 numbers are [n1, n2, n3, n4, n5, n6], the numbers n2-n1, n3-n2, n4-n3, n5-n4 give an exponential function.
Thanks for your help
  1 件のコメント
Bruno Luong
Bruno Luong 2022 年 8 月 3 日
編集済み: Bruno Luong 2022 年 8 月 3 日
Here is one solution
n(1)=n(2)=... = n(6) = 1058 /6
All the different are
n(k+1)-n(k) = 0 = exp(k*(-Inf)) for k = 1..., 5, so it is an exponential function wrt k

サインインしてコメントする。

回答 (1 件)

Abhishek Chakram
Abhishek Chakram 2023 年 9 月 22 日
Hi Jyoti Mangal,
It is my understanding that you are facing difficulty in writing the code to divide a number into N parts such that difference between each part is exponentially increasing and sum of all the parts is equal to the number itself.
You can use the concept of geometric progression (GP) for it.
Here’s an example for the same:
gp_sum = 4586; % The number to be split
N = 6; % Number of parts
r = 2; % Common ratio for geometric progression
starting_number = (gp_sum * (r - 1)) / (r^N - 1); % starting number of geometric progression
split_numbers = zeros(1, N);
split_numbers(1) = starting_number;
for i = 2:N
split_numbers(i) = starting_number * r^(i-1);
end
sum(split_numbers); % Prints the sum of splited numbers that is equal to number itself
split_numbers; % Prints the splited numbers
Best Regards,
Abhishek Chakram

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by