Hello, list. I hope that you're having a nice Sunday. I have this function to approximate the dilogarithm function:
import("stdfaust.lib"); Li2(N, x) = ba.if( x < -1, -1 * ma.PI ^ 2 / 6 - .5 * log(-x) ^ 2 - sum(i, N, 1 / ((i + 1) ^ 2 * x ^ (i + 1))), ba.if( abs(x) <= 1, sum(i, N, x ^ (i + 1) / (i + 1) ^ 2), ma.PI ^ 2 / 3 - .5 * log(x) ^ 2 - sum(i, N, 1 / ((i + 1) ^ 2 * x ^ (i + 1 ))))); process = -2.0', -1.5', -1.0', -.5', -.1', .1', .5', 1.0', 1.5', 2.0' : par( i, 10, Li2(50)); //process = -2', -1.5', -1.0', -.5', -.1', .1', .5', 1.0', 1.5', 2' : par(i, 10, Li2(50)); I am calling it with delayed values to avoid division by zero or NaN in the non-outputting branches. I noticed that if I call it with int values as you can see in the commented process, I get -inf for 2 and -2, whereas I get the correct values if I use float. Please try with: faust2csvplot -double test_Li2.dsp ./test_Li2 -n 1 -s 1 I am aware that the arguments of some functions that use pattern matching must be ints, but I was also convinced that all values in Faust are treated as floats with math functions. What is good practice for floats and ints? Should I explicitly always write 1.0 instead of 1 as if I'm writing C++? Other than that, can you tell why -2 or 2 is producing -inf? Thanks. -- Dr Dario Sanfilippo http://dariosanfilippo.com
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users