I am required to convert several dozen mathematical functions into C programs, and then into Java equivalent. I'm not that great in Java so how would we call the following function double mvfBeale(int n, double *x)
in Java. Is a dynamic array the way to go for variable x
Following is a simple program in c, for which I need the Java equivalent to get started.
#include<stdio.h>
#include<math.h>
double mvfBeale(int n, double *x)
{
return pow(1.5 - x[0] + x[0]*x[1], 2) +
pow(2.25 - x[0] + x[0] * x[1]*x[1], 2) +
pow(2.625 - x[0] + x[0] * pow(x[1], 3), 2);
}
int main(void)
{
int n;
double x;
double result;
printf("Enter n: ");
scanf("%d", &n);
printf("Enter x: ");
scanf("%lf", &x);
result = mvfBeale(n, &x);
printf("Beale = %lf", result);
}
Thanks in advance for your guidance.