logarithm

Math domain error in python when using log

回眸只為那壹抹淺笑 提交于 2019-12-31 05:45:31
问题 Here is what I am writing: >>> import math >>> 2/3*math.log(2/3,2) Here is the error I'm getting: Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: math domain error Can someone please explain what I'm doing wrong? Thanks. 回答1: I'm assuming this is Python 2.7. In 2.7, 2/3 evaluates to 0 since division floors by default. Therefore you're attempting a log 0, hence the error. Python 3 on the other hand does floating point division by default. To get the correct

How to put a logarithmic scale with rows represented in logarithm on chart in C # [duplicate]

情到浓时终转凉″ 提交于 2019-12-30 11:14:58
问题 This question already has an answer here : Logarithmic Vertical and Horizontal Axes lines in MS Chart Control (1 answer) Closed 2 years ago . I'm developing a chart in C # and I need the graph lines to be represented in logarithm, the scale can already put, just missing the vertical lines in logarithmic scale according to the image below: My chart currently looks like this: 回答1: Update: To get those additional lines between the periods you need to turn on the MinorGrid for the x-axis of your

How to solve the recurrence T(n) = 2T(n^(1/2)) + log n? [closed]

久未见 提交于 2019-12-30 09:01:30
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am trying to find the time complexity for the recurrence: T(n) = 2T(n 1/2 ) + log n I am pretty close to the solution, however, I have run into a roadblock. I need to solve: n (1/2 k ) = 1 for k to simplify my substitution pattern. I am not looking for answers to the recurrence, just a solution for k . 回答1: When

How to solve the recurrence T(n) = 2T(n^(1/2)) + log n? [closed]

别说谁变了你拦得住时间么 提交于 2019-12-30 09:01:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am trying to find the time complexity for the recurrence: T(n) = 2T(n 1/2 ) + log n I am pretty close to the solution, however, I have run into a roadblock. I need to solve: n (1/2 k ) = 1 for k to simplify my substitution pattern. I am not looking for answers to the recurrence, just a solution for k . 回答1: When

Logarithm with SSE, or switch to FPU?

∥☆過路亽.° 提交于 2019-12-30 08:23:21
问题 I'm doing some statistics calculations. I need them to be fast, so I rewrote most of it to use SSE. I'm pretty much new to it, so I was wondering what the right approach here is: To my knowledge, there is no log2 or ln function in SSE, at least not up to 4.1, which is the latest version supported by the hardware I use. Is it better to: extract 4 floats, and do FPU calculations on them to determine enthropy - I won't need to load any of those values back into SSE registers, just sum them up to

Double equals 0 problem in C

五迷三道 提交于 2019-12-30 08:20:10
问题 I was implementing an algorithm to calculate natural logs in C. double taylor_ln(int z) { double sum = 0.0; double tmp = 1.0; int i = 1; while(tmp != 0.0) { tmp = (1.0 / i) * (pow(((z - 1.0) / (z + 1.0)), i)); printf("(1.0 / %d) * (pow(((%d - 1.0) / (%d + 1.0)), %d)) = %f\n", i, z, z, i, tmp); sum += tmp; i += 2; } return sum * 2; } As shown by the print statement, tmp does equal 0.0 eventually, however, the loop continues. What could be causing this? I am on Fedora 14 amd64 and compiling

geom_raster interpolation with log scale

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 06:49:51
问题 I'm a bit stuck plotting a raster with a log scale. Consider this plot for example: ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) But how to use a log scale with this geom? None of the usual methods are very satisfying: ggplot(faithfuld, aes(waiting, log10(eruptions))) + geom_raster(aes(fill = density)) ggplot(faithfuld, aes(waiting, (eruptions))) + geom_raster(aes(fill = density)) + scale_y_log10() and this doesn't work at all: ggplot(faithfuld, aes(waiting,

Logarithm function of an arbitrary integer base in C

别等时光非礼了梦想. 提交于 2019-12-30 02:53:05
问题 Is there a function or any other way to calculate in C the logarithm of base x , where x is an integer variable of my program? 回答1: C doesn't provide functions to compute logarithms of any bases other than e or 10 . So just use math: logarithm of x base b = log(x)/log(b) If you'll be doing the logarithms over the same base repeatedly, you can precompute 1/log(b) . I wouldn't rely on the compiler being able to do this optimization for you. 来源: https://stackoverflow.com/questions/11054740

Logarithm in C++ and assembly

可紊 提交于 2019-12-29 09:22:23
问题 Apparently MSVC++2017 toolset v141 (x64 Release configuration) doesn't use FYL2X x86_64 assembly instruction via a C/C++ intrinsic, but rather C++ log() or log2() usages result in a real call to a long function which seems to implement an approximation of logarithm (without using FYL2X ). The performance I measured is also strange: log() (natural logarithm) is 1.7667 times faster than log2() (base 2 logarithm), even though base 2 logarithm should be easier for the processor because it stores

Highcharts: Displaying zero values in logarithmic scale

一世执手 提交于 2019-12-29 08:08:35
问题 I am working with logarithmic scale in the y-axis I know that log(0) doesn't exist but I need to draw 0 values, and I need a log scale. I read in other answers that changing the zero values to null solve the problem, but it is not working for me. See the example: http://jsfiddle.net/QEK3x/15/ Thank you in advance. 回答1: Although not perfect, the best I came up with was to set the zero point to 0.0001 and then set the y-axis min to 0.0001: http://jsfiddle.net/6LHT8/ yAxis: { min:0.0001, type: