Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I understand the conecept of recursion but I don\'t understand how to use this s

ID: 3543995 • Letter: I

Question

I understand the conecept of recursion but I don't understand how to use this series summation. Can someone explain it to me? Thanks!

A person is trying to predict a honorarium that he will earn for this book. The honorarium is proportional to the number of books sold. In the publisher's experience, this amount follows the power law: the amount of money m(n) earned in year n is equal to m(l) * n-alpha, where alpha is a parameter depending on the book. Once we know the values m(l) and m(2) = m(l) * 2-alpha, we can find alpha from the ratio m(2) / m(l) (hint: use logarithms). Once the value alpha is determined, we now need to compute, for each year N, the total amount of money earned by this year, i.e., the sum s(N) = m(l) + m(2) + ... + m(N). Write a recursive method that, given m(l), m(2). and N, predicts s(N). Write a test program that asks the user for the values of m(l) and m(2), and prints out the sum of the series for the values n = 1, 2, 3,.... 10.

Explanation / Answer

Here is your java program:


import java.util.Scanner;


public class Honorarium

{

public static double sum = 0;


public static void main(String[] args)

{

double m1, m2;


Scanner scanner = new Scanner(System.in);

System.out.print("Enter m(1): ");

m1 = scanner.nextDouble();

System.out.print("Enter m(2): ");

m2 = scanner.nextDouble();


calculateHonorarium(m1, m2, 10);

}


private static void calculateHonorarium(double m1, double m2, int N)

{

double alpha = Math.log(m1 / m2) / Math.log(2);


if(N == 0)

{

System.out.println("s(10): " + sum);

}

else

{

sum += m1 * Math.pow(2, -1 * alpha);

calculateHonorarium(m1, m2, N - 1);

}

}

}