Dangit, I just came to the same conclusion but didn't look to see that you had figured it out first.
Also, you wanted it rounded, which I omitted. So just take the close parentheses off the end of the first line (after the assigns) and put it at the end:
assign("p", n - 9)
assign("p20", round(p * .2))
assign("p30", round(p * .3))
round(switch(r,1,477.45,2,238.75,3,214.845,4,190.97,5,179.05,6,167.1,7,143.25,8,131.27,9,119.35)*pow(n,0.125)
+ if((r > 9) and (r <= 9 + p20), 95.49 * pow(n, 0.125))
+ if((r > 9 + p20) and (r <= 9 + p20 + p30), 47.745 * pow(n, 0.125))
+ if(r > 9 + p20 + p30, 23.875 * pow(n, 0.125)))