Light Alkmst
New Member
- Reaction score
- 20
Earlier this morning, I had realized that there are probably no natural functions in the JASS files, and I figured that I might as well make them in case someone will need them.
e^(x)
ln(x)
All of the functions are more accurate closer to their centers, but the lower functions are a little slower. I'm a little lazy right now, so if someone could check the natural logs for me, it would be great.
The _0 functions are centered at 0
The _1 functions are centered at 1, and is slower than 0
The _C functions are centered at your choice, but will be slower
e^(x)
JASS:
function e0 takes real x returns real
return 1. + x + x * x / 2. + x * x * x / 6 + x * x * x * x / 24
endfunction
function e1 takes real x returns real
return 1. + (x - 1.) + (x - 1.) * (x - 1.) / 2. + (x - 1.) * (x - 1.) * (x - 1.) / 6 + (x - 1.) * (x - 1.) * (x - 1.) * (x - 1.) / 24
endfunction
function eC takes real x, real center returns real
return 1. + (x - center) + (x - center) * (x - center) / 2. + (x - center) * (x - center) * (x - center) / 6 + (x - center) * (x - center) * (x - center) * (x - center) / 24
endfunction
ln(x)
JASS:
function ln1 takes real x returns real
return (x - 1.) - (x - 1.) * (x - 1.) / 2. + (x - 1.) * (x - 1.) * (x - 1.) / 3. - (x - 1.) * (x - 1.) * (x - 1.) * (x - 1.) / 4.
endfunction
function lnC takes real x, real center returns real
return (x - center) - (x - center) * (x - center) / 2. + (x - center) * (x - center) * (x - center) / 3. - (x - center) * (x - center) * (x - center) * (x - center) / 4.
endfunction
All of the functions are more accurate closer to their centers, but the lower functions are a little slower. I'm a little lazy right now, so if someone could check the natural logs for me, it would be great.
The _0 functions are centered at 0
The _1 functions are centered at 1, and is slower than 0
The _C functions are centered at your choice, but will be slower