That background is 0.1%of the total amplitude and nearly on the order of the noise. Is the background really just a step or linear function or more complicated?
What is "n" in your formula?
The right and left side can never be equal, because the sign of their slope differs.
Here are the formulas you have attached. Why didn't you insert them in the post isntead of attaching them?
First formula:
Second Formula: