[Date Index]
[Thread Index]
[Author Index]
More Anomalous Behaviour with Indexed Variables
*Subject*: [mg3256] More Anomalous Behaviour with Indexed Variables
*From*: mrj at cs.usyd.edu.au (Mark James)
*Date*: 21 Feb 1996 13:18:00 -0600
*Approved*: usenet@wri.com
*Distribution*: local
*Newsgroups*: wri.mathgroup
*Organization*: The University of Sydney
*Sender*: daemon at wri.com
A recent article on this group discussed the frequent failure
of FindRoot when the search variable is indexed (e.g. x[1]).
I have been having similar problems.
Now this has cropped up again with NDSolve. If you
get a chance, run the following two groups of expressions
through your version. Why does the second version fail?
Is it because NDSolve no longer evaluates the dummy equation
first? I am using 2.2.1.
(*
PARAMETER IS: f
*)
Clear[ f ];
calc[ v_Real ] := ( f = v^2; 0 );
NDSolve[ {dummy'[t] == calc[p[t]], dummy[0]==0,
p'[t] == -p[t] + f, p[0]==0 }, {dummy,p}, {t,0,1} ]
(*
PARAMETER IS: f[1]
*)
Clear[ f ];
calc[ v_Real ] := ( f[1] = v^2; 0 );
NDSolve[ {dummy'[t] == calc[p[t]], dummy[0]==0,
p'[t] == -p[t] + f[1], p[0]==0 }, {dummy,p}, {t,0,1} ]
=====
FURTHER EXPLANATION:
The second differential equation in the first NDSolve call
above depends of a parameter f that is a function of p.
This parameter is calculated as a side effect
of integrating the first differential equation.
(My actual equation set, is 1000 times more complicated than this,
and I really want to use the side effect method to efficiently
calculate a number of parameters each integration step that
would otherwise each be calculated many times per step.)
I have used this method for a year without problems.
But changing the parameter to f[1] does not work.
(I now need to use indexed parameters in my real system.
I have managed to get this real system to work if I substitute
every indexed variable by a non-indexed one: e.g. s[1] -> s1 .)
Am I doing anything wrong, or is it a bug? If it is a bug:
Is there a workaround? Will it be fixed in 3.0?
Is this related to similar problems with indexed
variables in FindRoot?
Thanks for your help.
Mark James | EMAIL : mrj at cs.usyd.edu.au |
Basser Department of Computer Science, F09 | PHONE : +61-2-351-3423 |
The University of Sydney NSW 2006 AUSTRALIA | FAX : +61-2-351-3838 |
Prev by Date:
**More Anomalous Behaviour with Indexed Variables**
Next by Date:
**Re: Student v. Full version of Mathematica**
Previous by thread:
**More Anomalous Behaviour with Indexed Variables**
Next by thread:
**Re: More Anomalous Behaviour with Indexed Variables**
| |