p!differentiate - battlecatsultimate/PackPack GitHub Wiki

Type : Constraint Command
Level : Member
DM : Allowed


Alias

diff, dx

Parameter

Formula [Required] : Formula that will be differentiated. The formula must contain only up to one variable.

  • Example : p!dx sin(x), p!dx cos(a) (a here is variable)

-v Value [Required] : Value that will be put after differentiation. Since bot doesn't have capability to offer differentiated formula itself to the users, you have to put the value in it. Value also must be wrapped with square brackets [].

  • Example : p!dx sin(x) -v [pi], p!dx cos(a) -v [2 * pi]

-s Step <Optional> : Size of step that bot will use when performing numerical methods. Step size must be wrapped with square brackets []. Default step size is 10⁻⁸ if it's unspecified.

  • Example : p!dx sin(x) -v [pi] -s [10^(-8)]

-f or -front : Make bot use Forward Difference Method algorithm.

-c or -center : Make bot use Central Difference Method algorithm.

-b or -back : Make bot use Backward Difference Method algorithm.

Description

Bot calculating d/dx sin(x)

If the formula and the value are provided, bot will use numerical methods to obtain differentiated formula with specified value. For example, if we define formula as $f(x) = sin(x)$, and value as $v$, then what bot will return is ${f(v)}'$. Of course, this uses numerical methods, please keep in mind that the obtained value won't be exactly same with real value always. As parameter section says, $h$ is same with 10⁻⁸ as default, and if algorithm isn't specified, bot will use Central Difference Method as default since this gives better accuracy ( $O(h^{2})$ ).

About algorithm

Finite Difference Algorithm

Bot has capability to perform 3 algorithm : Forward Difference Method, Backward Difference Method, Central Difference Method. It's basically considering slope between two points on the $f(x)$ as differentiated value. Step size here means size of gap between two points, and represented as $h$.

  • Forward Difference Method

FDM follows formula below

$${f(x)}'\simeq\frac{f(x+h)-f(x)))}{h}$$

  • Central Difference Method

CDM follows formula below

$${f(x)}'\simeq\frac{f(x+h)-f(x-h)))}{2h}$$

  • Backward Difference Method

BDM follows formula below

$${f(x)}'\simeq\frac{f(x)-f(x-h)))}{h}$$

⚠️ **GitHub.com Fallback** ⚠️