格助詞に is used for “in order to”, when you go and/or come in order to do something:
- 昨日彼が会いに来た -> He came to see me yesterday
- 彼の事務所に挨拶をしに寄った -> I stopped by his office to say hello
- 彼はビールを買いに行った -> He went out to get some beer
- 週に三度私はジムに運動しに行く -> I go to the gym to work out three times a week
彼女は医者になりに勉強している-> Doesn’t involve movement
When come and go are not involved and “in order to” is in a sub-clause 格助詞の + に can be used.
- 卒業するのに必要な単位 -> The credits required in order to graduate
- タイヤをホイールから外すのに使われる機械 -> A machine used in order to remove tires from wheels
- 彼とは仕事を話をするのに一回会っただけだ -> I only met him once in order to talk business
彼はビールを買うのに行った-> Not in a sub-clause
In writing and formal speeches, 為(ため) is usually used.
- 週に三度私は運動するためにジムに行く -> I go to the gym to work out three times a week
- 彼女は医者になるために勉強している -> She is studying in order to become a doctor
- 電球を交換するためにヘッドライトを外した -> I removed the headlight assembly in order to replace the bulb
- 彼は国を守るためなら死ぬ事も厭わない -> He doesn’t mind dying in order to protect his country
- 彼は勝つためならどんな手でも使う -> He resorts to anything in order to win