Opened 9 years ago

Closed 5 years ago

#9421 closed defect (duplicate)

desolve mixes user parameters and integration constants

Reported by: zimmerma Owned by: burcin
Priority: major Milestone: sage-6.2
Component: calculus Keywords:
Cc: robert.marik, kcrisman Merged in:
Authors: Paul Zimmermann Reviewers: Ralf Stephan
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:



sage: var('t')
sage: x=function('x',t)
sage: var('c')
sage: desolve(diff(x,t)+2*x==t^2-2*t+c,x,ivar=t).expand()
c*e^(-2*t) + 1/2*t^2 + 1/2*c - 3/2*t + 3/4

Here the first occurrence of c is an integration constant, whereas the second one is the parameter in the ODE:

sage: var('d')
sage: desolve(diff(x,t)+2*x==t^2-2*t+d,x,ivar=t).expand()
c*e^(-2*t) + 1/2*t^2 + 1/2*d - 3/2*t + 3/4

In case the ODE contains c, desolve should choose another name for the integration constant.

Attachments (1)

trac_9421.patch (1012 bytes) - added by zimmerma 5 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 9 years ago by robert.marik

  • Cc robert.marik added

This is a part of more general problem which has been reported in #6882.

comment:2 Changed 8 years ago by kcrisman

  • Cc kcrisman added

comment:3 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

Changed 5 years ago by zimmerma

comment:4 Changed 5 years ago by zimmerma

  • Authors set to Paul Zimmermann
  • Status changed from new to needs_review

waiting for the general problem to be solved, the attached patch prints a warning if the given equation contains the variable c.


comment:5 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:6 Changed 5 years ago by rws

  • Reviewers set to Ralf Stephan
  • Status changed from needs_review to positive_review

I will OK this if you have a look at #8734 in turn, please 8) See also #16007

Last edited 5 years ago by rws (previous) (diff)

comment:7 follow-up: Changed 5 years ago by zimmerma

thus should we have a dependency on #8734?


comment:8 in reply to: ↑ 7 Changed 5 years ago by rws

Replying to zimmerma:

thus should we have a dependency on #8734?

Then everything waits for that review, which could take forever. But I want the warning now.

comment:9 Changed 5 years ago by nbruin

You might want to consider this one too:

sage: desolve(diff(f(x),x,x)-f(x),f(x))
k2*e^(-x) + k1*e^x

We can recognize the variables as distinct before they are converted from maxima:

sage: function('f',x)
sage: var('c')
sage: V=diff(f(x),x)-f(x)+c
sage: v=maxima_calculus(V)
sage: v.ode2(f(x),x)
sage: v.ode2(f(x),x).ecl()
  ((MEXPT SIMP) $%E $X)))>

so perhaps the right solution is to warn when sage's "forget the %" causes a name collision (with the righter solution being: making sage's "forget the %" more intelligent, so that collisions can be avoided)

comment:10 Changed 5 years ago by rws

With #16007 the output is now

sage: sage: x=function('x',t)
sage: sage: var('c')
sage: sage: desolve(diff(x,t)+2*x==t^2-2*t+c,x,ivar=t).expand()
1/2*t^2 + _C*e^(-2*t) + 1/2*c - 3/2*t + 3/4

sage: desolve(diff(f(x),x,x)-f(x),f(x))
_K2*e^(-x) + _K1*e^x

As that's a simple and fine solution instead of a warning or an extended patch I would be glad if someone could review that one-liner.

comment:11 Changed 5 years ago by vbraun

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.