1
$\begingroup$

I have an integral of a term which first needs some massaging, e.g. (EDIT: Made the integral in such a way that it cannot be pulled out)

Integrate[f[x](Integrate[g[x,y],{y,0,x}]*Integrate[h[x,y],{y,-1,0.3x}]),x] 

where f[x]=Sum[a[i] T[i, x], {i, 0, 10}] and g[x,y]=Sum[a[i,j] T[i, x] T[j, y], {i, 0, 10}, {j, 0, 10}] (Similarly h). I wrote it in this way to reference Truncation by coefficient size .

The coefficients are numerical and I will, after taking their product, chop the products of coefficients after a certain size. After this has been done I want to replace T by the actual functions and evaluate the integrals.

Doing this using Hold does not produce the desired result, since Chopof a product won't work unless expanded, however Holdprecisely forbids the product to expand. And I also have two Holdsif I naively just put hold around the Integrate.

How would I best proceed? Any way to tell Mathematica that I want only the Integrate to evaluate last, but still be able to take products and other operations on the integrands?

$\endgroup$
8
  • $\begingroup$ Not sure whether I understand your problem, but perhaps you are looking for Inactive instead of Hold? $\endgroup$ Commented Jan 28, 2024 at 21:16
  • $\begingroup$ I also don't understand what you're asking. Can you maybe walk through part of the "massaging" process? And why don't you just do this "massaging" before you take the integral? $\endgroup$ Commented Jan 28, 2024 at 22:04
  • $\begingroup$ @lericr The massaging in question is described in the second paragraph. I essentially need to truncate the product of series expansions to a certain order. The reason I cannot do this before integration is because I cannot pull out the integral completely, since some terms in the actual expression are not part of it. (It's a nested integral with sums etc.) And inserting the integrals to the final expression is not viable, since all terms get mixed up. $\endgroup$ Commented Jan 29, 2024 at 8:19
  • $\begingroup$ I'll try Inactive today and come back to you. Thanks for the hint, looks promising. @Domen $\endgroup$ Commented Jan 29, 2024 at 8:20
  • $\begingroup$ Sorry, I'm rather busy at the moment, maybe tomorrow. @Domen $\endgroup$ Commented Jan 29, 2024 at 16:38

1 Answer 1

0
$\begingroup$

You may write your integral like:

Integrate[f[x]g[x,y],{y,0,x}],x] 

Now you can expand f[x]g[x,y] and truncate. E.g.:

SeedRandom[1]; a[i_] := RandomReal[{0, 1}] a[i_, j_] := RandomReal[{0, 1}] g[x, y] = Sum[a[i, j] T[i, x] T[j, y], {i, 0, 10}, {j, 0, 10}]; f[x] = Sum[a[i] T[i, x], {i, 0, 10}]; Chop[Expand[f[x] g[x, y]], 1.3] 

Then you can replace T[..,..] by the real function: fun. If you want to write this in one single statement:

Integrate[Chop[Expand[f[x] g[x, y]], 1.3] /. T[i_, x] -> fun[i, x], {y,x},x] 
$\endgroup$
1
  • $\begingroup$ Sorry, my minimal working example really doesn't capture the difficulty, I'll try to edit my question in such a way to make these types of manipulations impossible. (Unless of course it still works, then good for me.) $\endgroup$ Commented Jan 29, 2024 at 12:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.