On Fri, 10 Sept 2021 at 16:40, Nicolas Guarin <nicogua...@gmail.com> wrote:
>
>
> I have the following ODE
>
>     z'' = 1 - z²
>
> That has as solutions z=tanh(C + t) and z=coth(C + t), depending on the
initial condition being greater or less than 1. When I use dsolve I get the
latter
>
>
> from sympy import *
> init_session()
> ode = Eq(f(t).diff(t), 1 - f(t)**2)
> sol = dsolve(ode, f(t))
>
> And sol is
>
>                    -1
> f(t) = ────────────  ,
>                 tanh(C₁ - t)
>
> That is equivalent to coth(C + t).
>
> Is there any reason for SymPy to give this answer and not the other or is
this a bug?

Are the different solutions not equivalent for different values of the
constants (bearing in mind the possibility for the constants to be
non-real)? This suggests that one solution can be transformed to the other
for appropriate values of the constants:

In [*41*]: C1, C2 = symbols('C1, C2')


In [*42*]: s1, s2 = solve(Eq(tanh(C1 + t), coth(C2 + t)), C1)


In [*43*]: s1.rewrite(exp).simplify()

Out[*43*]:

   ⎛  2⋅C₂⎞

log⎝-ℯ    ⎠

───────────

     2


In [*44*]: s2.rewrite(exp).simplify()

Out[*44*]:

   ⎛    ________⎞

   ⎜   ╱   2⋅C₂ ⎟

log⎝-╲╱  -ℯ     ⎠

In other words tanh(C1 + t) can be equivalent to coth(C2 + t) if C1 =
log(-exp(2*C2))/2. Of course if C2 is real then this implies that C1 is not.

Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxR2GB86zb07TNLvS%3DQz3CRogyGW9S6Vv%3DxrZ%2BEJ2nAkcQ%40mail.gmail.com.

Reply via email to