comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Differentiation in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Differentiation in IDL [message #50643] Mon, 16 October 2006 07:31
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Allan Whiteford writes:

> Surely when you type:
>
> dx = DERIV(x * !dtor,data)
>
> you're actually doing:
>
> d/d(x*!dtor) (sin(x*!dtor))
>
> which is:
>
> cos(x*!dtor)
>
> i.e. you shouldn't need to divide the result by !dtor.
>
> Of course, declaring x as findgen(360)*!dtor to start with looks a lot
> cleaner and is probably easier to follow, but I don't think what was
> suggested by Wox gives the wrong answer.

I think Bradley was suggesting an alternative way
of getting to the same answer. And, indeed it does.
His explanation adds insight to the original problem.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Differentiation in IDL [message #50644 is a reply to message #50643] Mon, 16 October 2006 07:26 Go to previous message
Allan Whiteford is currently offline  Allan Whiteford
Messages: 117
Registered: June 2006
Senior Member
Dear All,

Surely when you type:

dx = DERIV(x * !dtor,data)

you're actually doing:

d/d(x*!dtor) (sin(x*!dtor))

which is:

cos(x*!dtor)

i.e. you shouldn't need to divide the result by !dtor.

Of course, declaring x as findgen(360)*!dtor to start with looks a lot
cleaner and is probably easier to follow, but I don't think what was
suggested by Wox gives the wrong answer.

Thanks,

Allan

Braedley wrote:
> Also, d/dx(f(g(x)))=f'(g(x))*g'(x) (chain rule), so in your case,
> d/dx(sin(x*!dtor))=cos(x*!dtor)*!dtor
> If you divide the result from DERIV by !dtor, you'll get the result
> you're looking for. My suggestion would be to declare x as
> x=findgen(360)*!dtor
> to begin with.
>
> Cheers
>
>
> David Fanning wrote:
>
>> David Fanning writes:
>>
>>
>>> Wox writes:
>>>
>>>
>>>> Specify x?
>>>>
>>>> dx = DERIV(x * !dtor,data)
>>>
>>> Oh, sorry.
>>>
>>> x = findgen(360)
>>>
>>> David
>>>
>>
>> Oh, sorry. I misunderstood. Yes, this does it. Thank you!
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
>
Re: Differentiation in IDL [message #50645 is a reply to message #50644] Mon, 16 October 2006 07:15 Go to previous message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
Also, d/dx(f(g(x)))=f'(g(x))*g'(x) (chain rule), so in your case,
d/dx(sin(x*!dtor))=cos(x*!dtor)*!dtor
If you divide the result from DERIV by !dtor, you'll get the result
you're looking for. My suggestion would be to declare x as
x=findgen(360)*!dtor
to begin with.

Cheers


David Fanning wrote:
> David Fanning writes:
>
>> Wox writes:
>>
>>> Specify x?
>>>
>>> dx = DERIV(x * !dtor,data)
>>
>> Oh, sorry.
>>
>> x = findgen(360)
>>
>> David
>>
>
> Oh, sorry. I misunderstood. Yes, this does it. Thank you!
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Differentiation in IDL [message #50647 is a reply to message #50645] Mon, 16 October 2006 06:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Wox writes:
>
>> Specify x?
>>
>> dx = DERIV(x * !dtor,data)
>
> Oh, sorry.
>
> x = findgen(360)
>
> David
>

Oh, sorry. I misunderstood. Yes, this does it. Thank you!

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Differentiation in IDL [message #50648 is a reply to message #50647] Mon, 16 October 2006 06:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Wox writes:

> Specify x?
>
> dx = DERIV(x * !dtor,data)

Oh, sorry.

x = findgen(360)

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Differentiation in IDL [message #50649 is a reply to message #50648] Mon, 16 October 2006 06:54 Go to previous message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
Specify x?

dx = DERIV(x * !dtor,data)


On Mon, 16 Oct 2006 07:49:21 -0600, David Fanning <news@dfanning.com>
wrote:

> Folks,
>
> OK, I'm missing something crucial here.
>
> Suppose I have a sine function:
>
> x = Findgen(360)
> data = Sin(x * !dtor)
> Plot, data
>
> I know that d/dx(sin(x)) = cos(x). So, I would expect
> a cosine looking curve if I differentiate the data above.
>
> dx = DERIV(data)
> OPlot, dx, Linestyle=2
>
> The differentiated curve is almost a straight line! One
> could argue that it might have the correct cosine *shape*
> (squint your eyes a little bit), but the scale is vastly
> different. How come?
>
> Cheers,
>
> David
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Differentiation in IDL
Next Topic: Re: Basic format code question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:05:16 PDT 2025

Total time taken to generate the page: 0.00524 seconds