To carry out an experiment means to attempt to solve a problem or arrive at a certain conclusion by approaching it in different ways. Various methods are tried and tested, and the faulty ones are eliminated until you hit on the effect or result required.
This can be anything from a scientific project to applying make-up in a new way, mixing colours until you hit on the perfect shade for your boudoir or trying everything you can think of to ensure that the texture of the meringues in your 'Pavlova' are an exquisite blend of sticky crisp and light as a feather.
The phrase for trying everything until you get it right is known as 'trial and error'.
a method of discovery, solving problems, etc, by physically undertaking each step empirically, rather than relying on theory.
He learned to cook by trial and error. Each attempt is 'a hit or a miss'
What you are describing here is 'experimentation':
An attempt to accomplish something by trying various means until the correct one is found.
So you would say
The only way to solve this problem is by trial and error. (The error here alludes to the failed means or attempts, which are discarded until the right way is found).
Some synonyms for experiment are: