Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function of two variables $f(r,x,c)$, where $r$ and $x$ are variables and $c$ is a constant that appears in the function.

I would like to write it as a product of two functions $f1(r,c) \times f2(x,c)$.

If I set c = 1 and use FullSimplify, it automatically gives me the function in the form f1[r]*f2[x]. However, if no assumptions about c are provided c, FullSimplify doesn't work.

(Based on the Physics problem I am trying to solve there are reasons to believe that I should be able to write down function in the form $f(r,x,c)=f1(r,c) \times f2(x,c)$ )

Is there any command or procedure in Mathematica to separate the functional dependence of a given function with two variables?

share|improve this question

closed as off-topic by Michael E2, m_goldberg, bobthechemist, Dr. belisarius, Yves Klett Mar 16 '14 at 8:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Michael E2, m_goldberg, bobthechemist, Dr. belisarius, Yves Klett
If this question can be reworded to fit the rules in the help center, please edit the question.

Please post working code and format your question to make it easier to digest (have a look at – Yves Klett Oct 16 '13 at 13:29
Find the needed assumptions on c and provide them to Simplify or FullSimplify? – m_goldberg Oct 16 '13 at 14:23
Since it works for c=1, why not try some other values? Does it decompose for c=2? 10? 0.1? -10? If so, you can probably guess the correct forms for f1 and f2. – bill s Oct 16 '13 at 15:24
Does Factor help? – Daniel Lichtblau Oct 16 '13 at 15:50

We can try to force DSolve to try and solve a separable equation.

In[1]:= separateVariables[F_, vars_] := 
 Module[{mvars = Most[vars], desols, last, u}, 

  desols = MapThread[DSolve[u'[#2]/u[#2] == #1, u[#2], #2] &, 
   {Simplify[D[F, #]/F] & /@ mvars, mvars}];

  If[MemberQ[desols, _DSolve | $Failed] || 
       !And @@ MapThread[FreeQ[#1, Alternatives @@ Complement[vars, {#2}]] &, 
        {desols, mvars}], Return[$Failed]];

  desols = desols[[All, 1, 1, 2]] /. _C -> 1;
  last = Simplify[F/Times @@ desols];

  If[!FreeQ[last, Alternatives @@ mvars], 
   Append[desols, last]]

In[2]:= separateVariables[
 16 Cos[x]^3 Cos[y]^4 Cos[z]^3 Sin[x] Sin[z] - 
 16 Cos[x] Cos[y]^4 Cos[z]^3 Sin[x]^3 Sin[z] - 
 96 Cos[x]^3 Cos[y]^2 Cos[z]^3 Sin[x] Sin[y]^2 Sin[z] + 
 96 Cos[x] Cos[y]^2 Cos[z]^3 Sin[x]^3 Sin[y]^2 Sin[z] + 
 16 Cos[x]^3 Cos[z]^3 Sin[x] Sin[y]^4 Sin[z] - 
 16 Cos[x] Cos[z]^3 Sin[x]^3 Sin[y]^4 Sin[z] - 
 16 Cos[x]^3 Cos[y]^4 Cos[z] Sin[x] Sin[z]^3 + 
 16 Cos[x] Cos[y]^4 Cos[z] Sin[x]^3 Sin[z]^3 + 
 96 Cos[x]^3 Cos[y]^2 Cos[z] Sin[x] Sin[y]^2 Sin[z]^3 - 
 96 Cos[x] Cos[y]^2 Cos[z] Sin[x]^3 Sin[y]^2 Sin[z]^3 - 
 16 Cos[x]^3 Cos[z] Sin[x] Sin[y]^4 Sin[z]^3 + 
 16 Cos[x] Cos[z] Sin[x]^3 Sin[y]^4 Sin[z]^3, {x, y, z}]

Out[2]= {Sin[4 x], Cos[4 y], Sin[4 z]}

In[3]:= separateVariables[6-6 x+3 y^4-3 x y^4-2 z^2+2 x z^2-y^4 z^2+x y^4 z^2, {x, y, z}]
Out[3]= {x-1, y^4+2, z^2-3}

In[4]:= separateVariables[x + y, {x, y}]
Out[4]= $Failed
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.