I have a problem that I'm trying to solve for a couple a days now. The problem sounds like this:
I have a function in R :
f <- function(x) {
x ^ 3 - x ^ 2 - 4 * x + 2;
}
but I want to use it in Java, for example as follows: double y = f(5).
How can I do that?
Now, I'm using rJava package in R to use java code. I need to send this function as a parameter to a java method and calculate the function there (of course I can call the function in R and just send the result, but this is not the case, I need the function in Java as a whole).
java.util.Math.pow(int a, int b)returns the value ofa^b. But for your small powers, you can usex*x*xandx*xif you want. If powers specifically aren't your issue, then what is? Do you want a tutorial on Java-programming?