Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to compute the integral of a polynomial in t, which I know an analitical solution exist. But Mathematica give me as result the input, not the result of the integral:

enter image description here

I already know this since it is the input but I want to compute the value of this integral.

Here is the code if you want to reproduce this (copy-pasted from mathematica, this is indeed ugly):

x[t_] := a0 + a1*t + a2*t^2 + a3*t^3 + a4*t^4 + a5*t^5;

a0 = x0;
a1 = v0;
a2 = acc0/2;
a3 = -((20 x0 - 20 xf + 12 v0 tf + 8 vf tf + 3 acc0 tf^2 - accf tf^2)/(2 tf^3));
a4 = -((-30 x0 + 30 xf - 16 v0 tf - 14 vf tf - 3 acc0 tf^2 + 2 accf tf^2)/(2 tf^4));
a5 = -((12 x0 - 12 xf + 6 v0 tf + 6 vf tf + acc0 tf^2 - accf tf^2)/(2 tf^5));

Jp = 1/2*Integrate[(x[t] - xf)^2, {t, 0, tf}];
Jv = 1/2*Integrate[(x'[t] - (vf + v0)/2)^2, {t, 0, tf}];
J3 = alpha*Jp + (1 - alpha)*Jv

Do you have an idea of what I am doing wrong?

Thnk you in advance

share|improve this question

closed as off-topic by belisarius, Simon Woods, Artes, m_goldberg, rm -rf Feb 18 at 14:52

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Don't use Subscripts until you master Mathematica really well –  belisarius Feb 18 at 2:50
    
Your integral evaluates without problems, try starting a fresh Mathematica session –  belisarius Feb 18 at 7:28
4  
This question appears to be off-topic because it is non-reproducible. The integral evaluates OK –  belisarius Feb 18 at 7:29

1 Answer 1

up vote 0 down vote accepted

It works fine on my MMA(Version 9).

x[t_] := a0 + a1*t + a2*t^2 + a3*t^3 + a4*t^4 + a5*t^5;
a0 = x0;
a1 = v0;
a2 = acc0/2;
a3 = -((20 x0 - 20 xf + 12 v0 tf + 8 vf tf + 3 acc0 tf^2 - accf tf^2)/(2 tf^3));
a4 = -((-30 x0 + 30 xf - 16 v0 tf - 14 vf tf - 3 acc0 tf^2 + 2 accf tf^2)/(2 tf^4));
a5 = -((12 x0 - 12 xf + 6 v0 tf + 6 vf tf + acc0 tf^2 - accf tf^2)/(2 tf^5));
Jp = 1/2*Integrate[(x[t] - xf)^2, {t, 0, tf}];
Jv = 1/2*Integrate[(x'[t] - (vf + v0)/2)^2, {t, 0, tf}];
J3 = alpha*Jp + (1 - alpha)*Jv

(1/55440)alpha tf (3 acc0^2 tf^4 + 3 accf^2 tf^4 + accf tf^2 (tf (52 v0 - 69 vf) + 181 (x0 - xf)) + 4 (tf^2 (104 v0^2 - 133 v0 vf + 104 vf^2) + 3 tf (311 v0 - 151 vf) (x0 - xf) + 2715 (x0 - xf)^2) + acc0 tf^2 (5 accf tf^2 + 69 tf v0 - 52 tf vf + 281 x0 - 281 xf)) + 1/2 (1 - alpha) ((acc0^2 tf^3)/630 + 1/630 acc0 accf tf^3 + ( accf^2 tf^3)/630 + 1/30 acc0 tf^2 v0 + 1/105 accf tf^2 v0 + ( 67 tf v0^2)/140 - 1/105 acc0 tf^2 vf - 1/30 accf tf^2 vf + ( 33 tf v0 vf)/70 + (67 tf vf^2)/140 + (acc0 tf x0)/42 - ( accf tf x0)/42 + (10 v0 x0)/7 + (10 vf x0)/7 + (10 x0^2)/( 7 tf) - (acc0 tf xf)/42 + (accf tf xf)/42 - (10 v0 xf)/7 - ( 10 vf xf)/7 - (20 x0 xf)/(7 tf) + (10 xf^2)/(7 tf))

share|improve this answer
    
You are right, it works fine. The code was actually a little bit longer, but I suppose this is because I used longer execution path (a1, ..., a5 was not initially assigned like this, but came from a Solve function). Thank you for your help –  Alexandre Willame Feb 26 at 19:10

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