This question might be asked but I have been working on it for the whole day and I didn't solve and understand the other solutions. Until today my code was clearly working. I didn't change anything however today in the same code I got different errors in each time. I am using macOS. I installed rYsmPy rJava packages and Here is my code ;
lagrange.poly <- function(x, y) {
l <- list() # List to store Lagrangian polynomials L_{1,2,3,4}
k <- 1
for (i in x) {
num <- 1
denom <- 1
p <- x[! x %in% i]
for (j in p) {
num <- paste(num, "*", "(", 'x', " - ", as.character(j), ")", sep = "", collapse = "")
denom <- paste(denom, "*", "(", as.character(i)," - ", as.character(j), ")", sep = "", collapse = "")
}
l[k] <- paste("(", num, ")", "/", "(", denom, ")", sep = "", collapse = "")
k <- k + 1
}
eq <- 0
for (i in 1:length(y)) {
eq <- paste(eq, '+', as.character(y[i]), "*", l[[i]], sep = "", collapse = "")
}
x <- Var('x')
return(sympy(paste("simplify(", eq, ")")))
}
lagrange.poly(x, y)
When I run it lastly I got this error
Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), :
java.lang.NullPointerException
Called from: .jcheck()
Then program automaticly open .jcheck function. The output is
function (silent = FALSE)
invisible(.Call(RJavaCheckExceptions, silent))
Also before this error I got Error in .jcheck() : No running JVM detected. Maybe .jinit() would help.
I think they are connected but I don't have any idea to solve this problem.
Can anybody helps me? Thanks alot. This is after error what I see in my screen :
enter image description here