2
$\begingroup$

I want to compute the drag of a plate enter image description here

Below is the code I am using to integrate the function

velcenter = {dotx, doty, 0};                     
 r = {Cos[θ[t]], Sin[θ[t]], 0};
veltanA = {-Sin[θ[t]], Cos[θ[t]], 0};
 velxpoint = Part[Cross[velcenter, r], 3];
 dragD = 1/2*ρ*cofD*h*Integrate[(Abs[velxpoint - s*dotθ])*(velcenter + 
                                       s*dotθ*veltanA), {s, a - l, a}];

The integration is so slow and I want to speed it up. Any suggestions are welcome !

$\endgroup$
4
  • $\begingroup$ conbine the Abs functon and the integrate function .the runing time is unbelievable $\endgroup$
    – Ann
    Feb 26, 2014 at 8:41
  • $\begingroup$ Is your integrand intended to be a scalar or a vector ? $\endgroup$ Feb 26, 2014 at 8:49
  • $\begingroup$ integrand is a vector,3-D $\endgroup$
    – Ann
    Feb 26, 2014 at 13:29
  • $\begingroup$ The difficulty lies in the integral variable in Norm function,it makes the running time longer $\endgroup$
    – Ann
    Feb 28, 2014 at 1:06

1 Answer 1

3
$\begingroup$

Integrate seems to prefer Sqrt[x^2] instead of Abs[x]. It also is wise to suppress Sin and Cos temporarily. I would assume you do know for which parameters your integrand is
valid, thus you can use GenerateConditions -> False. Then:

velcenter = {dotx, doty, 0};
r = {Cos[θ[t]], Sin[θ[t]], 0};
veltanA = {-Sin[θ[t]], Cos[θ[t]], 0};
velxpoint = Part[Cross[velcenter, r], 3];
SetOptions[Integrate, GenerateConditions -> False];
dragD = 1/2*ρ*cofD*h*
    Inactive[Integrate][(Abs[velxpoint - s*dotθ])*(velcenter + s*dotθ*veltanA), 
              {s, a - l, a}] /.Cos -> Inactive[Cos] /. Sin -> Inactive[Sin]

AbsoluteTiming[
 res = Activate[Activate[dragD /. Abs :> (Sqrt[#^2] &), Integrate]] /. 
   Sqrt[zz_^2] :> Abs[zz]]

gives, after about half a minute (on my 2011 laptop) with Mathematica 10.3

enter image description here

You can check a specific point, e.g.:

Activate[
  (dragD==res) /. {dotx -> .2, doty -> .3, θ[t]-> 2., ρ->.2,
                   a-> 2.4,h-> 3.,l-> .9, dotθ-> .6,cofD -> .6}
]
$\endgroup$

Your Answer

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

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