Student Support Forum: 'replace' topicStudent Support Forum > General > Archives > "replace"

 Next Comment > Help | Reply To Topic
 Author Comment/Response randy Silvers 06/26/05 10:34pm I've got a function that depends on a state variable U and a control variable p, which depends on the state variable. I need to take the determinant of the Hessian, which will become quite long. I have a list of replacement rules which simplifies the expression, but I cannot get Mathematica to replace consistently or to attempt to rearrange terms and then replace. I have a replacement rule that replaces U+(a - a p**)/integral with U2g. This sometimes works. Sometimes, in my evaulations, Mathematica ends up with U+a(1-p**)/integral or it ends up with -a(-1+p**)/Integral + U The replacement succeeds when the exact matching expression is found but when its equivalent is output from an evaluation, the replacement fails. I have even copied an expression from the output and listed it in the following line as a replacement but sometimes nothing happens. Specifically, it seems to recognize and replace this instance of U2g, but another expression pi1, is not replaced even after copying and pasting in a replacement rule. I need to examine an expression that, even simplified with some replacements is a page long so I want to accurately replace things. Also, I have as a replacement rule that -p**-Tp**+p**F[p**]->pi2. This works, but when there is a sum such as (1 - p**-Tp**+(-1+p**)F[p**]) no replacement is made, even though this expression equals (1 - F[p**]-p**-Tp**+p**F[p**]) which should become (1-F[p**]-pi2). Then, with the substitution rule that 1-F[p**]->pi1+pi2, the expression would become pi1+pi2-pi2 which would reduce to pi1, which is correct. Essentially, how can I get Mathematica to try all rearrangements to simplify and replace? See attached for more specifics. Attachment: substdemo.nb, URL: sirandol@deakin.edu.au,

 Subject (listing for 'replace') Author Date Posted replace randy Silvers 06/26/05 10:34pm Re: replace Henry Lamb 06/30/05 11:08am
 Next Comment > Help | Reply To Topic