DIFF(3pm)

πŸ“¦
version 2.085 Β· 4 versions
, in ubuntu noble

πŸ’– DIFF πŸ’–

the <code>PDL::GSL::DIFF</code> manual page, bestie β€” it's page DIFF(3pm) from the User Contributed Perl Documentation collection, and no cap, it's about to make numerical differentiation your whole personality. πŸ¦‹


✨ NAME ✨

PDL::GSL::DIFF β€” it's the PDL interface to the numerical differentiation routines living inside GSL. That's it, that's the name, slay. πŸ’…


🌸 DESCRIPTION 🌸

okay so. This is an interface to the numerical differentiation package that's present in the GNU Scientific Library. Like, you give it a function, you give it a point, it hands you back a derivative. Iconic behavior honestly. ✨


πŸŽ€ SYNOPSIS πŸŽ€

the vibe, in code:

use PDL;
use PDL::GSL::DIFF;

my $x0 = 3.3;

my @res = gsldiff(\&myfunction,$x0);
# same as above:
@res = gsldiff(\&myfunction,$x0,{Method => 'central'});

# use only values greater than $x0 to get the derivative
@res =  gsldiff(\&myfunction,$x0,{Method => 'forward'});

# use only values smaller than $x0 to get the derivative
@res =  gsldiff(\&myfunction,$x0,{Method => 'backward'});

sub myfunction{
  my ($x) = @_;
  return $x**2;
}
#line 61 "DIFF.pm"

look at that little #line 61 "DIFF.pm" at the end β€” it's literally part of the example, leave it alone bestie, it's canon. πŸ’€


πŸ‘‘ FUNCTIONS πŸ‘‘

🌈 diff_central

Signature:

Signature: (double x(); double [o] res(); double [o] abserr(); SV* function)

info not available β€” yeah, that's genuinely all the docs say, we're not gonna pretend otherwise. 🫢

diff_central does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. periodt.


🌈 diff_backward

Signature:

Signature: (double x(); double [o] res(); double [o] abserr(); SV* function)

info not available

diff_backward does not process bad values either. And same energy as above: it will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.


🌈 diff_forward

Signature:

Signature: (double x(); double [o] res(); double [o] abserr(); SV* function)

info not available

diff_forward does not process bad values. Yep, you guessed it β€” it will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. πŸ’…


🌟 gsldiff

This function is serving as an interface to the three differentiation functions present in GSL: gsl_diff_central, gsl_diff_backward and gsl_diff_forward. 🧚

So here's the tea on how it picks: to compute the derivative, the central method uses values greater and smaller than the point at which the derivative is to be evaluated, while backward and forward use only values smaller and greater respectively. gsldiff() returns both the derivative and an absolute error estimate. The default method is 'central', and you can specify the others by passing an option.

Please check the GSL documentation for more information. (go look, it's right there in SEE ALSO, i'm not making stuff up πŸ’œ)

Usage:

($d,$abserr) = gsldiff($function_ref,$x,{Method => $method});

Example:

#derivative using default method ('central')
($d,$abserr) = gsldiff(\&myf,3.3);

#same as above with method set explicitly
($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'central'});

#using backward & forward methods
($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'backward'});
($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'forward'});

sub myf{
  my ($x) = @_;
  return exp($x);
}

😭 BUGS 😭

Feedback is welcome!! Log bugs in the PDL bug database (the database is always linked from http://pdl.perl.org). Don't suffer in silence bestie, tell the maintainers. 🫢


πŸ”₯ SEE ALSO πŸ”₯

  • PDL

The GSL documentation is online at

http://www.gnu.org/software/gsl/manual/

πŸ’œ AUTHOR πŸ’œ

This file copyright (C) 2003 Andres Jordan <andresj@physics.rutgers.edu> All rights reserved. There is no warranty. You are allowed to redistribute this software documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.

The GSL differentiation routines were written by David Morrison.


and that's the whole page, bestie β€” shoutout to perl v5.38.2, dated 2024-04-10, which is the version and date this page came from, all bundled up as DIFF(3pm). go differentiate something, you're the main character now. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from