docs: public static MutableDoubleTuple insertElementAt(
          DoubleTuple t, int index, double value, 
          MutableDoubleTuple result)
      {
          if (index < 0)
          {
              throw new IndexOutOfBoundsException(
                  "Index "+index+" is negative");
          }
          if (index > t.getSize()) // Note: index==t.getSize() is valid!
          {
              throw new IndexOutOfBoundsException(
                  "Index "+index+", size "+t.getSize());
          }
          if (result == null)
          {
              result = DoubleTuples.create(t.getSize() + 1);
          }
          else if (result.getSize() != t.getSize() + 1)
          {
              throw new IllegalArgumentException(
                  "Input size is " + t.getSize() + ", result size must be " +
                  (t.getSize() + 1) + " but is " + result.getSize());
          }
          int counter = 0;
          for (int i=0; i<index; i++)
          {
              result.set(counter, t.get(i));
              counter++;
          }
          result.set(counter, value);
          counter++;
          for (int i=index; i<t.getSize(); i++)
          {
              result.set(counter, t.get(i));
              counter++;
          }
          return result;
      }