You are here: Re: WTC Towers: The Case For Controlled Demolition « PHP Programming Language « IT news, forums, messages
Re: WTC Towers: The Case For Controlled Demolition

Posted by Toby A Inkster on 12/20/07 15:57

schoenfeld.one wrote:

> Simulates a top-down demolition of WTC 1 in SI units.
>
>> wtc1 :: Double
>> wtc1 = cascadeTime 417 110 93
>
> Simulates a top-down demolition of WTC 2 in SI units.
>
>> wtc2 :: Double
>> wtc2 = cascadeTime 417 110 77

If you're going to post conspiracy theories to comp.lang.php, at least
have the decency to port them to PHP.

<?php

define('G', 9.8);
$u = array();

function cascadeTime ($_H, $_N, $_J)
{
$j = $_N - $_J;
$n = $_N - $j;
$h = $_H / $_N;

$sum = 0;
for ($k=0; $k<=$n; $k++)
{
$z = u($_H, $_N, $_J, $k);
echo "\$z is $z\n";
$sum += (sqrt(($z^2) + (2 * G * $h)) - $z) / G;
}

return $sum;
}

function u_recursive ($_H, $_N, $_J, $k)
{
if ($k==0) return 0;

$j = $_N - $_J;
$n = $_N - $j;
$h = $_H / $_N;

$R = u_recursive($_H, $_N, $_J, $k-1);
return ( ($j+$k-1) / ($j+$k) ) * sqrt( ($R^2) + (2*G*$h) );
}

/* Original recusive definition of u() can hit up
* against PHP's function call stack. */
function u ($_H, $_N, $_J, $k)
{
global $u;
$u[$_H][$_N][$_J][0] = 0;

if (isset($u[$_H][$_N][$_J][$k]))
return $u[$_H][$_N][$_J][$k];

$j = $_N - $_J;
$n = $_N - $j;
$h = $_H / $_N;

for ($i=1; $i<=$k; $i++)
if (!isset($u[$_H][$_N][$_J][$i]))
$u[$_H][$_N][$_J][$i] =
( ($j+$i-1) / ($j+$i) ) *
sqrt( ($u[$_H][$_N][$_J][$i-1]^2) + (2*G*$h) );

return $u[$_H][$_N][$_J][$k];
}

echo "WTC1 " . cascadeTime(417, 110, 93) . "\n";
echo "WTC2 " . cascadeTime(417, 110, 77) . "\n";

?>

I think I probably made a mistake porting though, as my results don't
quite match yours. My Haskell isn't what it once was. I think the problem
is in u().

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 13 days, 1:36.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация