2
$\begingroup$

my problem is: I get the result of definite integral and now I need to find the upper limit for the same integral but with opposite sign value so f2=-f1.

   f[x_]:=(E^x m (-1 + x - x0) + E^(b x) n (1 + b (-x + x0)))^2 / 
            ( (a E^(b x) + E^x K1) (E^x m -E^(b x) n)^2 (x - x0) )

The values of the parameters are:

    m = 2.017`100;
    n= 0.87`100;
    K1 = 1;
    a = 21.57`100;
    x0 = -1.53`100;
    b = 0.56827`100;
    x1 = 7.8`10;
    x2 = 10;

I was able to calculate the value of the following definite integral:

firstIntegral = NIntegrate[f[x],{x,x1,x2}]

(*Out: 0.0019499644501301185 *)

I am now trying to find the indefinite integral first and then find the upper limit by this:

    f1[x1_, x2_] := Integrate[f[x], {x, x1, x2}]
    FindRoot[ nv[10, x3] == -firstIntegral, {x3, .001}]

A first version of this question was put on hold due to simple syntax mistakes; I re-edited the question to include and clarify this second part of my problem.

$\endgroup$
  • $\begingroup$ Try adding a colon in your function definition, i.e. f[x_] := $\endgroup$ – MarcoB May 19 '15 at 12:49
  • $\begingroup$ After adding the semicolon, evaluate NIntegrate[f[x], {x, x1, x2}] $\endgroup$ – Dr. belisarius May 19 '15 at 12:52
  • 1
    $\begingroup$ Could you tell me, how to solve this problem: we need to get the upper limit for the same integral but the opposite sign value, so the upper limit of the first integral becomes lower for the required integral : firstIntegral=NIntegrate[ f[x], {x, x1, x2}]; upperLimit = Solve[NIntegrate[ f[x], {x, x2, x3}] = firstIntegral, x3] $\endgroup$ – Elka May 19 '15 at 13:23
  • $\begingroup$ @ElviraKadaub there might be a solution for x3<0, but there's a singularity there around -1.53 which maybe has a principal value, so the task at hand isn't exactly trivial. $\endgroup$ – LLlAMnYP May 19 '15 at 14:33
  • 1
    $\begingroup$ Hey @Marco, integral-equation actually means something kinda different from what the OP seems to have, so I removed it. $\endgroup$ – J. M. will be back soon May 19 '15 at 15:56
3
$\begingroup$

Elvira, I am going to put here what I had put together for an answer to your question. There is still something puzzling about your question though, and that is the fact that you are essentially recalculating the same integral twice, it seems to me.

Here is what I mean:

$$\text{firstIntegral}=\int_{x1}^{x2} \! f(x) \, \mathrm{d}x $$

Then you are looking for $x3$ such that

$$\int_{x2}^{x3} \! f(x) \, \mathrm{d}x = -\int_{x1}^{x2} \! f(x) \, \mathrm{d}x $$

but, considering that if you swap the limits of integration, the integral value changes sign, we can write:

$$\int_{x2}^{x3} \! f(x) \, \mathrm{d}x = -\int_{x1}^{x2} \! f(x) \, \mathrm{d}x = \int_{x2}^{x1} \! f(x) \, \mathrm{d}x $$

... so the $x3$ value you are looking for is $x1$! I wonder if I am misreading your question this second time around...

In any case, I'd like to present some machinery that I think might come in handy for you to solve further questions like this one. In the absence of further clarifications, I will use what we learned above about $x3$to check that the numerical results are correct.

As you said, this is the value of your first integral:

firstIntegral = NIntegrate[f[x], {x, x1, x2}]

(* Out: 0.00194996 *)

Symbolic integration of your function f[x] doesn't get very far, at least on my computer and for reasonable waiting time. So I'll tackle your your problem numerically instead.

To do so , I will define a function that calculates your second integral numerically, but that attempts to do so only when it is fed a numerical value for the integration limits, otherwise the NIntegrate function won't be able to complete its task.

secondIntegral[a_?NumericQ, b_?NumericQ] := NIntegrate[f[x], {x, a, b}]

See this FAQ for further explanation on the topic of NumericQ.

Let's take a look at the value of this integral, using $x2$ as the lower integration limit, as you requested:

Plot[secondIntegral[x2, x3], {x3, 5, x2},
 GridLines -> {None, {-firstIntegral}}, GridLinesStyle -> {Thick, Red}
]

Mathematica graphics

In that plot, I put a $y$-axis grid line indicating the value of -firstIntegral, so that gives us an idea of a) whether a solution exists (it does); b) what a rough estimate for $x3$ might be (somewhere around 8).

I will then use FindRoot to solve the equation numerically, using the rough estimate for $x3$ I got from the plot.

FindRoot[secondIntegral[x2, x3] == -firstIntegral, {x3, 8}]

(* Out: {x3 -> 7.8} *)

Notice that we recover the value of $x1$ you had set at the beginning as expected from the discussion above. Do let me know if I am misunderstanding your problem though.

$\endgroup$
  • 1
    $\begingroup$ Thank you @MarcoB. This is my friend's problem I am trying to help with so I'm not that strong in the problem and its analytical solution. But I'll definetly get back to your answer later as soon as she'll take a look on it. $\endgroup$ – Elka May 19 '15 at 16:52
  • $\begingroup$ @ElviraKadaub I wonder if your friend had a chance to take a look at my answer to see whether I am misunderstanding their problem. $\endgroup$ – MarcoB May 20 '15 at 20:47
  • $\begingroup$ You do understand it right, @MarcoB. I'll try to explain her problem: she's investigating the system with duck trajectory, so x1 belongs to the stable part, then it goes to x2 - discontinuity point and then it should move to the unstable condition, so x3 must differ from x1. According to your solution, those limits we used before were not right and she gives new limits х1= 4,35708; х2=7 should be correct but now she couldnt compute the integral due to singularity problem which nable to solve for now. Thanks again. $\endgroup$ – Elka May 20 '15 at 21:22
  • $\begingroup$ @Elvira OK good to know. Well, hopefully my answer can help in some way. Otherwise you/she could always post another question with the new requirements. $\endgroup$ – MarcoB May 20 '15 at 21:24

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.