2
$\begingroup$

I'm completely new to Mathematica. I got a 14 day free trial and I'm using the online version. I'm trying to use it to check the results of an integration I performed by hand. But I'm not getting any results due to an internal error ("too much recursion"). What am I doing wrong, and how can it be fixed?

T1[t_] := dy * ((b x y + c x) / (e y + f) + g x ) - dx * (a / e x Log[e y + f]) /. x -> px + t dx /. y -> py + t dy
FullSimplify[Integrate[T1[t], {t, 0, 1}]]

This is to solve the problem $$\int_0^1 \Delta_y \left( \frac{b x y + cx}{ey + f} + gx \right) - \Delta_x \left( \frac{a}{e} x \ln (ey + f) \right) \> dt,$$ where $x = p_x + t \Delta_x, y = p_y + t \Delta_y$, and $a$ through $g$ are constants. $p_x, p_y, \Delta_x, \Delta_y$ can also be considered as constants that do not depend on $t$.

The error given is:

InternalError: too much recursion

As I say, I computed the integral by hand but I want to check it. Thanks for any help.

$\endgroup$
4
  • $\begingroup$ How to $ p_x $ and $ \Delta_x $, et c., depend on $ t $? $\endgroup$
    – Pillsy
    Nov 23, 2015 at 18:36
  • $\begingroup$ Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Nov 23, 2015 at 19:44
  • $\begingroup$ $p_x, p_y, \Delta_x, \Delta_y$ are constants and don't depend on $t$. $\endgroup$ Nov 23, 2015 at 19:50
  • $\begingroup$ It will possibly help if you can supply appropriate assumptions for your parameters. $\endgroup$
    – george2079
    Nov 23, 2015 at 21:23

2 Answers 2

0
$\begingroup$

Its useful to minimize the number of parameters in your expression as much as possible. Fundamentally you have things that look like this:

 Integrate[ t  Log[a + b t], {t, 0, 1}]

With just two parameters this quickly returns a conditional expression:

ConditionalExpression[((2 a - b) b + 2 a^2 Log[a] + 2 (-a^2 + b^2) Log[a + b])/( 4 b^2), (Im[a] >= 0 && Im[b] >= 0) || (Im[a] <= 0 && Im[b] <= 0) || Re[a] >= (Im[a] Re[b])/Im[b] || Im[a]/Im[b] <= -1]

We can see quickly it wants a,b to be real:

Integrate[ t  Log[a + b t], {t, 0, 1}, 
    Assumptions -> {Element[{a, b}, Reals]}]

ConditionalExpression[((2 a - b) b + 2 a^2 Log[a] + 2 (-a^2 + b^2) Log[a + b])/(4 b^2), a >= 0 && a + b >= 0]

 Integrate[ t  Log[a + b t], {t, 0, 1}, 
     Assumptions -> { a>=0,a+b>=0}] (* the inequalities imply Real *)

((2 a - b) b + 2 a^2 Log[a] + 2 (-a^2 + b^2) Log[a + b])/(4 b^2)

Now we know the assumptions to use with the original:

 Integrate[T1[t], {t, 0, 1}, 
       Assumptions -> {f + e py >= 0, f + e py + e dy >= 0}]

(1/(4 dy^2 e^3))(dy e (4 c dx e + a dx^2 dy e - 2 a dx^2 f + 2 dx dy e^2 g + 4 a dx dy e px + 4 dy e^2 g px + 2 b (dx dy e - 2 dx f + 2 dy e px) - 2 a dx^2 e py) + 2 (-a dx (f + e py) (dx f - 2 dy e px + dx e py) - 2 b f (dx f - dy e px + dx e py) + 2 c e (-dy e px + dx (f + e py))) Log[f + e py] + 2 (-2 (c e - b f) (-dy e px + dx (f + e py)) + a dx (f + e (dy + py)) (-2 dy e px + dx (-dy e + f + e py))) Log[ f + e (dy + py)])

$\endgroup$
1
  • $\begingroup$ Thanks. I switched to running a local rather than online version, and included the assumptions as you indicated. Then I was able to do the integration and it matched my longhand version. $\endgroup$ Nov 24, 2015 at 14:06
2
$\begingroup$

I'm not sure, what exactly goes wrong on your machine, but here it works. Maybe one note, if your integral behaves well, then you could calculate the indefinite integral, which is faster by ages because Mathematica does not check conditions etc.

expr = dy ((b x y + c x)/(e y + f) + g x) - 
    dx (a/e x Log[e y + f]) /. {x -> px + t dx, y -> py + t dy};
Integrate[expr, t]

Or you say explicitly that conditions for the integral should not be calculated. It is not as fast as the above solution, but still faster then your try

Integrate[expr, {t, 0, 1}, GenerateConditions -> False]

I checked whether my expr is the same as your T1[t].

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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