FAQ Database Discussion Community


Matlab: Solving a logarithmic equation

matlab,logarithm,wolframalpha,natural-logarithm
I have the following equation that I want to solve with respect to a: x = (a-b-c+d)/log((a-b)/(c-d)) where x, b, c, and d are known. I used Wolfram Alpha to solve the equation, and the result is: a = b-x*W(-((c-d)*exp(d/x-c/x))/x) where W is the is the product log function (Lambert...

Highcharts - Line disappears when using logarithmic axis

highcharts,axis,logarithm
If I change the y-axis type to logarithmic on the meteogram example of the highcharts demo, the temperature line stops being visible. Is this a bug or is there something in the code preventing it from displaying when in logarithmic mode? The only change I made to the demo was...

primes, logarithms, summations and loops

python,loops,sum,primes,logarithm
I'm trying to make a program to compute all primes smaller than a given number, and the natural logarithm of the product of all those primes. So because we're working with logarithms I could also just add the natural logarithm of each prime smaller than the given number. So I...

Convert float to log space in python

python,floating-point,logarithm,natural-logarithm
I am implementing the Viterbi algorithm (a dynamic algorithm) in Python, and I notice that for large input files, the probabilities keep getting multiplied and shrinking beyond the floating point precision. I need to store the numbers in log space. Can anyone give a simple example Python code-snippet of how...

How To Code this formula in Java?

java,math,logarithm
I have tried to represent this formula in Java but the values are not correct maybe I have some issue transforming the formula to code. private double getFactor(int y) { double factor = 10 * Math.pow(3, logOfBase(2, 10 + Math.pow(y, 3))); return factor; } public double logOfBase(int base, double num)...

Javascript - negative decimal input range with non-linear scale

javascript,slider,logarithm,exponential
I have an input range slider that ranges from -1000 to 1000. <input type="range" min="-1000" max="1000" value="0" /> I want the steps to be non-linear (either log or exp) with more precision in the lower range. So for e.g. -1000 -999.5 -998 -996 ... 0 100 300 600 1000 Doesn't...

Big-O proof involving a sum of logs

math,big-o,logarithm
Prove that I put the series into the summation, but I have no idea how to tackle this problem. Any help is appreciated...

Is it better to compute log(x/(y*z)) or log(x)-log(y)-log(z)?

numbers,numerical-methods,logarithm
Mathematically, log(x/(y*z)) and log(x)-log(y)-log(z) are equivalent. On a computer, they will give different answers. Which is preferable to compute?

Does this function compute the natural logarithm of a number with an exact precision of 3 digits?

c++,algorithm,floating-point,logarithm
I have the following algorithm in my textbook that should compute the natural log of a number with an exact precision of 3 digits. #include <iostream> #include <cmath> double logN(double a, double li, double ls) { if(a == 1) return 0; else if(fabs(li - ls) < 0.0001) return (li +...

What is the complexity of function f(n) with n=f(n).log(f(n))

algorithm,math,big-o,complexity-theory,logarithm
What is the complexity of function f(n),preferably the Big-O notation, and f(n) satisfies the condition n = f(n).log(f(n)) ,f(n) > 1 .Let assume that log in base 2. I tried to isolate f(n) from the condition but could not get it done. After using excel to get the graph of...

Speeding up a big a loop with a logarithm in Python

python,performance,matlab,logarithm
I'm trying to speed up the following code: from math import log from random import random def logtest1(N): tr=0 for i in range(1,N): T= 40 + 10*random() tr += -log(random())/T I'm fairly new to python (coming from matlab)... and this same code runs 5x slower in python than matlab (and...

Want to plot Pandas Dataframe as Multiple Histograms with log10 scale x-axis

python,pandas,matplotlib,histogram,logarithm
I have floating point data in a Pandas dataframe. Each column represents a variable (they have string names) and each row a set of values (the rows have integer names which are not important). >>> print data 0 kppawr23 kppaspyd 1 3.312387 13.266040 2 2.775202 0.100000 3 100.000000 100.000000 4...

How to write in a logarithmic plot a text in each decade in Matlab

matlab,plot,logarithm
I need to write a different number in each decade, in the bottom or top of my logarithmic plot. I have these numbers in an array N. There is a way to automate the process without write a for loop for each decade? In each decade there are 9 numbers,...

Proof of O(loga n) = O(logb n), for any base a or b

algorithm,big-o,logarithm
I am revising for my exams and this question appears on a past paper: Show that O(loga n) = O(logb n) for any choice of logarithmic bases a and b working from the mathematical definition of the order notation f(n) E O(g(n)). Could someone please show me how to solve...