Is this plagiarism? Can I publish my work
There are a number of other questions on this site relating to these issues, although I'm not going to search for them now.

There are different issues going on here:

Firstly, you want to publish the bit of research you have done so far, but the PI thinks it should instead be turned into something more substantial before publishing. In this he is almost certainly right. It is not considered good practice to slice work into small pieces to get more papers.

You are considering publishing work with someone else against their wishes. Don't. Especially if you want to stay within the research community.

I take it you are concerned about having material for your PhD. Unless you are somewhere where publishing is a requirement for graduating, this is actually irrelevant. A PhD thesis should contain what you have done, and the normal progression of research is considered when assessing it.

You want to work remotely. I am confused as to who your PhD supervisor is. If he is your supervisor then you should expect to see him in person. If you are doing a PhD elsewhere, then how do you expect to have time to work on this project while also working full-time on your PhD topic?

Note also that writing a faster algorithm does not in itself really constitute new research in maths. Is there a particular theoretical change that made it faster? Or is it just that you coded a bit better? Does it actually make a difference in practical computational time, such that it allowed you to test some new examples that gave you the key insight for a theorem (or at least conjecture, or counter-example)?

The professor has said your name won't go on the final paper if you do no further work. It's possible that the professor is being unreasonable, and you can look up other questions along those lines. But the more likely situation is that your name won't go on the paper because what you have done doesn't count for authorship. Generally in mathematics the authors are only those who have contributed to what appears in the paper. It sounds unlikely that that would be true of the work you have done.

An unconventional solution, but one that would perhaps be more to your liking, might be to agree to release your write-up of your algorithm alongside the final paper, either as an appendix or as a separate paper. It probably won't do that much for you career-wise, but it might make you feel better and preserve your relationship with the professor. Also, by the time that happens you may be in a better position to admit that he's right. I know for myself it's hard to admit that your work isn't really that valuable, because it matters a lot to you. Over time you will become a little less emotionally involved.

Also, remember that this is someone you will want a reference from, if you are to stay in academia.