Infinitive is not a subject, but it is the main verb of a sentence of giving an order, a command, or a request.
The subject of this sentence is removed and it is the pronoun "you".
Write your homework. (complete sentence)
Writing your homework. (incomplete sentence as it lacks the main verb)
Writing your homework is a means by which you can get high marks. (complete sentence)
Open the door,please.(complete sentence)
Opening the door (incomplete sentence as it lacks the main verb)
Opening the door is / can /....... (complete sentence)
Play tennis.(complete sentence)
Playing tennis (incomplete sentence as it lacks the main verb)
Playing tennis is very amusing.(complete sentence)
the main verb is not necessarily verb to be;
it may be any other verb such as: helps - can -have - improve- provide - etc...........