Simpel beregning af Newtons anden lov
Hej,Jeg har udviklet et produkt som skal kunne beregne den ukendte variable i Newtons anden lov.
Som man kan se her:
http://rtgkom.dk/~sonnyg05/agf/index.php?menu=3&submenu=9
beregner den før man har indtastet værdier, og derfor melder den /0-fejl.
Hvordan kan jeg gøre sådan så den først beregner når man har trykket på knappen?
KODE:
Newtons second law
<br /><br />
F=ma
<br /><br />
F is the force, m is the mass and a is the acceleration - all in SI-units.
<br /><br />
<?php
echo'
<form method=post>
F: <input type="text" name="f">
a: <input type="text" name="a">
<input type=submit value="Beregn den ukendte værdi">
</form>
';
$f = $_REQUEST["f"];
$a = $_REQUEST["a"];
$m = $f / $a;
echo '<br />';
echo "F er: " . $f;
echo '<br />';
echo "m er: " . $m;
echo '<br />';
echo "a er: " . $a;
?>
<br /><br />
<hr />
<br />
The product of the mass and velocity is the momentum of the object (which Newton himself called "quantity of motion").
<br />It should be noted that, as is consistent with the law of inertia, the time derivative of the momentum is non-zero when the momentum changes direction,
even if there is no change in its magnitude. See time derivative.
<br /><br />
If the mass of the object in question is constant this differential equation can be rewritten as:
<br /><br />
F = m a
<br /><br />
where:
<br /><br />
a = dv / dt is the acceleration.
<br /><br />
A verbal equivalent of this is "the acceleration of an object is proportional to the force applied, and inversely proportional to the mass of
the object". If momentum varies nonlinearly with velocity (as it does for high velocities — see special relativity), then this last version is not accurate.
