Solved

problem with math.log function in vb.net

Posted on 2008-10-19
4
671 Views
Last Modified: 2010-04-21
I am not sure if I am using the math.log function in vb.net properly.

I am trying to do the formula
%Fat=495/(1.0324-0.19077(log(waist-neck))+0.15456(log(height)))-450
(and converting inches to cm)
with
  LbJP.Text = 495 / (1.0324 - 0.19077 * (Math.Log((Val(TxtWaistBL.Text) * 2.54) - (Val(TxtNeck.Text) * 2.54))) + 0.15456 * (Math.Log((Val(TxtHeight.Text) * 2.54)))) - 450
but the number isn't coming out anywhere near close to where it should.

High points for expediency! I need an answer quickly
0
Comment
Question by:JCM0165
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 16

Expert Comment

by:GreymanMSC
ID: 22754151
The Body Fat Calculation uses base 10 logarithm, where as Math.Log gives the Natural Logarithm.  They are not the same thing.

To convert to base 10 log, you need to divide by the natural log of 10.
  LbJP.Text = 495 / (1.0324 - 0.19077 * (Math.Log((Val(TxtWaistBL.Text) * 2.54)/Math.Log(10) - (Val(TxtNeck.Text) * 2.54))) + 0.15456 * (Math.Log((Val(TxtHeight.Text)/Math.Log(10) * 2.54)))) - 450

Open in new window

0
 
LVL 16

Accepted Solution

by:
GreymanMSC earned 500 total points
ID: 22754162
Duh...
LbJP.Text = 495 / (1.0324 - 0.19077 * (Math.Log((Val(TxtWaistBL.Text) * 2.54) - (Val(TxtNeck.Text) * 2.54))/Math.Log(10)) + 0.15456 * (Math.Log((Val(TxtHeight.Text) * 2.54))/Math.Log(10))) - 450

Open in new window

0
 
LVL 16

Expert Comment

by:GreymanMSC
ID: 22754168
Make sure the bracketing around the logs is in the right place.

The important thing is that:

  Log10(X) = Math.Log(X) / Math.Log(10)
0
 

Author Closing Comment

by:JCM0165
ID: 31507663
Thanks!
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question