Math::...lculus(3pm)

πŸ’– Math::Symbolic::MiscCalculus πŸ’–

okay so bestie, welcome to the Math::...lculus(3pm) page (yes the title is literally cut off mid-word, the filename said "too long", we don't gatekeep, we move on πŸ’…). This is the documentation for the module Math::Symbolic::MiscCalculus, and it's genuinely one of my faves because it's calculus but make it vibes. Let's go πŸ¦‹


✨ NAME ✨

Math::Symbolic::MiscCalculus β€” Miscellaneous calculus routines (eg Taylor poly). that's it. that's the whole name. iconic brevity πŸŽ€


🌸 SYNOPSIS 🌸

here's the whole vibe in code form, no notes:

use Math::Symbolic qw/:all/;
use Math::Symbolic::MiscCalculus qw/:all/; # not loaded by Math::Symbolic

$taylor_poly = TaylorPolynomial $function, $degree, $variable;
# or:
$taylor_poly = TaylorPolynomial $function, $degree, $variable, $pos;

$lagrange_error = TaylorErrorLagrange $function, $degree, $variable;
# or:
$lagrange_error = TaylorErrorLagrange $function, $degree, $variable, $pos;
# or:
$lagrange_error = TaylorErrorLagrange $function, $degree, $variable, $pos,
                                      $name_for_range_variable;

# This has the same syntax variations as the Lagrange error:
$cauchy_error = TaylorErrorLagrange $function, $degree, $variable;
heads up babes πŸ‘€ β€” that last line in the original synopsis literally says TaylorErrorLagrange, not TaylorErrorCauchy. I am simply the messenger, not the editor. I keep it exactly as written, no cap. 🫢

also the plot twist: Math::Symbolic::MiscCalculus is not loaded by Math::Symbolic itself, so you gotta use it separate, bestie.


🌈 DESCRIPTION 🌈

This module hands you a little collection of subroutines that do calculus-adjacent things β€” specifically computing Taylor polynomials and the errors associated with them, all built out of Math::Symbolic trees. the way it just does that for you?? obsessed 😭

Please note (and I'm just relaying this, don't come for me): the code in here may or may not be refactored into the OO-interface of the Math::Symbolic module at some point in the future. so like, enjoy it while it's in this shape πŸ’€

πŸŽ€ EXPORT πŸŽ€

None by default. as in, you get nothing for free, you have to ask β€” very demure, very mindful.

You may choose to have any of these routines exported into your calling namespace. The :all tag exports every single one of the following:

TaylorPolynomial
TaylorErrorLagrange
TaylorErrorCauchy

so go ahead and manifest them into your namespace πŸ’«


πŸ‘‘ SUBROUTINES πŸ‘‘

πŸ’œ TaylorPolynomial

This function (symbolically) computes the n-th-degree Taylor Polynomial of a given function. Broadly speaking: the Taylor Polynomial is an n-th degree polynomial that approximates the original function, and it does that approximation especially well in the neighbourhood of a particular point x0. (And since the author says their mathematical English jargon is lacking, they strongly suggest you read up on what this actually is in a book. realest disclaimer ever honestly πŸ“š)

Mathematically speaking, the Taylor Polynomial of the function f(x) looks exactly like this:

Tn(f, x, x0) =
  sum_from_k=0_to_n(
      n-th_total_derivative(f)(x0) / k! * (x-x0)^k
  )

Now the arguments, one by one, because order matters and we don't do chaos here:

  1. first argument β€” the function to approximate. It can be a string to be parsed, or a valid Math::Symbolic tree. either one, your choice, slay.
  2. second argument β€” an integer saying which degree to approximate to.
  3. third argument β€” the last required one. It's the variable to use for the approximation, given either as a string (name) or as a Math::Symbolic::Variable object. That's the 'x' up in the formula. πŸ‘†
  4. fourth argument β€” optional! It's the name of the variable to introduce as the point of approximation. Can also be a variable object. That's the 'x0'. If you don't specify it, this variable's name is assumed to be the function variable's name (the 'x') with '_0' appended. cute, automatic, self-sufficient ✨
⚠️ also important: this routine is for functions of one variable only. if you need two variables, there's an equivalent in the Math::Symbolic::VectorCalculus package. go get her πŸ’…

πŸ¦‹ TaylorErrorLagrange

TaylorErrorLagrange computes and returns the formula for the Taylor Polynomial's approximation error after Lagrange. (Again β€” the author's English terminology is lacking, their words, not mine.) It looks similar to this:

Rn(f, x, x0) =
  n+1-th_total_derivative(f)( x0 + theta * (x-x0) ) / (n+1)! * (x-x0)^(n+1)

Please refer to your favourite book on the topic πŸ’• also: 'theta' may be any number between 0 and 1.

The calling conventions for TaylorErrorLagrange are similar to those of TaylorPolynomial, with one glow-up: TaylorErrorLagrange takes an extra optional argument specifying the name of 'theta'. If it isn't specified explicitly, the variable will just be named 'theta', exactly like in the formula above. default behaviour ate, no notes 🌟

🌸 TaylorErrorCauchy

TaylorErrorCauchy computes and returns the formula for the Taylor Polynomial's approximation error after (guess who!) Cauchy. (And yes β€” again, the author's English terminology is lacking. we love a recurring bit πŸ™ˆ) It looks similar to this:

Rn(f, x, x0) = TaylorErrorLagrange(...) * (1 - theta)^n

Please refer to your favourite book on the topic, plus the documentation for TaylorErrorLagrange. 'theta' may be any number between 0 and 1.

The calling conventions for TaylorErrorCauchy are identical to those of TaylorErrorLagrange. twin behaviour, matching energy, periodt. 🫢


πŸ’Œ AUTHOR πŸ’Œ

Please send feedback, bug reports, and support requests to the Math::Symbolic support mailing list: math-symbolic-support at lists dot sourceforge dot net. Also β€” and this is so sweet β€” please consider letting them know how you use Math::Symbolic. Thank you!! πŸ₯Ί

If you're interested in helping with development or extending the module's functionality, hit up the developers' mailing list: math-symbolic-develop at lists dot sourceforge dot net. come join the group chat bestie πŸ’¬

List of contributors:

Steffen MΓΌller, symbolic-module at steffen-mueller dot net
Stray Toaster, mwk at users dot sourceforge dot net
Oliver EbenhΓΆh

the way three whole icons carried this module on their backs πŸ˜­πŸ‘‘


πŸ” SEE ALSO πŸ”

New versions of this module can be found at http://steffen-mueller.net or on CPAN. Module development happens on Sourceforge at http://sourceforge.net/projects/math-symbolic/ β€” go lurk, go contribute, go be the main character πŸ’–

  • Math::Symbolic (the moment you need it, it's right there)

and that's the whole page, bestie!! no crumbs left, every flag and formula preserved exactly as the universe intended 🌈✨

little sign-off before you go: this has been perl v5.40.0, dated 2024-09-16 πŸ’…πŸ«Ά bye babes, go approximate something responsibly!! πŸŽ€πŸ¦‹πŸŒΈ
πŸ“¦ where this page comes from