0

I feel there should be an easy solution to my problem but I couldn't find it.

I can explain my problem through a very simple example:
Given the functions f and a:

f := x(x-3) + 2x(x-3)
a := (x-3)

I now want to write f in terms of a which should be:

f = (x + 2x)a
or
f = 3xa


This is a very easy example, what I eventually want to do includes integrations of volumes.

I did find Mupad functions "Simplify" and "Rewrite" but I do not believe they can do what I want here. Is there a function in Matlab or a procedure that can do this automatically?

Shai
  • 111,146
  • 38
  • 238
  • 371
hschokker
  • 69
  • 4
  • Not really familiar with this, but if you just want to get `a` 'outside the brackets', perhaps just divide by `a`? I doubt whether there is any functionality to extract all occurances of `a` (As it may occur in many different ways simultaneously). – Dennis Jaheruddin Jul 11 '13 at 12:04
  • Do you have the Symbolic Toolbox? – Oleg Jul 11 '13 at 12:15
  • I am not yet familiar with the Symbolic Toolbox but it seems to be included at the Matlab installation at our University's computers. – hschokker Jul 11 '13 at 12:34

1 Answers1

0

You wish to substitute for ONLY some of the x elements in the expression? How do you expect a computer to know what you want? Computers are quite literal things. If you tell it that

a = x - 3

then it must also know that

x = a + 3

Therefore,

f = (a+3)a + 2(a+3)a = 3a(a+3)

Only a computer that can read your mind will know that you wish to replace only some of the terms.

  • I am sorry, my example was not the best. It doesn't really matter how the a term in my example is implemented in f, as long as it is there. (preferably in a "clean" way, it is to make the formula of f more easy to understand) I could try and give the original problem in my question, that will make my question probably better to understand. – hschokker Jul 12 '13 at 13:35