Question

In: Computer Science

Fill in the following function to sum the series of 1 + x/1 + x^2/2 +...

Fill in the following function to sum the series of 1 + x/1 + x^2/2 + x^3/3 + .. + x^n/n using Java Program

Solutions

Expert Solution

Please find your solution below and if any doubt or need change comment.and do upvote .

CODE:

import java.util.Scanner;
public class Main
{
    //rturns the sum of the series
    public static double sumTheSeries(int x,int n){
        double i,sum=1.0;
        double product=x;
        //find sum till n 
        for( i=1;i<=n;i++){
            sum=sum+product/i;
            product=product*x;
        }
        return sum;
    }
        public static void main(String[] args) {
          Scanner sc=new Scanner(System.in);
          //take user input
          System.out.print("Enter value of x: ");
          int x=sc.nextInt();
          System.out.print("Enter value of n: ");
          int n=sc.nextInt();
          System.out.printf("The summation is: %.2f", sumTheSeries(x,n));
        }
}

OUTPUT:


Related Solutions

1) Write an algorithm to calculate the sum of the following series: Sum =x-x3/3! + x5/5!...
1) Write an algorithm to calculate the sum of the following series: Sum =x-x3/3! + x5/5! – x7/7! +……. Stop when the term<0.0001. 2) An internet service provider charges its subscribers per month as follows: Data usage (n), in gbs charges (NIS) 0.0<n<=1.0 250 1.0<n<=2.0 500 2.0<n<=5.0 1000 5.0<n<=10.0 1500 n>10 2000 Write a C program to read the usage(n) from a file and print the charges to be paid by the subscribers. Your program must include the function calculate...
Write a complete program to sum the following series: (hint: use the for loop) 1 /2...
Write a complete program to sum the following series: (hint: use the for loop) 1 /2 + 1/ 4 + 1 /6 + ⋯ + 1 /100 PS: use C++ language please
-Write a program in C++: • to find the sum of the series 1! /1+2! /2+3!...
-Write a program in C++: • to find the sum of the series 1! /1+2! /2+3! /3+4! /4+5! /5 using the function1, • to convert decimal number to binary number using the function2, • to check whether a number is a prime number or not using the function3, • to check whether two given strings are an anagram using the function4. important must do in (Multi-Filing) of c++
Determine the sum of the series ∑n=1∞ ( 6n)/(n+2) if possible. (If the series diverges, enter...
Determine the sum of the series ∑n=1∞ ( 6n)/(n+2) if possible. (If the series diverges, enter 'infinity', '-infinity' or 'dne' as appropriate.)
1) Find the Taylor series (to second order terms) of the function f(x,y) = x^2 −4x...
1) Find the Taylor series (to second order terms) of the function f(x,y) = x^2 −4x + y + 9 around the point x = 3, y = −1. 2)Explain why the corresponding Taylor Series (to third order terms) will be the same as the second-order series.
1.)is the function f (x) = x exp^ (-x ^ 2/2) a proper function of the...
1.)is the function f (x) = x exp^ (-x ^ 2/2) a proper function of the operator O= d2 / dx2-x2? if so, what is the intrinsic value? 2.)is the function f (x) = exp^ (4ix) -exp ^(-4ix) its own function of the operator d2 / dx2? if so, what is the intrinsic value? 3.)is the function f (x) = exp^ (2ix) -exp ^(-2ix) a proper function of the operator d^2 / dx^2? if so, what is the intrinsic value?...
Find the real Fourier series of the piece-wise continuous periodic function f(x)=1+x+x^2 -pi<x<pi
Find the real Fourier series of the piece-wise continuous periodic function f(x)=1+x+x^2 -pi<x<pi
Find the Fourier series of the following functions f(x) = sinx+x^2+x, −2 < x < 2
Find the Fourier series of the following functions f(x) = sinx+x^2+x, −2 < x < 2
Consider the function. f(x) = x^2 − 1, x ≥ 1 (a) Find the inverse function...
Consider the function. f(x) = x^2 − 1, x ≥ 1 (a) Find the inverse function of f. f ^−1(x) = (b) Graph f and f ^−1 on the same set of coordinate axes. (c) Describe the relationship between the graphs. The graphs of f and f^−1 are reflections of each other across the line ____answer here___________. (d) State the domain and range of f and f^−1. (Enter your answers using interval notation.) Domain of f Range of f Domain...
(a) Determine the Taylor Series centered at a = 1 for the function f(x) = ln...
(a) Determine the Taylor Series centered at a = 1 for the function f(x) = ln x. (b) Determine the interval of convergence for this Taylor Series. (c) Determine the number n of terms required to estimate the value of ln(2) to within Epsilon = 0.0001. Can you please help me solve it step by step.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT