On Sat, May 3, 2014 at 12:56 PM, <sto.mar@web.de> wrote:
Am 03.05.2014 08:24, schrieb shayne.alone@gmail.com:
> I have a function with calculate a result as fallow:
>
> res = (50.0 * (1.0 + sin((x / 23.0 - (x / 23)) * 360.0 * pi / 180.0)))
Are you sure about this function?
x / 23.0 - (x / 23) evaluates to zero, assuming x is a Float.
(Which seems to be implied since you talk about the slope.)
Not quite, since x/23 is an integer division, as Kevin pointed out. It's the
same as x / 23.0 - floor(x / 23.0). Leaving arithmetic underflows [1] aside,
it will be 0 iff x = i*23 (i = 1, 2, ..., n).
Still, finding the slope of f(x) at x means calculating f'(x), i.e., derive
f(x). Which has nothing to do with Ruby, but is a math question.
x / 23.0 - (x / 23) evaluates to zero, assuming x is a Float.
(Which seems to be implied since you talk about the slope.)
Not quite, since x/23 is an integer division, as Kevin pointed out.
It's the same as x / 23.0 - floor(x / 23.0). Leaving arithmetic
underflows [1] aside, it will be 0 iff x = i*23 (i = 1, 2, ...,
n).
Not quite, when you assume x to be a Float - as clearly stated
in my post - then x/23 is *not* an integer division.
Still, finding the slope of f(x) at x means calculating f'(x),
i.e., derive f(x). Which has nothing to do with Ruby, but is a math
question.
On the other hand, when you assume x to be an Integer then f'(x) would
not be mathematically defined...
Probably the OP simply meant f(n+1) - f(n).
Regards,
Marcus
···
Am 04.05.2014 17:27, schrieb Eric MSP Veith:
On Saturday 03 May 2014 10:26:58, sto.mar@web.de wrote:
On Sun, May 4, 2014 at 10:04 PM, Eric MSP Veith <eveith@wwweb-library.net>wrote:
On Sunday 04 May 2014 18:29:24, sto.mar@web.de wrote:
> Not quite, when you assume x to be a Float - as clearly stated
> in my post - then x/23 is *not* an integer division.
You are right, I should have checked before.
---%<---
irb(main):001:0> x = 6
=> 6
irb(main):002:0> x / 23
=> 0
irb(main):003:0> x / 23.0
=> 0.2608695652173913
--->%---