Home > Blockchain >  Wolframalpha replace part of equation with new variable
Wolframalpha replace part of equation with new variable

Time:10-06

How can I replace part of an equation in Wolframalpha with another variable? For instance if I have a matrix P = {{a b c d q/(p a)-bc^2, a, b}, {q, a b c d q/(p b)-bc^2, 0}, {1, 1, 1}}. How can I replace the a b c d term with a new variable called s?

CodePudding user response:

This answer is for Wolfram Mathematica, as tagged.

You can simply use ReplaceAll — shorthand /.

P = {
  {a   b   c   d   q/(p   a) - b c^2, a, b},
  {q, a   b   c   d   q/(p   b) - b c^2, 0},
  {1, 1, 1}}

newP =  P /. (a   b   c   d) -> s

{{-b c^2 q/(a p) s, a, b}, {q, -b c^2 q/(b p) s, 0}, {1, 1, 1}}

If you need to extract the pattern to be replaced from a more complex expression there are some tips here : How to group certain symbolic expressions?

  • Related