Logarithm

More
7 years 11 months ago #120335 by rodw
Replied by rodw on topic Logarithm
Well thats actually quite strange. thermistor.comp use the log() function. I wonder why and even if it compiles?
github.com/LinuxCNC/linuxcnc/blob/master...omps/thermistor.comp .

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #120336 by andypugh
Replied by andypugh on topic Logarithm
The thermistor comp runs in userspace.

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #120338 by rodw
Replied by rodw on topic Logarithm

andypugh wrote: The thermistor comp runs in userspace.


Yes, I saw that but still it has no declaration in the header files for log(). The other user space components are quite liberal with standard #include files. Makes me wonder if log() should not be added to rtapi_math.h
The following user(s) said Thank You: yeepah

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago - 7 years 11 months ago #120340 by yeepah
Replied by yeepah on topic Logarithm
I found a code. I will try it before post it. ASAP hope tomorow

I don't know if ther is a link but I found some people who get trouble to compile log in C with linux. They had to compiled the program with the -lm option. And it worked
like : www.unix.com/programming/63585-what-wrong-log-function-c.html
By the way, no clue what does it meens.
Last edit: 7 years 11 months ago by yeepah.

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #120341 by andypugh
Replied by andypugh on topic Logarithm
For simplicity, reliability and portability I think that "lincurve" is the best answer.
It was designed for exactly this sort of job, with inputs inside a well defined range.
We use the same approach extensively in my day job as it limits the computational overhead. And automatically limits outputs to sane values regardless of inputs.
The following user(s) said Thank You: yeepah

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #120451 by yeepah
Replied by yeepah on topic Logarithm
I will work on lincurve, but i need some result. I use the easy way...
So : if somebody need a natural logarithm function in C, here it is


double log(double x){
int i=1;
double logx = 0 ;
double ty = (x-1)/(x+1) ;
double tty=0;
do
{
logx = logx + ty / i;
tty = ty ;
ty = (ty * ((x-1)/(x+1)) * ((x-1)/(x+1)));
i = i + 2 ;
}
while(tty - ty > 0.0000005 );
logx = 2*logx;
return logx;
}

log(2) will give 0.6314

Please Log in or Create an account to join the conversation.

Time to create page: 0.341 seconds
Powered by Kunena Forum