tags:

views:

161

answers:

6
+3  Q: 

Formulas in PHP

To a person skilled in programming, I know this question might seem ridiculous, but please bear with me. I'm involved in a court case and a critical point hinges on the answer to a couple of questions.

Given a mathematical formula, along with complete formula documentation as shown here: alt text
(Pixelated some of the descriptors)

  1. In solving the equation for P, is there ANY requirement or need to implement the formula in Microsoft Excel prior to implementing it in PHP source code?

  2. Could a competent PHP programmer just type the formula into PHP source code without the use of Microsoft Excel in the interim?

Thank you very much!

+8  A: 

1: No, I (and many here) probably really would not get the use of excel. 2: Absolutely.

A thing you have to realize though is that programming languages seldom deal in 'equations', they aren't 'symmetric' as in maths, the right side evaluates to the left.

Lajla
So you have to be very explicit. Use parentheses liberally.
Jonah Bron
+4  A: 

The formulas you have presented are remedial mathematics, any decent programmer with any programming language (including PHP) could implement those formulas without Excel or any other software aid. So the answers to your questions are:

1.) NO

2.) YES

typoknig
+2  A: 

There's no reason whatsoever to use Excel before implementing this in PHP. Though it might help someone who wanted to use Excel for some basic calculations to see variations on input values, one skilled in PHP could just code in the variables and formulas directly.

JYelton
You could also use the Open Office program to do this
Joe Philllips
A: 

I guess I'll be the contrarian.

In solving the equation for P, is there ANY requirement or need to implement the formula in Microsoft Excel prior to implementing it in PHP source code?

While there's no need to implement the formulas in Microsoft Excel prior to implementing it in PHP source code, because of the number and complexity of the formulas, a developer may have used Excel to see all of the intermediate results before coding the formulas into PHP.

The original implementation might have been in Excel, and after a period of time when the users were comfortable with the results, the formulas were recoded in PHP.

Could a competent PHP programmer just type the formula into PHP source code without the use of Microsoft Excel in the interim?

Yes.

Gilbert Le Blanc
The original implementation could also have been on a napkin. The question was if Excel MUST be used for to develop/calculate these formulas, not if it were possible to use Excel on these formulas.
typoknig
Going back further, the calculations were probably done with a calculator and, even further back, by hand. I quoted the question, and answered it honestly, based on the words "ANY requirement or need".
Gilbert Le Blanc
To see some of the calculations' results before coding PHP, any number of aids could be used. Excel, OpenOffice, a calculator, a napkin (as typoknig suggested (p.s. love the name)), or carved into a restaurant table somewhere. Excel's just one tool out there amongst many others.
JYelton
Gilbert Le Blanc
Yes, and perhaps I should have been more clear - instead of "ANY", I should have put my lawyer hat on and said "AN ABSOLUTE" :-)
Erick
+4  A: 

I haven't tested this but I didn't use anything to write this. Just this message box and the image above. I did this to show how simple it would be to write the code that implements these formulas in a matter of minutes.

<?php
$C  = 1;
$I  = 2;
$N  = 3;
$T  = 4;
$TA = 5;
$Q  = 6;
$E  = 7;
$L  = 8;
$D  = 9;

$i = 1.0/12.0;
$v = 1.0/(1.0+$i);
$f = (1.0+$i)/(1.0+($i*$Q/30.0));
$a = ((1.0 - pow($v, $N))/$i)*$f;
$b = (1.0 - pow($v, $N+$T))/$i;
$ff = ($E - $Q)/30.0;
$aa = $A*$ff;
$j = $D*$TA/100.0;
$k = (($L*$T)/(600.0*($T+1.0))) * ((($T-$a+$b)/$i)+$aa);
$P = $C / ($a - $j - $k);
echo $P;
?>
Joe Philllips
Awesome - looks remarkably like my code. Image that.
Erick
+1  A: 

I suspect even an incompetent programmer, in any language including PHP, would get this correct 90% of the time. And behavior like you describe would make me suspect they (the opposing side and his/her attorney) are smoking something stronger than crack.

MJB