I have found an excel file online that helps with the calculations of a Drugs Half-life and helps to determine how much of the given drug is likely to remain in ones system based on
Hal-life Hour Number
The quantity of the Drug taken per dose
how much is in your system from previous doses
Below is a screenshot of the Excel file showing both the Output with the calculations already performed and also shows the actual Math that is involved for each day...
- The Columns A, B, C, D, E, etc.. is the Day 24 hours
- Column D Row 6 is the Half life for a Drug in Hours
- From the Image below you can see that the calculation is perfromed and that Value is then used in the Next Day's equation
Ok so I am not that knowledgeable with Math outside of basic Addition, Subtraction, Multiplication, and Division I do not know much more then that.
My goal is to create a tool similar to this Excel file but with PHP, I am not sure how to do so but I think all the answers are right here in the image above as far as the math portion.
Looking at D3
I can see that it takes...
D2
's value which is30
in the Image- It then Adds
C3
's value - Then Multiplies that by
1/2
- I am not sure what the
^
does though? - Then it Divides
24 hours
byD6
which holds the Hour Number
In my PHP I would like to have a Function that I can pass an array of Data, so let's say I pass in an Array with...
- the Number of Days to calculate (my image shows like 4 days so if I pass 10 days, it will shows the daily results up to 10 days)
- Then an array of the Daily amount consumed in mg (so in my image this would be an array with
30
,0
,30
,0
,0
,0
,0
- Then I would also pass in the Half Life in Hours, so in my image the drug used has a half-life of 4.5 hours
This function would then return an array with the data for each day, should show the remaining mg in one's system for each day, I can then use this data result to build charts, graphs, or simply a List
I would appreciate any help to get me started, I think I can pull this off on my own but I need help getting the math portion 100%, above I break down the equation as I see it, please help me understand better for example I am not sure what ^
does in the equation or how to do it in PHP
I hope my question is not too vague, I will come back with more specific once I get a good start on this but please help if you can so far, thank you for reading.
^
= Exponentiation Other than that, what php code do you have so far?^
raises the left hand side to the power of the right hand side.pow
function for the exponentiation. It sounds like you have a pretty good handle on the rest.