4
$\begingroup$

Is there a general way of re-writing a function of two variables as a product of two functions,

$$f(x, y) = g(x)h(y)$$

Specifically, I’m trying to write an expression,

$$f(x, y) = \frac{a y - x}{y - 1} = g(x) h(y)$$

$\endgroup$
  • 1
    $\begingroup$ Do you mean $f(x,y)=g(x)h(y)$? $\endgroup$ – SneezeFor16Min Jun 28 at 17:08
  • 1
    $\begingroup$ Yes! Let me change $\endgroup$ – Daniel Farrell Jun 28 at 17:12
  • $\begingroup$ I guess you can use Factor. If it doesn't work, decomposition may be difficult or impossible. $\endgroup$ – SneezeFor16Min Jun 28 at 17:17
  • 1
    $\begingroup$ Ok will read about that function, thanks $\endgroup$ – Daniel Farrell Jun 28 at 17:17
  • 1
    $\begingroup$ This is like the process in solving separable differential equations, but your specific example is not separable. A well-written function should so indicate. $\endgroup$ – Michael E2 Jun 28 at 17:32
5
$\begingroup$
decompose[
  expr_,
  vars_?(ListQ[#] && Length[#] >= 2 && VectorQ[#, AtomQ] &),
  dom_ : Reals
] := If[
        VectorQ[Keys[#], k \[Function] Length[k] <= 1],
                    {True, Times @@@ Apply[Power, #, {2}]},
        (* Else, do some math.
           True: Decomposable but `FactorList` failed.
           @PleaseCorrectGrammarMistakes *)
        (r \[Function] If[r,
                    {True, <||>},
        (* False: Undecomposable *)
                    {False, Null},
        (* Else: With condition *)
                    {ConditionalExpression[True, r],
                      Null}]
        )@ Resolve[ForAll[vars,
                     FunctionDomain[expr, vars, dom],
                     Reduce[
                       expr^(Length[vars] - 1)*D @@
                          Flatten[{expr, vars}]
                       == Times @@ (D[expr, #] & /@ vars),
                     dom]], dom]
      ] &@GroupBy[
            FactorList[expr],
            vars \[Intersection] Level[#[[1]], {-1}] &
      ]

For example:

decompose[(a y - x)/(y - 1), {x, y}]
{ConditionalExpression[True, a == 0], Null}
decompose[
 (Log[x] + (x - 1)/Sqrt[x]) (y^2 + Sqrt[y] + y) // Expand,
 {x, y}
 ]
{True, <|{} -> 1, {x} -> (-1 + x + Sqrt[x] Log[x])/Sqrt[x], {y} -> 
   Sqrt[y] (1 + Sqrt[y] + y^(3/2))|>}
decompose[
 (Log[x] + (x - 1)/Sqrt[x]) (y^2 + Sqrt[y] + x y) // Expand,
 {x, y}
 ]
{False, Null}
decompose[
 2 x^2 (1 + y) z Sqrt[z] // Expand,
 {x, y, z}]
{True, <|{} -> 2, {x} -> x^2, {z} -> z^(3/2), {y} -> 1 + y|>}
decompose[
 2 x^2 (1 + y) z Sqrt[x + z] // Expand,
 {x, y, z}]
{False, Null}
| improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ Thanks. It seems my expression is not decomposable. $\endgroup$ – Daniel Farrell Jun 28 at 18:15
  • $\begingroup$ Your answer is very good. I would like to know if there is any theoretical proof for this question. If so, it is better to give a link to this textbook. $\endgroup$ – Ordinary users68 Jun 29 at 0:30
  • 1
    $\begingroup$ @PleaseCorrectGrammarMistakes Thanks. But I am just taking advantage of FactorList and no math is involved. I've seen your answer and perhaps you can turn it into code. $\endgroup$ – SneezeFor16Min Jun 29 at 3:43
3
$\begingroup$

I found that there are similar questions in the course of mathematical analysis compiled by 史济怀 of China. I pasted the questions and the reference answers as follows:

enter image description here

On page 492 of this book, we can find a brief reference answer:

enter image description here

In short, if $u(x,y)$ can be decomposed into the product of two monomials, then the second mixed partial derivative of $\ln u(x,y)$ should be 0.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ 数学分析这块快忘光了.但如果$u(x,y)$可取负值,结论还成立吗? $\endgroup$ – SneezeFor16Min Jun 29 at 3:39
  • $\begingroup$ @SneezeFor16Min 经过询问哆嗒数学群(群号128709478)里面的北京大学的小米(QQ2498412165),他说仍然成立,只是多一些讨论罢了。 $\endgroup$ – Ordinary users68 Jun 29 at 3:54
  • 1
    $\begingroup$ Okay, I think we should stay in English. Will you post code from this proof? If not, I'll update my answer. :) $\endgroup$ – SneezeFor16Min Jun 29 at 4:06
  • 1
    $\begingroup$ @SneezeFor16Min 我不贴了,你把你的答案更新就好了。 $\endgroup$ – Ordinary users68 Jun 29 at 4:18

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