jschulzb

150 Reputation

9 Badges

13 years, 314 days

MaplePrimes Activity


These are replies submitted by jschulzb

@Carl Love your right, as far as I can tell, the solutions may be so close together fsolve cant tell them apart. So
if I start at a solution of:
t=0.00005, theta=0.00005 and the REAL next solution is
t=0.0000500001, theta= 0.0000500001,

fsolve may skip it to find something like 
t=0.003, theta=0.003

(I call this teleporting) This only occurs when there exist more than one solution. In my case there are either 1 or 3 solutions which partially depend on the time (t). (Even if time allows for mulitple solutions, the trajectory of the ball may not)

 

@acer  

Unfortunately I don’t think I can use 'avoid' because I have no idea where the other solutions are. The multiple solutions may be arbitrarily close together, and I need fsolve to just find the first one. (I'm solving for t and theta, so the smaller t is considered the first one),

Here's the worksheet. Notice on the bottom aimation the ball jumps across the boundary. (Also any ideas to make the animation smooth and not jumpy? All I could think is to animate a one line at a time between each collision, but that would be kinda annoying) 

 billiard_simulatio.mw

Cool! Thank you very much! Graphing is taking me from ~33-50 seconds on a laptop with an AMD Phenom Quad-core processor. Might I ask if your using a desktop ? Otherwise I'm switching to Intel! 


I can't find any information about the compile=true option in dsolve,  but I can 'compile the procedure', but it doesn't make much difference.

Also whats the purpose of your try X(200); catch "cannot evaluate": end try; statment? 

Cool! Thank you very much! Graphing is taking me from ~33-50 seconds on a laptop with an AMD Phenom Quad-core processor. Might I ask if your using a desktop ? Otherwise I'm switching to Intel! 


I can't find any information about the compile=true option in dsolve,  but I can 'compile the procedure', but it doesn't make much difference.

Also whats the purpose of your try X(200); catch "cannot evaluate": end try; statment? 

Hi, 

     Sorry about the confusion, and the number of questions, anyways here's the code.

restart;
with(DEtools):
with(plots):
with(plottools):

x,y equations

eqy:= diff( y(t), t$2 ) = -9.8  :
eqx:= diff( x(t), t$2 ) = 0  :  

Initial conditions

inty:= D(y)(0) = v*cos(theta):
intx:= D(x)(0) = v*sin(theta):

Numerical solution that stops when y (t) = 3.05, D(y)<0, or the max is under 3.05

soln:= dsolve({eqx, eqy, inty, intx, x(0)=0, y(0)=0}, {x(t), y(t)}, numeric,
          method = rkf45, output=listprocedure, parameters=[v, theta],
          events=[ [ [diff(y(t),t)=0, y(t)<3.05], halt],
                   [ [y(t)=3.05, diff(y(t),t)<0], halt] ] ):

Test a single solution, (it worked)

PARAMS= soln( parameters = [ 14, Pi/4] ):
soln[1](133):
plots[odeplot](soln, [x(t), y(t)], 0..3.05);

Now I want to graph all the intitial conditions that worked (plot v vs theta)

I tried a loop just to find the pairs (v, theta) that worked and print them out.

Y:= t -> rhs( soln[4](t) ) :
for j from 5 by 2 to 20 do
   for i from 5 by 2 to 20 do
      soln( parameters = [ i, j]):
      zmax:= fsolve( rhs( soln[5](t)) = 0, t): # (when D(y) = 0)
      zzero:= fsolve( Y(t)=3.05, t= zmax..infinity):
      if X(zzero) < 6 and X(zzero) > 5 then
         print( i, j);
      else end if;
   end do:
end do:

Which worked for SMALL cases, but is slow and sometimes fails. That's definatly not optimal. So the goal is to find the intital conditions (maybe within range v=0..20, theta= 0..Pi/2) that cause event #2 to occur, and plot them. I suppose I should store the working values in a sequence, and plot the sequence?

Anyways, thank you a lot for your time.

@acer Hi, that's awesome Maple has this built in! Unfortunatly the help page is quiet complicated and the examples don't exactly fit what I'm trying to do.

I want to solve a projectile motion (basket ball) question numerically because of drag/magnus forces. If it's launched from 2m and wants to land in a hoop thats 3m high and 6m away, I want to see what initial velocities and angle will work. Ignoring the backboard for now,  I would intuitively want to use a for loop for theta and v, solving the equation each time and finding the intitial conditions that work, but this is rather slow. Using events I would think use dsolve( event y(t)=0, if x(t) is within hoop plot it on a graph of theta vs v, else try new initial conditions).

 

I'm sure theres a more efficient way, any suggestions? I'm quiet interested in simulations with dsolve, is there any full/more detailed examples using events in dsolve?

@acer Hi, that's awesome Maple has this built in! Unfortunatly the help page is quiet complicated and the examples don't exactly fit what I'm trying to do.

I want to solve a projectile motion (basket ball) question numerically because of drag/magnus forces. If it's launched from 2m and wants to land in a hoop thats 3m high and 6m away, I want to see what initial velocities and angle will work. Ignoring the backboard for now,  I would intuitively want to use a for loop for theta and v, solving the equation each time and finding the intitial conditions that work, but this is rather slow. Using events I would think use dsolve( event y(t)=0, if x(t) is within hoop plot it on a graph of theta vs v, else try new initial conditions).

 

I'm sure theres a more efficient way, any suggestions? I'm quiet interested in simulations with dsolve, is there any full/more detailed examples using events in dsolve?

hmm... can that method be easily generalized? for instance instead of finding a zero, can I find a point when y=1.04? (if two or more points exist). 

My issue is im trying nested for loops to find a solution but the fsolves  and dsolve, nuemrics slow down the loop a lot.

Thanks

hmm... can that method be easily generalized? for instance instead of finding a zero, can I find a point when y=1.04? (if two or more points exist). 

My issue is im trying nested for loops to find a solution but the fsolves  and dsolve, nuemrics slow down the loop a lot.

Thanks

thanks guys!  I ended up using the DE method, but since I wish to animate it later I'm gunna try the spacecurve method now, 

thanks guys!  I ended up using the DE method, but since I wish to animate it later I'm gunna try the spacecurve method now, 

1 2 3 Page 3 of 3