2
$\begingroup$

I have an immense expression of the form

$$ \sum_i \frac{f_i(X,Y,x,y)}{(a_iX^2+b_iY^2+c_ix^2+d_iy^2)(e_iX^2+g_iY^2+h_ix^2+k_iy^2)}, $$ where at $a_i$ or $b_i$ AND $e_i$ or $g_i$ is different from zero.

How can I alter this expression, in an automated form, so as to cut off every term, in each factor of the denominator, that does not contain $X$ or $Y$?

That is, the expression is to become

$$ \sum_i \frac{f_i(X,Y,x,y)}{(a_iX^2+b_iY^2)(e_iX^2+g_iY^2)}. $$

How can this be done?

$\endgroup$
4
  • $\begingroup$ Perhaps newdenominator=denominator//.{x->0,y->0}. Please test that carefully to make certain that it is exactly correct. If so then use that newdenominator inside your sum. $\endgroup$
    – Bill
    Oct 1 '21 at 4:58
  • $\begingroup$ @Bill that depends on how the actual expression is. If it has for example 1/x or 1/x^2 or such, it will cause divide by zero or some other problem. It was not clear from the question, since no actual MWE was given. But if the denominator has the exact same form shown, I think setting x and y to zero should work also. $\endgroup$
    – Nasser
    Oct 1 '21 at 5:09
  • $\begingroup$ @Bill It occurred to me that separating each term in Numerator and Denominator, setting x,y to zero and then reassemble the complete expression would be the way to do it, however I couldn't set up a correct syntax for it. $\endgroup$
    – GaloisFan
    Oct 1 '21 at 15:38
  • $\begingroup$ @Nasser That won't happen because the denominators are never of the form 1/(x,y)^2 because on each term either the x or the y coefficient is different from zero and the f are polynomials. $\endgroup$
    – GaloisFan
    Oct 1 '21 at 15:41
2
$\begingroup$

Consider this expression

expr = Sum[
  f[i][X, Y, x, y]/
     (a[i] X^2 + b[i] Y^2 + c[i] x^2 + d[i] y^2)/
     (e[i] X^2 + g[i] Y^2 + h[i] x^2 + k[i] y^2), {i, 1, 3}]

Since Numerator and Denominator can be used to isolate the $f_i$'s of each term of this expression, we can do this

Numerator[#]/(Denominator[#] /. {x -> 0, y -> 0}) &  /@ expr

But, Numerator may not be able to identify all of your $f_i$'s.

$\endgroup$
1
  • $\begingroup$ The f's are polynomial expressions, so I think it will work fine! Thank you! $\endgroup$
    – GaloisFan
    Oct 1 '21 at 15:45
3
$\begingroup$

You can try

Clear["Global`*"]
oneTerm = f[X, Y, x, y]/((a*X^2 + b*Y^2 + c*x^2 + d*y^2)*(e*X^2 + g*Y^2 + h*x^2 + k*y^2))
cleanOneTermInSum[oneTerm, X, Y]

which takes

Mathematica graphics

and returns

Mathematica graphics

Since you did not post an actual sum in Mathematica code, I can't try it on your code to make sure it works. You can now wrap each one of the terms in the sum by the above call.

The idea is to look at the denominator, and use Select with FreeQ to remove unwanted expressions.

Clear["Global`*"]
oneTerm = f[X, Y, x, y]/((a*X^2 + b*Y^2 + c*x^2 + d*y^2)*(e*X^2 + g*Y^2 + h*x^2 + k*y^2));

cleanIt[expr_, X_, Y_] := Select[expr, Not[ FreeQ[#, X] && FreeQ[#, Y]] &];(*helper*)

cleanOneTermInSum[term_, X_Symbol, Y_Symbol] := Module[{den, cleanDen, cleanExpr},

    den = Denominator[term];

    If[AtomQ[den],
        cleanExpr = term
        ,
        If[Head[den] === Times,
            den = List @@ den;
            cleanDen = Map[cleanIt[#, X, Y] &, den];
            cleanExpr = Numerator[term]/(Times @@ cleanDen)
        ,
            cleanDen = cleanIt[den, X, Y];
            cleanExpr = Numerator[term]/cleanDen 
        ]
    ];
    
    cleanExpr
]
$\endgroup$
1
  • $\begingroup$ Thank you! Upvoted. I'll try to understand the code soon. $\endgroup$
    – GaloisFan
    Oct 1 '21 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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