ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 09 Jul 2021 01:21:16 +0200Why am I getting a different solution on SageMath for an ODE compared to when I work it by hand?https://ask.sagemath.org/question/57912/why-am-i-getting-a-different-solution-on-sagemath-for-an-ode-compared-to-when-i-work-it-by-hand/ I am solving the separable linear ODE y'(x)+y(x)'-1 = 0 and SageMath returns the solution:
(_C + e^x)*e^(-x)
However, when I work it by hand I get this answer with a minor difference:
y = -e^(-x)C +1
Where is the negative sign in the SageMath solution?
Here is my code:
y = function('y')(x)
x = var('x')
de = diff(y,x)+y-1 == 0
desolve(de,y)
Thu, 08 Jul 2021 02:38:41 +0200https://ask.sagemath.org/question/57912/why-am-i-getting-a-different-solution-on-sagemath-for-an-ode-compared-to-when-i-work-it-by-hand/Answer by slelievre for <p>I am solving the separable linear ODE y'(x)+y(x)'-1 = 0 and SageMath returns the solution:</p>
<pre><code>(_C + e^x)*e^(-x)
</code></pre>
<p>However, when I work it by hand I get this answer with a minor difference:</p>
<pre><code>y = -e^(-x)C +1
</code></pre>
<p>Where is the negative sign in the SageMath solution?</p>
<p>Here is my code:</p>
<pre><code>y = function('y')(x)
x = var('x')
de = diff(y,x)+y-1 == 0
desolve(de,y)
</code></pre>
https://ask.sagemath.org/question/57912/why-am-i-getting-a-different-solution-on-sagemath-for-an-ode-compared-to-when-i-work-it-by-hand/?answer=57927#post-id-57927There is not really a difference.
Both answers involve an arbitrary constant.
Your `C` is the opposite of Sage's `_C`.Thu, 08 Jul 2021 22:20:03 +0200https://ask.sagemath.org/question/57912/why-am-i-getting-a-different-solution-on-sagemath-for-an-ode-compared-to-when-i-work-it-by-hand/?answer=57927#post-id-57927Comment by Austin for <p>There is not really a difference.</p>
<p>Both answers involve an arbitrary constant.</p>
<p>Your <code>C</code> is the opposite of Sage's <code>_C</code>.</p>
https://ask.sagemath.org/question/57912/why-am-i-getting-a-different-solution-on-sagemath-for-an-ode-compared-to-when-i-work-it-by-hand/?comment=57929#post-id-57929Ahh that makes sense. Thank you!Fri, 09 Jul 2021 01:21:16 +0200https://ask.sagemath.org/question/57912/why-am-i-getting-a-different-solution-on-sagemath-for-an-ode-compared-to-when-i-work-it-by-hand/?comment=57929#post-id-57929