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: |
Description
Consider
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)
Change History (12)
comment:1 Changed 9 years ago by
- Cc robert.marik added
comment:2 Changed 8 years ago by
- Cc kcrisman added
comment:3 Changed 6 years ago by
- Milestone changed from sage-5.11 to sage-5.12
Changed 5 years ago by
comment:4 Changed 5 years ago by
- 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
.
Paul
comment:5 Changed 5 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:6 Changed 5 years ago by
- Reviewers set to Ralf Stephan
- Status changed from needs_review to positive_review
comment:7 follow-up: ↓ 8 Changed 5 years ago by
thus should we have a dependency on #8734?
Paul
comment:8 in reply to: ↑ 7 Changed 5 years ago by
comment:9 Changed 5 years ago by
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) f(x) sage: var('c') c sage: V=diff(f(x),x)-f(x)+c sage: v=maxima_calculus(V) sage: v.ode2(f(x),x) 'f(x)=(c*%e^-x+%c)*%e^x sage: v.ode2(f(x),x).ecl() <ECL: ((MEQUAL SIMP) ((%F SIMP) $X) ((MTIMES SIMP) ((MPLUS SIMP) $%C ((MTIMES SIMP) $C ((MEXPT SIMP) $%E ((MTIMES SIMP) -1 $X)))) ((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
With #16007 the output is now
sage: sage: x=function('x',t) sage: sage: var('c') 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
- Resolution set to duplicate
- Status changed from positive_review to closed
This is a part of more general problem which has been reported in #6882.