473,413 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Math.Log

Joe
Hello,

I'm using Math.Log10 to get my numbers on the same scale but I'm running
into a problem with negative values.
Math.Log10(-143.73833558) is returning a NaN.

Is there something else I can use?

Sorry if this might seem obvious but I'm not a math wiz.

Thanks,
Joe
Sep 30 '08 #1
11 4354
"Joe" <jb*******@noemail.noemailwrote in message
news:e8**************@TK2MSFTNGP03.phx.gbl...
I'm using Math.Log10 to get my numbers on the same scale but I'm running
into a problem with negative values.
Math.Log10(-143.73833558) is returning a NaN.

Is there something else I can use?

Sorry if this might seem obvious but I'm not a math wiz.
No, the logarithm of a negative number is not defined in the Real
domain. If you can define more precisely what you mean by "get my numbers on
the same scale" we may be able to suggest an alternative approach.

Sep 30 '08 #2
On Sep 30, 3:20*pm, "Joe" <jbassk...@noemail.noemailwrote:
I'm using Math.Log10 to get my numbers on the same scale but I'm running
into a problem with negative values.
Math.Log10(-143.73833558) is returning a NaN.
Yes, I'd expect it to.
Is there something else I can use?

Sorry if this might seem obvious but I'm not a math wiz.
Log isn't defined for negative numbers. See
http://msdn.microsoft.com/en-us/libr...10(VS.85).aspx

If you only care about the magnitude, use Math.Log10(Math.Abs(x))

Jon
Sep 30 '08 #3
Joe
What I need is to take a range say 10 to 38456 and divide it up into 5
parts.

"Alberto Poblacion" <ea******************************@poblacion.orgwro te
in message news:%2****************@TK2MSFTNGP06.phx.gbl...
"Joe" <jb*******@noemail.noemailwrote in message
news:e8**************@TK2MSFTNGP03.phx.gbl...
>I'm using Math.Log10 to get my numbers on the same scale but I'm running
into a problem with negative values.
Math.Log10(-143.73833558) is returning a NaN.

Is there something else I can use?

Sorry if this might seem obvious but I'm not a math wiz.

No, the logarithm of a negative number is not defined in the Real
domain. If you can define more precisely what you mean by "get my numbers
on the same scale" we may be able to suggest an alternative approach.

Sep 30 '08 #4
"Joe" <jb*******@noemail.noemailwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
What I need is to take a range say 10 to 38456 and divide it up into 5
parts.
... and you want the parts to fit a logarithmic scale, i imagine. You
then want to do the same thing for negative numbers, in such a way that the
scale will be "symetrical" to the positive part. In this case, I suggest
simply taking absolute values and then changing the sign of the result. That
is, if for a positive x you are doing:
double part = Math.Log10(x);
then when x is negative just do:
part = -Math.Log10(-x);
which will give you a "part" between -1 and -5 for x between -10
and -100000.

Sep 30 '08 #5
Hello Joe,

I totally agree with Alberto's suggestion. Since the Math.Log method does
not support the negative parameter. We can pass its absolute value as
parameter into the Math.Log method. Please let us to know if the suggestion
works for your scenario or not. If you have any future questions or
concerns, please do not hesitate to let me know. I will try my best to
provide future help.

Have a nice day!

Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 1 '08 #6
But that really goes haywire if your data contains values between 0.0 and
1.0. The log10 of those will be negative.

"Alberto Poblacion" wrote:
"Joe" <jb*******@noemail.noemailwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
What I need is to take a range say 10 to 38456 and divide it up into 5
parts.

... and you want the parts to fit a logarithmic scale, i imagine. You
then want to do the same thing for negative numbers, in such a way that the
scale will be "symetrical" to the positive part. In this case, I suggest
simply taking absolute values and then changing the sign of the result. That
is, if for a positive x you are doing:
double part = Math.Log10(x);
then when x is negative just do:
part = -Math.Log10(-x);
which will give you a "part" between -1 and -5 for x between -10
and -100000.

Oct 1 '08 #7
"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:EB**********************************@microsof t.com...
But that really goes haywire if your data contains values between 0.0 and
1.0. The log10 of those will be negative.
Certainly. In fact, it will approach "minus infinite" as the values
approach zero. I imagine that this is why the Original Poster specified a
range similar to "10 to 38456", otherwise the idea of directly applying a
logarithmic scale needs to be reconsidered.

Oct 1 '08 #8
Joe
We have a very wide range of possible numbers coming in. They can
be -15000.90922 to 34000000 and anywhere in between.

We do also have a lot of values very close to 0.

"Alberto Poblacion" <ea******************************@poblacion.orgwro te
in message news:um****************@TK2MSFTNGP02.phx.gbl...
"Family Tree Mike" <Fa************@discussions.microsoft.comwrote in
message news:EB**********************************@microsof t.com...
>But that really goes haywire if your data contains values between 0.0 and
1.0. The log10 of those will be negative.

Certainly. In fact, it will approach "minus infinite" as the values
approach zero. I imagine that this is why the Original Poster specified a
range similar to "10 to 38456", otherwise the idea of directly applying a
logarithmic scale needs to be reconsidered.

Oct 1 '08 #9
"Joe" <jb*******@noemail.noemailwrote in message
news:ec**************@TK2MSFTNGP04.phx.gbl...
We have a very wide range of possible numbers coming in. They can
be -15000.90922 to 34000000 and anywhere in between.

We do also have a lot of values very close to 0.
If the objetive is to break the range of numbers into several parts, you
will have to give some thought as to how you want those parts to be made.
For instance, if you have a number such as 0.001 coming in, its logarithm
will be -3. So it's probably not adequate to be used as a "number of part".
Depending on how you want to group your data you may wish to use a
"mixed" approach where you first apply a fixed criterion to separate the
numbers and then apply a logarithmic scale to some groups. For instance,
first of all divide your numbers into three groups: less than -10,
between -10 and 10, and more than 10. Then apply Logs (as discussed earlier)
to the first and last group to divide them in "parts", while leaving those
in the middle to belong to yet another "part". This may or may not be
adequate for you; it all depends on how you want your numbers classified.

Oct 2 '08 #10
Hi Joe,

If your number x can be in the range from -15000.90922 to 34000000, an easy
and simple way is to add 15002 to the x. So all numbers will be in the
range from 1.09078 to 34015002. So, we can use it as the parameter of the
Math.Log10() directly. But I am not sure if this is the best approach to
your demand. As Alberto has indicated, this issue depends on how you want
to classify your numbers. Could you please share what is in your mind, so
we can give future help on this.
Best regards,
Ji Zhou
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

Oct 2 '08 #11
Hello Joe,

I am writing to check the status of the issue on your side. Could you
please let me know if the suggestion works for you or not? If you have any
questions or concerns, please feel free to let me know. I will be more than
happy to be of assistance.

Have a great day!

Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Oct 8 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Frank Millman | last post by:
Hi all I was helping my niece with her trigonometry homework last night. Her calculator's batteries were flat, so I thought I would use Python's math module to calculate sin, cos, and tan. I...
0
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** ...
1
by: limelight | last post by:
I have discovered a math error in the .NET framework's Log function. It returns incorrect results for varying powers of 2 that depend on whether the program is run from within the IDE or from the...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
7
by: bravesplace | last post by:
Hello, I am using the folling funtion to round a number to a single digit on my form: function round1(num) { return Math.round(num*1)/1 }
110
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm...
11
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
0
by: kirby.urner | last post by:
Cyber-curricula have a leveling aspect, as kids nearer Katrina's epicenter tune in and bliss out on 'Warriors of the Net' (why wait for stupid big dummy textbooks to catch up?). They feel more...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
15
by: bH | last post by:
Hi All, I have been looking at javascript drawing from this website : http://www.cwdjr.net/geometricDraw/pentagon_draw.html" and I am wondering why the author made it into two images : upper...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.