0

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

sessen
  • 3
  • 3
  • Did you run `.jinit()`? If so, what's the output? – cory May 26 '20 at 16:05
  • Yes when I tired it out of the function or inside .jcheck output is just 0 and when I call .jinit(lagrange.poly(x, y)) the output has error like Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException Called from: .jcheck() – sessen May 26 '20 at 16:25

0 Answers0