void solve() {
    for (int i = 0; i < numberOfPoints; i++) { // zeros wavefunction
      phi[i] = 0;
    }

    for (int i = 0; i < numberOfPoints; i++) {
      phi[i] = state[0]; // stores wavefunction
      x[i] = state[2];
      solver.step(); // steps Schroedinger equation
      if (Math.abs(state[0]) > stepThreshold) { // checks for diverging solution
        break; // leave the loop
      }

      if ((state[0] >= 0 && phi[i] < 0)
          || (state[0] < 0 && phi[i] >= 0 && i != 0)) {
        nodes++;
      }
    }
  }