Slope of the curve

Hi all;

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)))
## and x is the variable which vary on each call.

know I need the have the slope of the curve as each point! :-/
is there any method out? or any fast idea to let me find it out?
tnx

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn <http://ir.linkedin.com/in/taleghani>

No, the second x/23 does integer division

···

On Sat, May 3, 2014 at 3:29 AM, Wael El Hachimi <wael@unik.ma> wrote:

maybe there is an error:
sin((x / 23.0 - (x / 23)) = sin(0)

On 3 May 2014 07:24, shayne.alone@gmail.com <shayne.alone@gmail.com>wrote:

Hi all;

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)))
## and x is the variable which vary on each call.

know I need the have the slope of the curve as each point! :-/
is there any method out? or any fast idea to let me find it out?
tnx

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn <http://ir.linkedin.com/in/taleghani&gt;

--
--
Wael El Hachimi El Idrissi
Developer | Unik Experience
(212)0-615-174-102 | wael@unik.ma | http://www.unik.ma
Twitter: http://twitter.com/WaelElHachimi

maybe there is an error:
sin((x / 23.0 - (x / 23)) = sin(0)

···

On 3 May 2014 07:24, shayne.alone@gmail.com <shayne.alone@gmail.com> wrote:

Hi all;

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)))
## and x is the variable which vary on each call.

know I need the have the slope of the curve as each point! :-/
is there any method out? or any fast idea to let me find it out?
tnx

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn <http://ir.linkedin.com/in/taleghani&gt;

--
--
Wael El Hachimi El Idrissi
Developer | Unik Experience
(212)0-615-174-102 | wael@unik.ma | http://www.unik.ma
Twitter: http://twitter.com/WaelElHachimi

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.)

Regards,
Marcus

···

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)))

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A

I didn't found some thing special!
but it seems not to be a complex :slight_smile:
I the fallowing calculation to find the deviation out:

result = (50.0 * (1.0 + sin((z / 23.0 - (z / 23)) * 360.0 * pi /
180.0))).to_f.round(3)
slope = ((50.0 * (1.0 + sin(((z+1) / 23.0 - ((z+1) / 23)) * 360.0 * pi /
180.0)))-phys/1).to_f.round(3)

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn <http://ir.linkedin.com/in/taleghani&gt;

···

On Sat, May 3, 2014 at 12:05 PM, Kevin Mustelier <kemus@mit.edu> wrote:

No, the second x/23 does integer division

On Sat, May 3, 2014 at 3:29 AM, Wael El Hachimi <wael@unik.ma> wrote:

maybe there is an error:
sin((x / 23.0 - (x / 23)) = sin(0)

On 3 May 2014 07:24, shayne.alone@gmail.com <shayne.alone@gmail.com>wrote:

Hi all;

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)))
## and x is the variable which vary on each call.

know I need the have the slope of the curve as each point! :-/
is there any method out? or any fast idea to let me find it out?
tnx

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn <http://ir.linkedin.com/in/taleghani&gt;

--
--
Wael El Hachimi El Idrissi
Developer | Unik Experience
(212)0-615-174-102 | wael@unik.ma | http://www.unik.ma
Twitter: http://twitter.com/WaelElHachimi

actually in my case, x is always a positive integer...

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn <http://ir.linkedin.com/in/taleghani&gt;

···

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.)

Regards,
Marcus

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A

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.

<https://en.wikipedia.org/wiki/Differentiation_rules&gt; could help.

HTH

      --- Eric

[1] Arithmetic underflow - Wikipedia

···

On Saturday 03 May 2014 10:26:58, sto.mar@web.de wrote:

> 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.)

Maybe you are looking for #lambda?

···

----------------------------------------
anon_method = lambda do |x|
  x + 2
end

anon_method.call(4) #=> 6
----------------------------------------

Vale,
Quintus

--
Blog: http://www.quintilianus.eu

I will reject HTML emails. | Ich akzeptiere keine HTML-Nachrichten.
                               >
Use GnuPG for mail encryption: | GnuPG für Mail-Verschlüsselung:
http://www.gnupg.org | http://gnupg.org/index.de.html

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:

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A

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
--->%---

      --- Eric

···

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.

:slight_smile:

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn <http://ir.linkedin.com/in/taleghani&gt;

···

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
--->%---

                        --- Eric