MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problems solving using Solve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68850] Re: Problems solving using Solve
  • From: Peter Pein <petsie at dordos.net>
  • Date: Mon, 21 Aug 2006 03:28:01 -0400 (EDT)
  • References: <ec65bn$1f8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

akil schrieb:
> I have a problem suing the following code:
> 
...

> 
> eg.
> {ax,ay}= {-44.9376, 36.1678} and {cx,cy}= {17.8329, 122.477} and 
> {centerOfMassx,centerOfMassy}={-18.6338,72.3356} and rcAB=-0.166667 and 
> rcCD=-0.37931
> 
> Doing the Solve[afg== 0, v] takes ages (after an hour I quit it). Is there 
> any way I can make it work faster? Is any code in Cone such that it 
> unnecessarily makes it run faster? So are there any ways I can try to make 
> everything run faster? Using integers it runs, but it takes too long when 
> using real cones (made up of four points A B C D and a centerOfMass).
> 
> Akil 
> 
> 

Hi Akil,

you should delay the evaluation of afg:

cd[input_, rcCD_, cx_, cy_] := rcCD*input + cy - rcCD*cx;
(* just a guess: *)  ab = cd;
cone[beta_, v_, rcAB_, rcCD_, ax_, ay_, cx_, cy_, centerOfMassx_, 
centerOfMassy_] :=
   Module[{fx, fy, ex, ey, waarde, criticalRC, criticalHeight, 
xVerplaatsing, ePx2Py2},
     fx = x /. Solve[Tan[beta]*(x - v) == cd[x, rcCD, cx, cy], x][[1]];
     fy = cd[fx, rcCD, cx, cy];
     criticalRC = (centerOfMassy - fy)/(centerOfMassx - fx);
     criticalHeight = (-criticalRC)*fx + fy;
     ex = Together[(-ay + rcAB*ax + criticalHeight)/(rcAB - criticalRC)];
     ey = Together[ab[ex, rcAB, ax, ay]];
     xVerplaatsing = ex - v;
     ePx2Py2 = Sqrt[xVerplaatsing^2 + ey^2];
     waarde = xVerplaatsing/ePx2Py2;
     ArcCos[-waarde]
   ];
afg[beta_, v_, rcAB_, rcCD_, ax_, ay_, cx_, cy_, centerOfMassx_, 
centerOfMassy_] :=
    Numerator[Together[D[cone[beta, v, rcAB, rcCD, ax, ay, cx, cy, 
centerOfMassx, centerOfMassy], v]]];

Timing[example = afg[beta, v, 3, 7/4, 7, 4, 21, 11, 13, 7]]
{0.031*Second,
  -2*(-300713 + 531069*Tan[beta] + 19551*v*Tan[beta] + 57513*Tan[beta]^2
  - 88578*v*Tan[beta]^2 + 2793*v^2*Tan[beta]^2 - 306269*Tan[beta]^3 +
  76059*v*Tan[beta]^3 - 3759*v^2*Tan[beta]^3 + 49*v^3*Tan[beta]^3)
}

First[Timing[solVector = v /. Solve[example == 0, {v}]; ]]
0.016*Second

Plot[Evaluate[Re[solVector]], {beta, Pi/12, Pi/2}, PlotStyle -> {Red, 
Green, Blue}, AxesOrigin -> {Pi/4, 0}];
(* Graphics omitted *)

v0 = First[solVector]
(1/7)*(179 - 133*Cot[beta])

Groetjes,
   Peter


  • Prev by Date: Re: Problem with NMaximize
  • Next by Date: AuthorTools "Make Contents" no makes contents?
  • Previous by thread: Re: Problems solving using Solve
  • Next by thread: Re: Problems solving using Solve