|
Re: parabolic trough edge's lengthFrom: mrdovey@iedu.com (Morris Dovey) With the given values for f and dr, it gets results correct to ten 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; do { 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 C:\usr\mrd\c> in just under 5 seconds. Not quite enough time to go for coffee :( -- Morris Dovey
|