baltoche Posted March 14, 2017 Share Posted March 14, 2017 Dear All, I'm trying to find function J(x) shown in attached file. Could somebody help me ? It seems that I don't have the right tool to solve it Thanks and Regards. Série.pdf Link to comment Share on other sites More sharing options...

DrP Posted March 14, 2017 Share Posted March 14, 2017 That capitol Sigma is a summation of the function of P for all values of P between 0 and infinity. Not sure how to solve it though - I haven't done that for years. I'm sure someone else can point you in the right direction - there are some good maths guys here. Link to comment Share on other sites More sharing options...

fiveworlds Posted March 14, 2017 Share Posted March 14, 2017 Not sure how to solve it though It is an infinite loop. public static void function(int x){ int answer = 0; int p = 0; while(true){ if(p%2 == 0}{ answer = answer + java.lang.Math.pow((x/2),2p)/java.lang.Math.pow(factorial(p),2) system.out.println(answer); } else{ answer = answer - java.lang.Math.pow((x/2),2p)/java.lang.Math.pow(factorial(p),2) system.out.println(answer); } } } public static int factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result = result * i; } return result; } -1 Link to comment Share on other sites More sharing options...

Strange Posted March 14, 2017 Share Posted March 14, 2017 It is an infinite loop. It is the sum of an infinite series, which is not the same thing. Your program can never return the value of the function but it is often possible to calculate the value. 1 Link to comment Share on other sites More sharing options...

pzkpfw Posted March 14, 2017 Share Posted March 14, 2017 (edited) You seem to have missed modifying p. And, I'd recommend decreasing the repeated code. Also, the code will "explode" when the ints start overflowing. It won't be infinite! Points for a non-recursive factorial. However, since we know (well, I'm assuming) p increases by 1 each time, we'd be able to keep the last factorial calculated and just multiply by the new p each time, rather than re-calculating all of 1 to p each time. Of course that makes it a non-generic factorial function, more of a "nextvalue" function. (I didn't make this change). (Disclaimer: I didn't read the PDF, I'm just reacting to the code (and I don't "do" java).) public static void function(int x){ int answer = 0; int temp = 0; int p = 0; while(true){ temp = java.lang.Math.pow((x/2),2p)/java.lang.Math.pow(factorial(p),2); if(p%2 == 0}{ answer = answer + temp; } else{ answer = answer - temp; } system.out.println(answer); p++; // p was not changing } } public static int factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result = result * i; } return result; } Edited March 14, 2017 by pzkpfw 1 Link to comment Share on other sites More sharing options...

baltoche Posted March 15, 2017 Author Share Posted March 15, 2017 Dear All, Thank you for your respective contributions. I do appreciate ! the reason why I need this function is because I need to integrate it in function of x. Have your codes been typed on Matlab ? Do I need module "Symbolic Math Toolbox" to try your code ? Thanks again and Regards, Cédric Link to comment Share on other sites More sharing options...

## Recommended Posts

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account## Sign in

Already have an account? Sign in here.

Sign In Now