Opened 8 years ago
Closed 4 years ago
#9824 closed defect (fixed)
improve desolve_system initial condition documentation
Reported by:  rhinton  Owned by:  burcin 

Priority:  major  Milestone:  sage6.5 
Component:  calculus  Keywords:  calculus, maxima, symbolics, beginner 
Cc:  robert.marik  Merged in:  
Authors:  Sergey Bykov  Reviewers:  KarlDieter Crisman 
Report Upstream:  N/A  Work issues:  
Branch:  dfbad1c (Commits)  Commit:  dfbad1c4ffbd6ea02985e76e4fe33a4278badb2a 
Dependencies:  Stopgaps: 
Description (last modified by )
Edit: See comments for the actual issue.
desolve_system apparently ignores initial conditions. Notice the identical results in the two calls in the following example.
sage: t = var('t') sage: epsilon = var('epsilon') sage: x1 = function('x1', t) sage: x2 = function('x2', t) sage: de1 = diff(x1,t) == epsilon sage: de2 = diff(x2,t) == 2 sage: desolve_system([de1, de2], [x1, x2], ivar=t) [x1(t) == epsilon*t + x1(0), x2(t) == 2*t + x2(0)] sage: desolve_system([de1, de2], [x1, x2], ics=[1,1], ivar=t) [x1(t) == epsilon*t + x1(0), x2(t) == 2*t + x2(0)]
Change History (13)
comment:1 followup: ↓ 2 Changed 8 years ago by
 Status changed from new to needs_info
comment:2 in reply to: ↑ 1 Changed 8 years ago by
 Status changed from needs_info to needs_work
Thanks for pointing out my mistake!
I think updating the documentation is a great idea. I think we should raise a ValueError? exception if ics
is incomplete. Assuming an initial value of 0 is not horrible, but Python and Sage seem to prefer explicitness.
Replying to robert.marik:
As I observed from documentation, the ics have to be in the form [x0,x1(x0),x2(x0)]
The following works.
sage: t = var('t') sage: epsilon = var('epsilon') sage: x1 = function('x1', t) sage: x2 = function('x2', t) sage: de1 = diff(x1,t) == epsilon sage: de2 = diff(x2,t) == 2 sage: desolve_system([de1, de2], [x1, x2], ivar=t) [x1(t) == epsilon*t + x1(0), x2(t) == 2*t + x2(0)] sage: desolve_system([de1, de2], [x1, x2], ics=[0,1,1], ivar=t) [x1(t) == epsilon*t + 1, x2(t) == 2*t + 1]O.K. what to do with this?
Update documentation to mention this explicitly?
Assume (silently or with a warning) that ivar=0 for initial condition whenever the number of dependent variables equals the number of initial conditions?
comment:3 Changed 7 years ago by
 Description modified (diff)
 Summary changed from desolve_system ignores initial conditions to improve desolve_system initial condition documentation
I agree that we should be explicit here. There is no obvious default for a diffeq; initial condition of zero is not the same as starting to count at 0 or 1. Yes, updating the documentation would be great for this.
comment:4 Changed 7 years ago by
 Keywords beginner added
comment:5 Changed 5 years ago by
 Milestone changed from sage5.11 to sage5.12
comment:6 Changed 4 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:7 Changed 4 years ago by
 Milestone changed from sage6.2 to sage6.3
comment:8 Changed 4 years ago by
 Milestone changed from sage6.3 to sage6.4
comment:9 Changed 4 years ago by
 Branch set to u/captaintrunky/improve_desolve_system_initial_condition_documentation
comment:10 Changed 4 years ago by
 Commit set to dfbad1c4ffbd6ea02985e76e4fe33a4278badb2a
 Status changed from needs_work to needs_review
New commits:
dfbad1c  Fixed bug with incomplete initial conditions

comment:11 Changed 4 years ago by
This looks good.
While testing this (it doesn't always work, but only in cases of user error like not specifying each function as also a variable to be solved for (at least, I think that is user error?)), I got the following mysterious error.
sage: sage: t = var('t') sage: sage: u = var('u') sage: sage: x = function('x', t) sage: sage: y = function('y', t) sage: sage: de1 = diff(x,t) + y  1 == 0 sage: sage: de2 = diff(y,t)  x + u == 0 sage: sage: des = [de1,de2] sage: sage: ics = [0,1,1] sage: sage: vars = [x,y] sage: sage: sol = desolve_system(des, vars, ics, u); sol TypeError: ECL says: Error executing code in Maxima:
I get similar errors if Maxima just can't solve the system, but with a message. While it's true that u
isn't one of the variables differentiated by or of the functions u
, at least it should give an error message that the system doesn't make sense; this could easily happen as a typo for something that works fine.
sage: sage: sol = desolve_system(des, vars, ics, t); sol [x(t) == (u  1)*cos(t) + u + 2*sin(t), y(t) == (u  1)*sin(t)  2*cos(t) + 1]
Perhaps for another ticket.
comment:12 Changed 4 years ago by
 Milestone changed from sage6.4 to sage6.5
 Reviewers set to KarlDieter Crisman
 Status changed from needs_review to positive_review
comment:13 Changed 4 years ago by
 Branch changed from u/captaintrunky/improve_desolve_system_initial_condition_documentation to dfbad1c4ffbd6ea02985e76e4fe33a4278badb2a
 Resolution set to fixed
 Status changed from positive_review to closed
As I observed from documentation, the ics have to be in the form [x0,x1(x0),x2(x0)]
The following works.
O.K. what to do with this?
Update documentation to mention this explicitly?
Assume (silently or with a warning) that ivar=0 for initial condition whenever the number of dependent variables equals the number of initial conditions?