Mathematica: how to avoid replacement from taking the previous outputs

  • Context: Mathematica 
  • Thread starter Thread starter kaizen.moto
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 3K views
kaizen.moto
Messages
94
Reaction score
0
Hi all,

Please help me with regard to my problems about replacement syntax.

Iam looking for a method such that Mathematica won't use the previous output as an input for the subsequent cells or codes. Instead, I wish Mathematica express the replacement in terms of expressions for the subsequent cells.

Please help me to solve this matter. I,ve attached the notebook for your reference.

Thanks in advance for any response.
 

Attachments

Physics news on Phys.org
Does your submat function produce the correct formulas in terms of z? E.g. submat[2] evaluates to {{2 + 15 z + 3 z (3 + 3 z + 2 z^2)}, {3 + 9 z + 2 z^2 + z^2 (2 + 11 z)}}. Is that correct?
 
Thank you for reply.
Yes, that is absolutely correct
submat[1] = sub [1] = matDstar[z].matX + matH1sar[z,1];
submat[2] = {{2 + 15 z + 3 z (3 + 3 z + 2 z^2)}, {3 + 9 z + 2 z^2 +
z^2 (2 + 11 z)}}.

Now, this is the interesting part:
submat[1] /. z-> 0 returning {2,3}, submat[2] /. z-> 0 gives {2,3}; submat[3] /. z-> 0 generates {2,3} and so on.

It supposed to be like these:
submat[1] /. z-> 0 returning {2,3}, submat[2] /. z-> 0 gives {26,20}; submat[3] /. z-> 0 generates {158,142} and so on.

My question is that how to modify the existing codes so that they would generate the desired outputs as above.

Thank you
 
submat[3] evaluates to

{{2 + 21 z + 3 z (3 + 3 z + 2 z^2) + 3 z (3 + 9 z + 2 z^2 + z^2 (2 + 11 z))},
{3 + 18 z + 2 z^2 + z^2 (2 + 11 z) + z^2 (2 + 15 z + 3 z (3 + 3 z + 2 z^2))}}

What should it evaluate to?
 
I apologize for my wrong expressions, it should be read as follows:

submat[1] = {{2 + 11 z}, {3 + 3 z + 2 z^2}};
submat[2] = {{26 + 64 z}, {20 + 6 z + 26 z^2}}
submat[3] = {{158 + 432 z}, {142 + 9 z + 158 z^2}}
submat[4] = {{1028 + 7221 z}, {801 + 4 z + 1028 z^2}}

so if z = 0;
submat[1] = {2,3};
submat[2] = {26,20};
submat[3] = {158,142};
submat[4] = {1028,801};
 
So the problem is clearly not in the substitution z->0 but in your submat routine. It gives the wrong output. That said, I have no idea how to fix the submat routine. You can write it as:

submat[n_]:={{a[n] + b[n] z},{c[n] + d[n] z + e[n] z^2}}

But it is not clear from your description what the functions a,b,c,d,e are.