I am getting ready to apply to mathematics graduate programs this semester. As far as I know most school require 3 letters of reference. I've secured two letters but for my third letter I have a couple of options. I can simply ask another professor whose class I have done well in, but I am not confident in the strength of the letter. As for my other option, I have just finished a summer research program under the supervision of a grad student and I feel as if he has more helpful things to say. However, it seems like in general it is not the best idea to get references from people who do not have PhD's. I was wondering what the best course of action would be.
There are a couple of major dangers in asking a graduate student for a letter:
A typical grad student has never actually read a letter of recommendation and has very little idea of how they are written or what the standard of comparison is. It's easy to completely misjudge the style or miscalibrate the letter, in which case a letter that's intended to be helpful can turn out to be useless, or even counterproductive. No inexperienced letter writer should ever send a letter without first running it by a mentor, so you would need to make sure the grad student plans to do that.
Graduate students automatically write from a position of somewhat less credibility, just because they lack experience. Someone with more experience can compare a student to past students whose later career trajectories are known, but grad students generally can't do that.
One possibility is for the grad student to write a letter jointly with his/her advisor. That may or may not be feasible, but it's worth checking.
I don't recommend to ask a reference letter from another student. From my experience, the persons who will evaluate your application will most likely not trust a letter written by a student. In general, a referee is a professor, researcher or a person working in the industry. This person should have supervised you, collaborated with you or you should have taken their course.
So in your situation, you should ask the professor who is supervising the grad student instead of asking the grad student. Otherwise, you may always ask the other professor that you mentioned.
It is common for graduate students or postdocs to have a better grasp of the work that you've done on a project as generally they are the ones supervising and providing mentorship to research assistants/fellows. Generally, a lot of the text of the letter will be written by your direct supervisor (grad student or postdoc) who will provide this to the professor in charge of the lab, who will provide some additional comments and put it on their letterhead & sign it. Thus, you will need to ask both the grad student and the professor to combine forces on the letter. Sometimes the graduate student can facilitate this communication for you and sometimes you'll need to be more proactive. But this is extremely common and expected--the graduate student will provide concrete examples of your work & work ethic that the professor can then use.