Hybrid Car – More Fun with Less Gas

parabolic trough edge's length - Page 2

register ::  Login Password  :: Lost Password?
Posted by dow on July 10, 2010, 3:21 am

I think the integral is:

<integral> sqrt(1 + 4Ax^2 +4ABx + B^2) dx

between whatever limits you want. Maybe I could have integrated it
analytically sometime back in the middle of the last century, but
nowadays I'd do like you did, and just program a computer to grind out
a numerical answer.

The paraboloid problem was a bit different. If f is the focal length,
then we can define k = 4f^2. The integral becomes:

<integral> r.sqrt(k+r^2).(k-r^2) dr

where r is the radius of the rim of the dish. The lower limit of the
integral is zero, but the upper limit is what we want to find in order
to make the value of the definite integral zero. Usually, we know the
limits and want to find the value of the integral. In this problem, we
know the value of the integral and one of the limits, and we want to
find the other limit. Writing a program that would would produce an
answer correct to ten significant digits in less than a human lifetime
was a bit of a challenge!

Fun stuff....


Posted by dow on July 10, 2010, 11:18 pm

I tried writing program to solve your problem. In 13 seconds, it got
an answer correct to only about seven digits. So I guess my 15-year
old 386 is way slower than whatever you're using.

Here's the program I used to solve the paraboloid problem, in QBasic:

f = 1 ' focal length
dr = f / 100000 ' step size
d2 = dr / 2
k = 4 * f * f
t = 0
r = d2
  r2 = r * r
  q = r * (k - r2) * SQR(k + r2)
  t = t + q
  r = r + dr
r = r - d2 - dr * t / q
d = r * r / (4 * f)
a = ATN(r / (d - f)) * 45 / ATN(1)
PRINT "Focal length:"; f; "unit(s)"
PRINT "Depth of dish:"; d; "units"
PRINT "Radius of rim:"; r ; "units"
PRINT "Angular radius of rim, seen from focus:"; a; "degrees"

With the given values for f and dr, it gets results correct to ten
significant digits, but on my machine takes about ten minutes to do
it  How long does it take on your computer?


Posted by Morris Dovey on July 11, 2010, 4:34 pm
 On 7/10/2010 6:18 PM, dow wrote:

I suspect that the long runtime is a result of (re)interpreting the
BASIC source code 100,000 times, rather than a slow processor.

I disposed of my BASIC interpreter not too long after Nick stopped
posting code, so I can't run your code as-is - but I transliterated to C

#include <stdio.h>
#include <math.h>
int main(void)
{  double f = 1;           /* focal length */
    double dr = f / 100000; /* step size    */
    double d2 = dr / 2;
    double k = 4 * f * f;
    double t = 0;
    double r = d2;
    double r2,q,d,a;
    {  r2 = r * r;
       q = r * (k - r2) * sqrt(k + r2);
       t = t + q;
       r = r + dr;
    }  while (t > 0);
    r = r - d2 - dr * t / q;
    d = r * r / (4 * f);
    a = atan(r / (d - f)) * 45 / atan(1);
    printf("Focal length: %G\n",f);
    printf("Depth of dish: %G\n",d);
    printf("Radius of rim: %G\n",r);
    printf("Angular radius of rim, seen from focus %G degrees",a);
    return 0;

then compiled and linked. When I ran the executable I got

C:\usr\mrd\c> dow
Focal length: 1
Depth of dish: 1.84781
Radius of rim: 2.71868
Angular radius of rim, seen from focus 72.6801 degrees

in just under 5 seconds.

Not quite enough time to go for coffee :(

Morris Dovey

Posted by dow on July 11, 2010, 5:32 pm
Well, if you're happy with only six significant digits, you should
have been able to use a much larger value of dr, maybe f/100, which
would have cut your run time to about 0.005 seconds. Even in
interpreted BASIC on my machine, it takes much less than a second.
(I've just tried it.)

Here's the little program I wrote to solve your parabola-length

' y = ax^2 + bx + c
' c is irrelevant
a = 2 ' example values
b = 3
ll = -2 ' lower limit
ul = 2 ' upper limit
n = 100000 ' number of steps
dx = (ul - ll) / n
d = a + a
t = 0
FOR x = ll + dx / 2 TO ul STEP dx
  dd = d * x + b
  t = t + SQR(1 + dd * dd)
l = t * dx
PRINT "Length:"; l

Is that pretty much the same as you wrote?

Evaluating SQRs takes time. Doing many thousands of them takes a lot
of time. I suspect that's what's taking most of the time, in both your
implementations and mine.

I don't feel bad about using computers instead of doing "real"
integrations. If we'd had computers in the 1950s, we'd have used them
then too.


Posted by Morris Dovey on July 11, 2010, 6:50 pm
 On 7/11/2010 12:32 PM, dow wrote:

I'm even easier to please than that since I can't afford machining to
tighter tolerances than +/-0.0002" (roughly +/-0.005mm).

With a tweak to the output format specification (%G -> %12.10f) the code

    Focal length: 1.0000000000
    Depth of dish: 1.8478097550
    Radius of rim: 2.7186833247
    Angular radius of rim, seen from focus 72.6801340944 degrees

in the same time. The C language provides for a "long double" floating
point representation, but I can't imagine actually needing that kind of
precision for any real-world parabolic reflector.

Sorta close - mine won't produce any cumulative error if the machine
isn't capable of exactly representing dx in the number of bits
available, but that's just a nit and easily fixed.

That depends a lot on the underlying hardware and math library. Some
years back I wrote a floating point library for processors having only
integer operations and, to my surprise, square roots didn't require
significantly more processing than plain old division...

I did (a Bendix G-15), and I did - and never overcame my addiction to
ever-higher throughput. That's what motivated me to order a copy of my
old textbook - so I could get rid of the loop. :)

Morris Dovey

This Thread
Bookmark this thread:
  • Subject
  • Author
  • Date
please rate this thread