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

Home » Public Forums » archive » partial derivatives of f(x,y)
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
partial derivatives of f(x,y) [message #3968] Wed, 12 April 1995 00:00 Go to next message
brooker is currently offline  brooker
Messages: 12
Registered: March 1994
Junior Member
I have a 2d function z=f(x,y). I need to calculate
the partial derivatives df/dx and df/dy for all the
grid points. Is there a routine for this somewhere?

Thanks-Peter Brooker
Re: partial derivatives of f(x,y) [message #4050 is a reply to message #3968] Fri, 14 April 1995 00:00 Go to previous message
bowman is currently offline  bowman
Messages: 121
Registered: September 1991
Senior Member
In article <3mmmpv$g0l@agate.berkeley.edu>,
korpela@albert.ssl.berkeley.edu (Eric J. Korpela) wrote:

> In article <D6xz1s.ADE@ireq.hydro.qc.ca>,
> <brooker@toka.ireq-ccfm.hydro.qc.ca> wrote:
>> I have a 2d function z=f(x,y). I need to calculate
>> the partial derivatives df/dx and df/dy for all the
>> grid points. Is there a routine for this somewhere?
>
> delta=some_small_number ;compared to the grid spacing
> dz_dx=(f(x+delta,y)-f(x-delta,y))/(2.0*delta)
> dz_dy=(f(x,y+delta)-f(x,y-delta))/(2.0*delta)

Perhaps he wanted:

z = FLTARR(nx,ny)
dzdx = FLTARR(nx,ny)
dzdy = FLTARR(nx,ny)

FOR j = 0, ny-1 DO $
dzdx(*,j) = (ROTATE(z(*,j),-1) - ROTATE(z(*,j),1))/(2.0*dx)
FOR j = 1, ny-2 DO $
dzdy(*,j) = (z(*,j+1) - z(*,j-1))/(2.0*dy)

...then whatever you want to do for the normal derivatives on the boundaries...

You could do this without the ROTATE's by looping over i for dzdx, but
then you would access memory with a large stride. I think this will use
the cache much more efficiently on most workstations.

Regards, Ken Bowman

--
Dr. Kenneth P. Bowman 409-862-4060
Associate Professor 409-862-4132 fax
Department of Meteorology bowman@csrp.tamu.edu
Texas A&M University PP-Glider
College Station, TX 77843-3150
Re: partial derivatives of f(x,y) [message #4051 is a reply to message #3968] Fri, 14 April 1995 00:00 Go to previous message
korpela is currently offline  korpela
Messages: 59
Registered: September 1993
Member
In article <D6xz1s.ADE@ireq.hydro.qc.ca>,
<brooker@toka.ireq-ccfm.hydro.qc.ca> wrote:
> I have a 2d function z=f(x,y). I need to calculate
> the partial derivatives df/dx and df/dy for all the
> grid points. Is there a routine for this somewhere?
>

Provided free of charge........ (Unless Unisys has patented it :) )

Assuming x and y are arrays.....

delta=some_small_number ;compared to the grid spacing
dz_dx=(f(x+delta,y)-f(x-delta,y))/(2.0*delta)
dz_dy=(f(x,y+delta)-f(x,y-delta))/(2.0*delta)

Eric
--
Eric Korpela | A day without meetings is like
korpela@ssl.berkeley.edu | work.
<a href=" http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpe la/w">Click here for more info.</a>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: problem converting FORTRAN to IDL
Next Topic: Re: Platform recommendation/tradeoffs?

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

Current Time: Wed Oct 08 15:15:47 PDT 2025

Total time taken to generate the page: 0.00533 seconds