#8950: new function for sage.calculus.desolve module
------------------------------+---------------------------------------------
Reporter: uri | Owner: burcin
Type: enhancement | Status: needs_work
Priority: minor | Milestone: sage-4.5.2
Component: calculus | Keywords: desolve
Author: Oriol Castejon | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------------+---------------------------------------------
Changes (by pang):
* status: needs_review => needs_work
Comment:
The patch is a little weird now: it contains first the old one and then
the same code, but with instructions to include it in a different place. I
couldn't use it, and I think trac has trouble with it, too, because it
doesn't render the patch if you click on it, like it does usually. I can
produce a patch from a fresh install if you want, but let's talk about the
content first:
It pretty much works, but:
1. I'm concerned about using the variable 't' if the argument ivar is not
set explicitely. Is it safe to assume that nobody would use the name 't'
for a dependent variable? Is it safe to assume that everybody would use
the name 't' for the independent variable? I would prefer either of these
two approaches:
* Always require the parameter ivar
* Use some code like in `desolve_system_rk4` to try to guess the
independent var:
1. compute all variables used in the functions passed as arguments:
{{{
all_vars = set([])
for de in des:
all_vars.update(set(de.variables()))
}}}
2. if there is exactly one variable in all_vars not in dvars, assume it
is the independent var:
2. if all_vars is contained in dvars, create an adhoc independent
variable that is not used elsewhere. I've thought of a safe way to pick up
a new var, which maybe overkill. It seems like this is not necessary
thanks to the particular way in which fast_float works, but IMHO it's
better to be on the safe side:
2. otherwise raise an error
{{{
...
ivars = all_vars - set(dvars)
if len(ivars) == 1:
ivar = ivars.pop()
elif not ivars:
safe_name = 't_' + str(dvars)
ivar = var(safe_name)
else:
raise ...
}}}
Oriol: what's your opinion on this issue?
2. I'd use:
{{{
J=diff(des,dvars)
}}}
instead of
{{{
J=jacobian(des,dvars)
J=J[0][0]
}}}
3. In my opinion, the parameters to ``odeint`` mu and ml should not be
used. Those parameters do not make sense if you don't pass Dfun as an
argument. But please correct me if I'm wrong.
4. I've introduced a few ``is_SymbolicVariable(dvars)`` tests. I think the
test ``len(dvars)==0`` is a lousy test for a Symbolic Variable.
5. The documentation wasn't building correctly. Sphinx is a bit rigid, and
we need to follow the indentation rules, etc. I've fixed that already.
I'm attaching a patch file with the changes above included. It probably
won't merge cleanly into your Sage install, so I'm attaching the plain
file desolvers.py directly. Please tell me what you think, and then we
will ask for another reviewer.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8950#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.