# How to substitute into general solution of ODE coefficients from Solve?

I am trying to solve a differential equation. After solving it, I look for the coefficients according to some boundary conditions that give a certain system of algebraic equations. How can I place back into the general solution the roots of the algebraic system?

k = DSolve[{y'''[z] == -I*Betta*y'[z] + B}, y[z], z];
roots = Solve[
0 == c1 + c2*Cosh[I/2*(I*Betta)^0.5] +
c3/I*Sinh[I/2*(I*Betta)^0.5] + B/(2*I*Betta) &&
0 == c1 + c2*Cosh[I/2*(I*Betta)^0.5] -
c3/I*Sinh[I/2*(I*Betta)^0.5] - B/(2*I*Betta) &&
1 == c2*I*(I*Betta)^0.5*Sinh[I/2*(I*Betta)^0.5] +
c3*(I*Betta)^0.5*Cosh[I/2*(I*Betta)^0.5] + B/(I*Betta) &&
1 == -c2*I*(I*Betta)^0.5*Sinh[I/2*(I*Betta)^0.5] +
c3*(I*Betta)^0.5*Cosh[I/2*(I*Betta)^0.5] + B/(I*Betta), {c1, c2,
c3, B}];
k2 = k /. {C[1] -> roots[[1, 1]], C[2] -> roots[[1, 2]],
C[3] -> roots[[1, 3]], B -> roots[[1, 4]]}


At the end I would like to have a function which I can plot with standard methods

• Why not directly express your equations in terms of the C[k]? Solve[0 == C[1] +C[2] Cosh[I/2*(I*Betta)^0.5] + ... && (* equations *), {C[1], C[2], C[3], B}] – J. M. will be back soon Mar 30 '17 at 9:55
• @J.M. The equations (equations) are the ones that you also wrote in Solve[0==C[1]+C[2] .... Maybe I wasn't clear, but I think your idea doesnt make sense. The first part of your Solve would be one of the equations that give the solution. The system of equations that give c1,c2,c3,B is exactly the one inside my Solve expressione. I want to substitute these solutions (which are given in vectorial form) INSIDE the function k(z) which comes from the DSolve and has got C[1],C[2],C[3],B.. inside, which I dont know how to replace with my c1,c2,c3,B. – Andrea G Mar 30 '17 at 10:11
• The idea is that you don't need the extra effort to transfer, say, c1, into C[1], since you can do DSolve[(* stuff *)] /. Solve[(* stuff *)]. That's why I'm saying that you can use C[1], etc. instead of c1, etc. in Solve[]. – J. M. will be back soon Mar 30 '17 at 10:19
• @J.M. Is there also a way to show each sine or cosine functions into sinh and cosh including imaginary unit. So far, I havent found much on documentation, rather the opposite. – Andrea G Mar 30 '17 at 10:45
• @AndreaG What are the four conditions? – zhk Mar 30 '17 at 15:40

k = DSolve[{y'''[z] == -I*Betta*y'[z] + B}, y[z], z];