0
$\begingroup$

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

$\endgroup$
7
  • $\begingroup$ 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}] $\endgroup$ Commented Mar 30, 2017 at 9:55
  • $\begingroup$ @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. $\endgroup$
    – Andrea G
    Commented Mar 30, 2017 at 10:11
  • 1
    $\begingroup$ 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[]. $\endgroup$ Commented Mar 30, 2017 at 10:19
  • $\begingroup$ @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. $\endgroup$
    – Andrea G
    Commented Mar 30, 2017 at 10:45
  • $\begingroup$ @AndreaG What are the four conditions? $\endgroup$
    – zhk
    Commented Mar 30, 2017 at 15:40

1 Answer 1

1
$\begingroup$
k = DSolve[{y'''[z] == -I*Betta*y'[z] + B}, y[z], z];
gsol[z_] = y[z] /. Flatten[k];
gdsol[z_] = D[y[z] /. Flatten[k], z];
findCs = Solve[{gsol[-1/2] == 0, gsol[1/2] == 0, gdsol[-1/2] == 1,
                gdsol[1/2] == 1}, {C[1], C[2], C[3], B}];
psol[z_, Betta_] = gsol[z] /. Flatten[findCs];
Plot[{Re[psol[z, 1]], Im[psol[z, 1]]}, {z, -1/2, 1/2}, PlotRange -> All, Frame -> True]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks @MMM this is exactly what I was looking for! $\endgroup$
    – Andrea G
    Commented Apr 21, 2017 at 15:15
  • $\begingroup$ @AndreaG I am pleased that it helped. $\endgroup$
    – zhk
    Commented Apr 21, 2017 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.