So I have a linear differential equation which depends on a function f(x) which is piecewise defined, let's say in regions A, B, C. Due to the form of f(x), it's easy to find a basis for the solutions in regions A and C, but in B no closed form solutions exist as far as I know. What I want to do is try different initial conditions in A, solve the full equation with NDSolve, and then pull out the results in region C. I know the basis so I'd like to know exactly which linear combination of that basis gives the particular solution in region C.
EDIT: some sample code of an example I threw together
f[x_] = Piecewise[{{x^3 + 9, 0 < x < 2}}, 1]
ode = g''[x] + f[x]*g[x] == 0
soln[x_] =
g[x] /. NDSolve[{ode, g[0] == 0, g'[0] == 1}, g[x], {x, -20, 20}]
Plot[soln[x], {x, -20, 20}]
The soln[x] for x>2 should be in the form fSin[x] + gCos[x] and I want to compute the constants f and g. Is there a way to extract this from the NDSolve output?