Step 7 Dec 2010 Puzzle

Its just basic calculation of line from point x(0),y(0) to x(1),y(1) and making small step in that line. Its pretty slow, adding more accuracy (making smaller steps) gets it very slow. I wrote it in SCL, i have not optimized it at all yet. I have some things already in mind what to do for it.
 
Hmh, I had error in my travel calculation (Rabbit[2].y instead of Rabbit[1].y, should not copypaste so much ;). Travel is ~30,4. Btw. I assumed travel to approximate center.
 
Last edited:
They start out 32m apart, they are always travelling at right angles to each other so each rabbit must travel 32m before they meet.
 
Best i could get off for now is ~31. I think i need to take fractional part off of the integer part to get it. That ~31 was with rabbits at (15,41...)x, (15,44...)y. Floats don't just work with small enough additions.
 
So how small did you make your steps?

Floats don't just work with small enough additions.
You must be trying very small steps. The mantissa should be accurate to one part in 16 million ( 16,777,216 ) 32/16,000,000=0.000002. If the steps were as small as 0.001 you should be able to get closer to 32 for the total distance traveled. I will work this out on Mathcad. I know it is cheating but the answer will be accurate.

I made this during the time I had to do edits
http://www.deltamotion.com/peter/Mathcad/Mathcad - rabbits.pdf
The distance does approach 32 and maybe a little more. Mathcad uses 64 bit floats so it is more accurate. I changed the steps from 0.01 to 0.001. 0.001 came close to a path distance of 32.
You can see I used a brute force approach. Nothing tricky.

TurboUrpo, from what I have seen the paths should be longer than 32 with bigger deltas.
 
Last edited:
I'm not very firm with complex numbers, but does anyone know if such a thing would be easier to calculate with complex numbers in polar coordinate system?

At leat to see what result I get I've done this with a little C programm. With 128000 iterations I came to a distance of 32.0015.

Here's my calculating loop:
Code:
    // factor max length of one step
    deltafac = 0.0001;         
    // startposition
    p1.x = 16.0;
    p1.y = -16.0;    
    for (long i = 0; i < 128000; i++){
        // Point to track to is our own point rotated by 90 degrees anticlockwise.
        // Calculating of p3 and p4 is  not necessary to calculate distance,
        // only for printing data with gnuplot
        p2.x = -p1.y;   p2.y = p1.x;
        p3.x = -p2.y;   p3.y = p2.x;
        p4.x = -p3.y;   p4.y = p3.x;               
        // get distance and limit length of step
        dx = (p2.x - p1.x) * deltafac;
        dy = (p2.y - p1.y) * deltafac;
        distance += sqrt(dx*dx + dy*dy); 
        // make step
        p1.x += dx;
        p1.y += dy;
    }
 
Thomas, this is vector math. First you need to create a unit vector and then multiply by the deltafac. You didn't create the unit vector so your steps will get smaller and smaller as the rabbit reach the center.

Look at my pdf. It is simple stuff that a high school student can work out.

If I wanted to this right I would use Runge Kutta which is a much more sophisticated and accurate iterative procedure.
 
Run rabbit run

http://www.deltamotion.com/peter/Mathcad/Mathcad - rabbits.pdf
I updated my pdf to show how this problem is solved using differential equations instead if difference equations. The advantage is that I can use 1/100 th the number of iterations and still get an answer with only 60% of the error using difference equations.

I am convinced that the distance traveled by each rabbit is 32 as LD said. However, that it only true if the rabbits follow the exact path. Since the solution is computed iteratively the rabbit path doesn't turn as fast a the correct path so the path will be a little longer. For instance the first iteration goes towards the next corner and doesn't take into account the rabbit in that corner is moving during the iteration so that iterative path is alway a little wider and longer. As the accuracy goes up the length of the path will approach 32. Those of you that got path lengths less than 32 have made an error somewhere.
The key to this problem is calculating the unit vector.
 
They start out 32m apart, they are always travelling at right angles to each other so each rabbit must travel 32m before they meet.
It makes intuitive sense. Have you proven it?


That is a proof. It expresses, in geometric terms, the same fundamental idea as


lim(ΔL->0) [(sqrt((D-ΔL)**2 + ΔL**2)-D)/((L+ΔL)-L)] = -1
 
Last edited:
Is a decade too late for an analytical solution?

32m is the answer (not 42 mind you, but okay), or at least it would be the answer, if they ever got there.


Here is another* analytical solution (linear differential equations are so much easier to solve ... :).


* LD proved it first.

xxx.jpg
 
Last edited:

Similar Topics

I am having a step7 v5.4 program where the blocks are encrypted and locked. And the manufacturer is stopped the support. Is there any ways to...
Replies
2
Views
177
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
248
HI! HOW COULD I OBTAIN THE NAMES OF THE STEPS OF A ROUTINE IN SFC LANGUAGE IN STUDIO5000? Or is there a system variable that gives me those...
Replies
0
Views
339
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
547
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
674
Back
Top Bottom