Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic
1 | 2 
gregmcc
2147 posts

Uber Geek

ID Verified
Trusted
Lifetime subscriber

  #1478445 25-Jan-2016 17:09
Send private message

Ouranos:

 

gregmcc: 1st Variable number 84 2nd Variable number 75 Answer

 

1399.345

 

=SUM(66.47+(13.75*A2)+(5*175)-(6.76*A4)*1.375)

 

This is the formula that goes in the box below "Answer"

 

 

That spreadsheet formula has two, or possibly three, errors:

 

1. The SUM function is unnecessary. Effectively it says =SUM(x) which is just x. I see many people do this and I don't understood why.

 

 

 

 

has no effect on the outcome so it's not an error

 

 

 

 

2. A formula should never contain hard-coded "magic numbers". For example, what does 66.47 mean? Put each of the numbers in a cell and refer to them. Then document what each of the numbers means, where it comes from, etc.

 

 

 again it makes no difference what these "magic" numbers are, they are fixed constants, it's only the 84 and 75 that change, so not an error either

 

 

 

 

 

 

3. The OP stated the equation as "[66.47 + (13.75 x 84) + (5 x 175 ) - (6.76 x 75] x 1.375" which has mismatched parentheses. Looking at the square brackets, I assume it is intended that the whole thing is multiplied by 1.375. If so, then =SUM(66.47+(13.75*A2)+(5*175)-(6.76*A4)*1.375) is wrong (as is the PowerShell script posted earlier). That is, does the original equation equal 2185.52125 or 1399.345?

 

 

maybe an error, but we will never know as the OP has given the equation without any explanation as to what it is calculating, what the fixed values are and what the variable value are.

 

 

 

Maybe the OP could enlighten us with more details and we can then determine where the brackets belong

 

 

 

 




insane
3236 posts

Uber Geek

ID Verified
Trusted

  #1478447 25-Jan-2016 17:13
Send private message

Someone throw it up into a google spreadsheet and share it


geekIT

2417 posts

Uber Geek


  #1478454 25-Jan-2016 17:44
Send private message

Sorry guys, I thought I should keep my question short for the sake of clarity.

 

The equation comes from a CSIRO book on Diet, Exercise and Health.

The purpose of the equation is to establish a man's daily maintenance calories, ie, the intake required to keep one's weight static.
(Obviously, any lesser calorie intake should result in weight loss.)

 

[66.47 + (13.75 x 84*) + (5 x 175* ) - (6.76 x 75*] x 1.375* =

 

The variables are:

 

84* - current weight in kilos. As one loses weight, this figure will reduce.

 

175* - height in cms. Shouldn't change radically unless one has an unfortunate encounter with a guillotine.

 

75* - age. This will advance, of course.

 

1.375* - this variable is a qualifier that represents one's level of activity. In this case, sedentary or light activity. This would probably remain static, especially with older people.

 

The women's equation is as follows:

 

[65.1 + (9.56 x 63*) + (1.85 x 155*) - (4.68 x 53*)] x 1.2* =

 

Again, the variables are:

 

63* - weight in kilos
155* - height in cm
53* - age
1.2* - same as the male version - sedentary or light daytime activity.

PS: My round-figure calculations for the above yielded 2186 cals for the man and 1555 cals for the woman.

 

 

 

 





'Those who can make you believe absurdities can make you commit atrocities.' Voltaire

 

'A patriot must always be ready to defend his country against his government.' Edward Abbey

 

 

 

 

 

 




Ouranos
118 posts

Master Geek


  #1478460 25-Jan-2016 18:01
Send private message

geekIT:

 

The purpose of the equation is to establish a man's daily maintenance calories, ie, the intake required to keep one's weight static.

 

 

There are many online calculators for that. A random search finds, for example:

 

http://www.weightloss.com.au/weight-loss/weight-loss-tools/energy-needs-calculator.html

 

http://www.freedieting.com/tools/calorie_calculator.htm

 

gregmcc:

 

has no effect on the outcome so it's not an error

 

 

OK, strictly speaking they are "latent faults". "Errors" for short.


Ouranos
118 posts

Master Geek


  #1478488 25-Jan-2016 18:25
Send private message

gregmcc:

 

try this on for size

 

https://docs.google.com/spreadsheets/d/1NA6oOGAjSmlwETxEo-7YmdOCAaltMkUp9_r_RTSu4ag/edit?usp=sharing

 

 

The equation coefficients for male and female need to be different. Therefore, your Google spreadsheet is wrong.

 

(That's why a formula should never have embedded "magic numbers".)


Ouranos
118 posts

Master Geek


  #1478491 25-Jan-2016 18:33
Send private message

By the way, what we're taking about here is called the Harris–Benedict equation:

 

https://en.wikipedia.org/wiki/Harris%E2%80%93Benedict_equation

 

It was devised almost 100 years ago and has been revised several times since:

 

https://en.wikipedia.org/wiki/Basal_metabolic_rate


 
 
 

Cloud spending continues to surge globally, but most organisations haven’t made the changes necessary to maximise the value and cost-efficiency benefits of their cloud investments. Download the whitepaper From Overspend to Advantage now.
Ruphus
465 posts

Ultimate Geek


  #1479516 27-Jan-2016 01:27
Send private message

ObidiahSlope:

 

 


Write-Output "Formula = (66.47 + (13.75 * $var2) + (5 * 175 ) - (6.76 * $var1) * 1.375)"

 

 

 

 

I have reworked the line above using Write-Host and its -NoNewline and -ForegroundColor arguments together with the semicolon command seperator to highlight the variable values.

 

Write-Host -NoNewline "Formula = (66.47 + (13.75 * "; Write-Host -NoNewline -ForegroundColor yellow "$var2"; Write-Host -NoNewline ") + (5 * 175 ) - (6.76 * "; Write-Host -NoNewline -ForegroundColor yellow "$var1"; Write-Host ") * 1.375)"

 

 

 

 

This....

 

http://powershell.com/cs/blogs/donjones/archive/2012/03/06/2012-scripting-games-commentary-stop-using-write-host.aspx

 

 

 

And this...

 

http://www.jsnover.com/blog/2013/12/07/write-host-considered-harmful/

 

 

 

Save the puppies.


toyonut
1508 posts

Uber Geek


  #1479598 27-Jan-2016 08:57
Send private message

Ruphus:

 

ObidiahSlope:

 

 


Write-Output "Formula = (66.47 + (13.75 * $var2) + (5 * 175 ) - (6.76 * $var1) * 1.375)"

 

 

 

 

I have reworked the line above using Write-Host and its -NoNewline and -ForegroundColor arguments together with the semicolon command seperator to highlight the variable values.

 

Write-Host -NoNewline "Formula = (66.47 + (13.75 * "; Write-Host -NoNewline -ForegroundColor yellow "$var2"; Write-Host -NoNewline ") + (5 * 175 ) - (6.76 * "; Write-Host -NoNewline -ForegroundColor yellow "$var1"; Write-Host ") * 1.375)"

 

 

 

 

This....

 

http://powershell.com/cs/blogs/donjones/archive/2012/03/06/2012-scripting-games-commentary-stop-using-write-host.aspx

 

 

 

And this...

 

http://www.jsnover.com/blog/2013/12/07/write-host-considered-harmful/

 

 

 

Save the puppies.

 

 

 

 

Although this is now far out of the scope of the OP, The script output is not going into a pipeline so write-host with colored tags is a nice and viable way to make the output more readable. I had not seen write-verbose before though, I am going to start using that from now on.





Try Vultr using this link and get us both some credit:

 

http://www.vultr.com/?ref=7033587-3B


ObidiahSlope
260 posts

Ultimate Geek


  #1479746 27-Jan-2016 11:46
Send private message

Ruphus:

 

Save the puppies.

 

 

 

 

A similar slaughter of innocent puppies takes place in the *nix world;

 

 

 

http://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo





Obsequious hypocrite

1 | 2 
Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.