You can think of independent and dependent variables in terms of cause and effect: an independent variable is the variable you think is the cause, while a dependent variable is the effect. In an experiment, you manipulate the independent variable and measure the outcome in the dependent variable.
In a chemical formula, we can see how many atoms from a certain element has participated for the compound and also we can clearly see what elements have been participated for the conpound