1
$\begingroup$

I am using DSolve to find the solutions to two differential equations. The problem is from the first solution, I only want the solution that includes a negative complex variable (in my case omega). In the second solution I want the positive complex omega. Is there any way to specify in DSolve, or FindInstance that I want +/- complexes?

My DSolve command looks like this:

DSolve[y'[x] == Exp[Ix] + Exp[-Ix], y[x], x]

I've looked through many answers on MMSE and I also looked at the documentation, but I haven't found a satisfying answer that works for me.

$\endgroup$
5
  • 3
    $\begingroup$ You can't really tell DSolve that. What you can do, is that after you get the solutions, simply remove the ones you do not want. If you give an example of what you have, someone can show you how to remove/filter out the solutions that you do not want from the result. $\endgroup$
    – Nasser
    Sep 28, 2023 at 18:42
  • 1
    $\begingroup$ Edit your question with the code; however, convert to InputForm prior to copy and paste into your question. $\endgroup$
    – Bob Hanlon
    Sep 28, 2023 at 19:03
  • $\begingroup$ Presumably you mean dsol1 = DSolveValue[y''[x] + (w^2 - Sech[x]^2) y[x] == 0, y[x], x]; however, you need to specify some initial conditions to resolve the arbitrary constants. What do you mean by "negative" and "positive" complex values? Are you referring to their real part, imaginary part, or both? $\endgroup$
    – Bob Hanlon
    Sep 28, 2023 at 19:13
  • $\begingroup$ when you solve this differential equation there will be an e^iw solution, and an e^-iw component. I would like to use DSolveValue, but only store the solution that includes e^-iw. $\endgroup$
    – RudyJD
    Sep 28, 2023 at 19:17
  • 1
    $\begingroup$ "Negative complex variable"? What about $1 - i$? $\endgroup$ Sep 28, 2023 at 21:14

1 Answer 1

1
$\begingroup$

Here is a solution that works:

value = DSolveValue[y'[x] == Exp[Ix] + Exp[-Ix], y[x], x] (* Here we store the solution *)

sols = {value[[1]],value[[2]]} (* We make a set from the two solutions *)

set = {value[[1,1,2,1]],value[[2,1,1]]} (* We make another set from the two solutions, only considering the exponentials *)

neg = PositionSmallest[set,1][[1]] (* Here we return which entry in the set has the smallest value,  *)

var = sols[[neg]](* We store the solution that has the negative complex exponential part *)

We have found a solution, modify as needed to fit your problem!

$\endgroup$
3
  • 1
    $\begingroup$ The ODE in your answer does not match the one in your question, and DSolve is unable to solve it. $\endgroup$
    – bbgodfrey
    Sep 30, 2023 at 15:02
  • $\begingroup$ thank you, I originally was working with a simpler version of the DiffEQ, and forgot to fix this when I copy+pasted $\endgroup$
    – RudyJD
    Sep 30, 2023 at 16:12
  • $\begingroup$ {set[[1, 1, 2]], set[[2, 1, 2]]} generates error messages. $\endgroup$
    – bbgodfrey
    Sep 30, 2023 at 18:39

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.