'YES') { $m1 = -26.74; $d1 = 1; $m2 = 1; $d2 = ''; $init = 'YES'; } // ---------------------------------------------------- // Read and count input argument values from interface. $ArgCount = $unknown = 0; $unk = ''; $m1 = trim(@$_POST['m1']); if (is_numeric($m1)) {$ArgCount++;} else {$unknown=1; $unk = 'm1'; $unkstr = 'm1';} $d1 = trim(@$_POST['d1']); if (is_numeric($d1)) {$ArgCount++;} else {$unknown=2; $unk = 'd1'; $unkstr = 'd1';} $m2 = trim(@$_POST['m2']); if (is_numeric($m2)) {$ArgCount++;} else {$unknown=3; $unk = 'm2'; $unkstr = 'm2';} $d2 = trim(@$_POST['d2']); if (is_numeric($d2)) {$ArgCount++;} else {$unknown=4; $unk = 'd2'; $unkstr = 'd2';} // AT THIS POINT, ALL KNOWN ARGUMENTS SHOULD // BE ENTERED AND ONLY ONE ARGUMENT LEFT BLANK. // (ArgCount) SHOULD BE 3 AND (unknown) SHOULD // HOLD THE INDEX SWITCH INDICATING THE VALUE // TO BE COMPUTED. ANY OTHER VALUES INDICATES // AN ERROR CONDITION. /* m1 = Brighter magnitude m2 = Fainter magnitude m2 = 5*log(d1/d2) + m1 */ // Compute unknown (x) for any given 3 known variables. // antilog10(x) = pow(10, x) $x = $units = ''; switch ($unknown) { case 1: $x = $m2 - 5*Log10($d2/$d1); // Compute (x=m1) from (m2, d1,d2) $x = sprintf("%+1.6f", $x); break; case 2: $x = $d2 / pow(10, ($m2-$m1)/5); // Compute (x=d1) from (m1,m2, d2) $x = sprintf("%1.6f", $x); $units = ' units'; break; case 3: $x = 5*Log10($d2/$d1) + $m1; // Compute (x=m2) from (m1, d1,d2) $x = sprintf("%+1.6f", $x); break; case 4: $x = $d1 * pow(10, ($m2-$m1)/5); // Compute (x=d2) from (d1, m1,m2) $x = sprintf("%1.6f", $x); $units = ' units'; break; } if ($x == '') { $out = " Enter any three known numeric variables
leaving the one unknown variable blank\nand then click the [COMPUTE] button.\n\nThat unknown blank value will be computed\nand then displayed in this output box."; } else { // ---------------------------- // Collect output computations. $out = " Computed unknown $unkstr  =  $x "; } // alpha centauri A mag = -0.01 dist = 4.365 0.007 LY print <<< _HTML $_INTERNAL_PAGE_TITLE_
$_PAGE_HEADING_

A body with apparent stellar magnitude:

m1 =    at distance   d1 =   units  


Would have the apparent stellar magnitude:

m2 =    at distance   d2 =   units  
$out  $units
 

Enter any three known values and leave the unknown value blank.  This program will then compute and display the unknown value from the three given known values.  The body can be a star, planet, asteroid, etc., - any object to which we apply the stellar magnitude system.  The distance can be taken as being in any convenient, units, such as kilometers, miles, AUs, light years, etc., whatever you decide the units represent. 


Apparent Stellar Magnitude With Respect to Distance

Using the following equations, we can mathematically move a star around in space and compute its apparent brightness at any given distance from any given known starting values.  This also allows us to mathematically compare the relative brightness of any two stars side-by-side at any common distance.  For example, we might wish to compute how bright a star our sun would appear to be in the sky of a planet orbiting a star $RandLY light years away or how the brightness of the sun would compare with another star, side-by-side, at any given distance.

NOTE:
  • These equations were not meant for extreme distances, like far beyond our own galaxy.  Distances that extreme require special, sometimes complicated corrections outside the scope of this simple program.  Here, space is being treated as 'crystal' clear and free of any obscuring dust or gas.
Let:
m1  =  Apparent magnitude of a star as viewed from distance d1
m2  =  Apparent magnitude of the same star as viewed from distance d2

The distance can be in any convenient units, such as AUs, light years, etc.

The relationship between apparent magnitude and distance may be expressed in terms of any of the four variables according to the following equations where each variable is defined in terms of the other three.

Using any convenient units of distance, the general mathematical relationship between stellar magnitude and distance may be expressed as:



Eq. 1

From which it follows that:



Eq. 2



Eq. 3



Eq. 4



Eq. 5

© Jay Tanner - PHP Science Labs $cYear - $ProgramVersion
_HTML;