▁reduced . ▁This ▁concept ▁is ▁known ▁as ▁dynamic ▁programming . ▁ ▁A ▁dynamic ▁programming ▁algorithm ▁▁ ▁To ▁begin , ▁let ▁us ▁assume ▁that ▁all ▁we ▁really ▁want ▁to ▁know ▁is ▁the ▁minimum ▁cost , ▁or ▁minimum ▁number ▁of ▁arithmetic ▁operations ▁needed ▁to ▁multiply ▁out ▁the ▁matrices . ▁If ▁we ▁are ▁only ▁multip lying ▁two ▁matrices , ▁there ▁is ▁only ▁one ▁way ▁to ▁multiply ▁them , ▁so ▁the ▁minimum ▁cost ▁is ▁the ▁cost ▁of ▁doing ▁this . ▁In ▁general , ▁we ▁can ▁find ▁the ▁minimum ▁cost ▁using ▁the ▁following ▁recursive ▁algorithm : ▁▁ ▁Take ▁the ▁sequence ▁of ▁matrices ▁and ▁separate ▁it ▁into ▁two ▁subsequ ences . ▁ ▁Find ▁the ▁minimum ▁cost ▁of ▁multip lying ▁out ▁each ▁sub sequence . ▁ ▁Add ▁these ▁costs ▁together , ▁and ▁add ▁in ▁the ▁cost ▁of ▁multip lying ▁the ▁two ▁result ▁matrices . ▁ ▁Do ▁this ▁for ▁each ▁possible ▁position ▁at ▁which ▁the ▁sequence ▁of ▁matrices ▁can ▁be ▁split , ▁and ▁take ▁the ▁minimum ▁over ▁all ▁of ▁them . ▁ ▁For ▁example , ▁if ▁we ▁have ▁four ▁matrices ▁ABC D , ▁we ▁compute ▁the ▁cost ▁required ▁to ▁find ▁each ▁of ▁( A )( BC D ), ▁( AB )( CD ), ▁and ▁( ABC )( D ), ▁making ▁recursive ▁calls ▁to ▁find ▁the ▁minimum ▁cost ▁to ▁compute ▁ABC , ▁AB , ▁CD , ▁and ▁B CD . ▁We ▁then ▁choose ▁the ▁best ▁one . ▁Better ▁still , ▁this ▁yields ▁not ▁only ▁the ▁minimum ▁cost , ▁but ▁also ▁demonstr ates ▁the ▁best ▁way ▁of ▁doing ▁the ▁multiplication : ▁group ▁it