  We introduce in $f(R)$ gravity--Palatini formalism the method of inverse
problem to extract the action from the expansion history of the universe.
First, we use an ansatz for the scale factor and apply the inverse method to
derive an appropriate action for the gravity. In the second step we use the
Supernova Type Ia data set from the Union sample and obtain a smoothed function
for the Hubble parameter up to the redshift~1.7. We apply the smoothed Hubble
parameter in the inverse approach and reconstruct the corresponding action in
$f(R)$ gravity. In the next step we investigate the viability of reconstruction
method, doing a Monte-Carlo simulation we generate synthetic SNIa data with the
quality of union sample and show that roughly more than 1500 SNIa data is
essential to reconstruct correct action. Finally with the enough SNIa data, we
propose two diagnosis in order to distinguish between the $\Lambda$CDM model
and an alternative theory for the acceleration of the universe.
