I have friend that I will ask for his mathematical analysis of my work, it's somewhat complete but needs further analysis using mathematics, if my friend does that, would he/she be considered a co-inventor? Even though they contributed nothing to the idea?
To be valid, a patent application must be "enabling". If your friend's work is critical to the implementation of the invention, then s/he should be named a co-inventor. If his work is for optimizing the solution, and such optimization is not part of the claim, then you could possibly leave him/her out. You should consult your patent attorney if you have doubt.