1.. _ad_notes: 2 3Notes on automatic differentiation 4================================== 5 6Preliminaries 7------------- 8 9Definition of normalised derivative: 10 11.. math:: 12 :label: eq_norm_der_00 13 14 x^{\left[ n\right]}\left( t \right) = \frac{1}{n!} x^{\left( n\right)}\left( t \right). 15 16`General Leibniz rule <https://en.wikipedia.org/wiki/General_Leibniz_rule>`__: given 17:math:`a\left( t \right) = b\left( t \right) c\left( t \right)`, then 18 19.. math:: 20 :label: eq_leibniz_00 21 22 a^{\left[ n\right]}\left( t \right) = \sum_{j=0}^n b^{\left[ n - j\right]}\left( t \right) c^{\left[ j\right]}\left( t \right). 23 24Basic arithmetic 25---------------- 26 27Addition and subtraction 28^^^^^^^^^^^^^^^^^^^^^^^^ 29 30Given :math:`a\left( t \right) = b\left( t \right) \pm c\left( t \right)`, trivially 31 32.. math:: 33 :label: eq_ad_addsub_00 34 35 a^{\left[ n \right]}\left( t \right) = b^{\left[ n \right]}\left( t \right) \pm c^{\left[ n \right]}\left( t \right). 36 37Multiplication 38^^^^^^^^^^^^^^ 39 40Given :math:`a\left( t \right) = b\left( t \right) c\left( t \right)`, the derivative :math:`a^{\left[ n \right]}\left( t \right)` 41is given directly by the application of the general Leibniz rule :eq:`eq_leibniz_00`. 42 43Division 44^^^^^^^^ 45 46Given :math:`a\left( t \right) = \frac{b\left( t \right)}{c\left( t \right)}`, we can write 47 48.. math:: 49 :label: 50 51 a\left( t \right) c\left( t \right) = b\left( t \right). 52 53We can now apply the normalised derivative of order :math:`n` to both sides, use :eq:`eq_leibniz_00` and re-arrange to obtain: 54 55.. math:: 56 :label: 57 58 a^{\left[ n \right]}\left( t \right) = \frac{1}{c^{\left[ 0 \right]}\left( t \right)}\left[ b^{\left[ n \right]}\left( t \right) - \sum_{j=1}^n a^{\left[ n - j \right]}\left( t \right) c^{\left[ j \right]}\left( t \right)\right]. 59 60Squaring 61-------- 62 63Given :math:`a\left( t \right) = b\left( t \right)^2`, the computation of :math:`a^{\left[ n \right]}\left( t \right)` is a special 64case of :eq:`eq_leibniz_00` in which we take advantage of the summation's symmetry in order to halve the computational 65complexity: 66 67.. math:: 68 :label: eq_ad_square_00 69 70 a^{\left[ n \right]}\left( t \right) = 71 \begin{cases} 72 2\sum_{j=0}^{\frac{n}{2}-1} b^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right) + \left( b^{\left[ \frac{n}{2} \right]}\left( t \right) \right)^2 \mbox{ if $n$ is even}, \\ 73 2\sum_{j=0}^{\frac{n-1}{2}} b^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right) \mbox{ if $n$ is odd}. 74 \end{cases} 75 76Square root 77----------- 78 79Given :math:`a\left( t \right) =\sqrt{b\left( t \right)}`, we can write 80 81.. math:: 82 :label: 83 84 a\left( t \right)^2 = b\left( t \right). 85 86We can apply the normalised derivative of order :math:`n` to both sides, and, with the help of :eq:`eq_ad_square_00`, we obtain: 87 88.. math:: 89 :label: 90 91 b^{\left[ n \right]}\left( t \right) = 92 \begin{cases} 93 2\sum_{j=0}^{\frac{n}{2}-1} a^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) + \left( a^{\left[ \frac{n}{2} \right]}\left( t \right) \right)^2 \mbox{ if $n$ is even}, \\ 94 2\sum_{j=0}^{\frac{n-1}{2}} a^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \mbox{ if $n$ is odd}. 95 \end{cases} 96 97We can then isolate :math:`a^{\left[ n \right]}\left( t \right)` to obtain: 98 99.. math:: 100 :label: 101 102 a^{\left[ n \right]}\left( t \right) = 103 \begin{cases} 104 \frac{1}{2a^{\left[ 0 \right]}\left( t \right)} \left[ b^{\left[ n \right]}\left( t \right) - 2\sum_{j=1}^{\frac{n}{2}-1} a^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) - \left( a^{\left[ \frac{n}{2} \right]}\left( t \right) \right)^2 \right] \mbox{ if $n$ is even}, \\ 105 \frac{1}{2a^{\left[ 0 \right]}\left( t \right)} \left[ b^{\left[ n \right]}\left( t \right) - 2\sum_{j=0}^{\frac{n-1}{2}} a^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right] \mbox{ if $n$ is odd}. 106 \end{cases} 107 108Exponentiation 109-------------- 110 111Given :math:`a\left( t \right) = b\left( t \right)^\alpha`, with :math:`\alpha \neq 0`, we have 112 113.. math:: 114 :label: 115 116 a^\prime\left( t \right) = \alpha b\left( t \right)^{\alpha - 1} b^\prime\left( t \right). 117 118By multiplying both sides by :math:`b\left( t \right)` we obtain 119 120.. math:: 121 :label: 122 123 \begin{aligned} 124 b\left( t \right) a^\prime\left( t \right) & = b\left( t \right) \alpha b\left( t \right)^{\alpha - 1} b^\prime\left( t \right) \\ 125 & = \alpha b^\prime\left( t \right) a\left( t \right). 126 \end{aligned} 127 128We can now apply the normalised derivative of order :math:`n-1` to both sides, use :eq:`eq_leibniz_00` and re-arrange to obtain, 129for :math:`n > 0`: 130 131.. math:: 132 :label: 133 134 a^{\left[ n \right]}\left( t \right) = \frac{1}{n b^{\left[ 0 \right]}\left( t \right)} \sum_{j=0}^{n-1} \left[ n\alpha - j \left( \alpha + 1 \right) \right] b^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right). 135 136Exponentials 137------------ 138 139Natural exponential 140^^^^^^^^^^^^^^^^^^^ 141 142Given :math:`a\left( t \right) = e^{b\left( t \right)}`, we have 143 144.. math:: 145 :label: 146 147 a^\prime\left( t \right) = e^{b\left( t \right)}b^\prime\left( t \right) = a\left( t \right) b^\prime\left( t \right). 148 149We can now apply the normalised derivative of order :math:`n-1` to both sides, use :eq:`eq_norm_der_00` and :eq:`eq_leibniz_00` 150and obtain, for :math:`n > 0`: 151 152.. math:: 153 :label: 154 155 a^{\left[ n \right]}\left( t \right) = \frac{1}{n} \sum_{j=1}^{n} j a^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right). 156 157Standard logistic function 158^^^^^^^^^^^^^^^^^^^^^^^^^^ 159 160Given :math:`a\left( t \right) = \operatorname{sig} {b\left( t \right)}`, where :math:`\operatorname{sig}\left( x \right)` 161is the `standard logistic function <https://en.wikipedia.org/wiki/Logistic_function>`__ 162 163.. math:: 164 :label: 165 166 \operatorname{sig} \left( x \right) = \frac{1}{1+e^{-x}}, 167 168we have 169 170.. math:: 171 :label: 172 173 a^\prime\left( t \right) = \operatorname{sig}{b\left( t \right)} \left[1 - \operatorname{sig}{b\left( t \right)} \right] b^\prime\left( t \right) = a\left( t \right) \left[1 - a\left( t \right) \right] b^\prime\left( t \right), 174 175which, after the introduction of the auxiliary function 176 177.. math:: 178 :label: 179 180 c\left( t \right) = a^2\left( t \right) , 181 182becomes 183 184.. math:: 185 :label: 186 187 a^\prime\left( t \right) = \left[ a\left( t \right) - c\left( t \right) \right] b^\prime\left( t \right). 188 189After applying the normalised derivative of order :math:`n-1` to both sides, we can use :eq:`eq_norm_der_00`, 190:eq:`eq_leibniz_00` and :eq:`eq_ad_addsub_00` to obtain, for :math:`n > 0`: 191 192.. math:: 193 :label: 194 195 a^{\left[ n \right]}\left( t \right) = \frac{1}{n}\sum_{j=1}^{n} j \left[ a^{\left[ n - j \right]} \left( t \right)- c^{\left[ n - j \right]}\left( t \right)\right] b^{\left[ j \right]}\left( t \right). 196 197 198Logarithms 199---------- 200 201Natural logarithm 202^^^^^^^^^^^^^^^^^ 203 204Given :math:`a\left( t \right) = \log b\left( t \right)`, we have 205 206.. math:: 207 :label: 208 209 a^\prime\left( t \right) = \frac{b^\prime\left( t \right)}{b\left( t \right)}, 210 211or, equivalently, 212 213.. math:: 214 :label: 215 216 b\left( t \right) a^\prime\left( t \right) = b^\prime\left( t \right). 217 218We can now apply the normalised derivative of order :math:`n-1` to both sides, use :eq:`eq_norm_der_00` and :eq:`eq_leibniz_00` 219and re-arrange to obtain, for :math:`n > 0`: 220 221.. math:: 222 :label: 223 224 a^{\left[ n \right]}\left( t \right) = \frac{1}{n b^{\left[ 0 \right]}\left( t \right)} \left[ n b^{\left[ n \right]}\left( t \right) - \sum_{j=1}^{n-1} j b^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right]. 225 226Trigonometric functions 227----------------------- 228 229.. _ad_tan: 230 231Tangent 232^^^^^^^ 233 234Given :math:`a\left( t \right) = \tan b\left( t \right)`, we have 235 236.. math:: 237 :label: 238 239 a^\prime\left( t \right) = \left[ \tan^2 b\left( t \right) + 1 \right] b^\prime\left( t \right) = a^2\left( t \right)b^\prime\left( t \right) + b^\prime\left( t \right), 240 241which, after the introduction of the auxiliary function 242 243.. math:: 244 :label: 245 246 c\left( t \right) = a^2\left( t \right) , 247 248becomes 249 250.. math:: 251 :label: 252 253 a^\prime\left( t \right) = c\left( t \right) b^\prime\left( t \right) + b^\prime\left( t \right). 254 255After applying the normalised derivative of order :math:`n-1` to both sides, we can use :eq:`eq_norm_der_00`, 256:eq:`eq_leibniz_00` and :eq:`eq_ad_addsub_00` to obtain, for :math:`n > 0`: 257 258.. math:: 259 :label: 260 261 a^{\left[ n \right]}\left( t \right) = \frac{1}{n}\sum_{j=1}^{n} j c^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right) + b^{\left[ n \right]}\left( t \right). 262 263Inverse trigonometric functions 264------------------------------- 265 266.. _ad_asin: 267 268Inverse sine 269^^^^^^^^^^^^ 270 271Given :math:`a\left( t \right) = \arcsin b\left( t \right)`, we have 272 273.. math:: 274 :label: 275 276 a^\prime\left( t \right) = \frac{b^\prime\left( t \right)}{\sqrt{1 - b^2\left( t \right) }}, 277 278or, equivalently, 279 280.. math:: 281 :label: eq_ad_asin00 282 283 a^\prime\left( t \right) \sqrt{1 - b^2\left( t \right) } = b^\prime\left( t \right). 284 285We introduce the auxiliary function 286 287.. math:: 288 :label: 289 290 c\left( t \right) = \sqrt{1 - b^2\left( t \right) }, 291 292so that :eq:`eq_ad_asin00` can be rewritten as 293 294.. math:: 295 :label: 296 297 a^\prime\left( t \right) c\left( t \right) = b^\prime\left( t \right). 298 299Applying the normalised derivative of order :math:`n-1` to both sides yields, via :eq:`eq_norm_der_00`: 300 301.. math:: 302 :label: 303 304 \left[a^\prime\left( t \right) c\left( t \right)\right]^{\left[ n - 1 \right]} = n b^{\left[ n \right]} \left( t \right). 305 306We can now apply the general Leibniz rule :eq:`eq_leibniz_00` to the left-hand side and re-arrange 307the terms to obtain, for :math:`n > 0`: 308 309.. math:: 310 :label: 311 312 a^{\left[ n \right]}\left( t \right) = \frac{1}{n c^{\left[ 0 \right]}\left( t \right)}\left[ n b^{\left[ n \right]}\left( t \right) - \sum_{j=1}^{n-1} j c^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right]. 313 314.. _ad_acos: 315 316Inverse cosine 317^^^^^^^^^^^^^^ 318 319The derivation is identical to the :ref:`inverse sine <ad_asin>`, apart from a sign change. 320Given :math:`a\left( t \right) = \arccos b\left( t \right)`, 321the final result is, for :math:`n > 0`: 322 323.. math:: 324 :label: 325 326 a^{\left[ n \right]}\left( t \right) = -\frac{1}{n c^{\left[ 0 \right]}\left( t \right)}\left[ n b^{\left[ n \right]}\left( t \right) + \sum_{j=1}^{n-1} j c^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right], 327 328with :math:`c\left( t \right)` defined as: 329 330.. math:: 331 :label: 332 333 c\left( t \right) = \sqrt{1 - b^2\left( t \right) }. 334 335.. _ad_atan: 336 337Inverse tangent 338^^^^^^^^^^^^^^^ 339 340Given :math:`a\left( t \right) = \arctan b\left( t \right)`, we have 341 342.. math:: 343 :label: 344 345 a^\prime\left( t \right) = \frac{b^\prime\left( t \right)}{1 + b^2\left( t \right) }, 346 347or, equivalently, 348 349.. math:: 350 :label: eq_ad_atan00 351 352 a^\prime\left( t \right) \left[1 + b^2\left( t \right) \right] = b^\prime\left( t \right). 353 354We introduce the auxiliary function 355 356.. math:: 357 :label: 358 359 c\left( t \right) = b^2\left( t \right), 360 361so that :eq:`eq_ad_atan00` can be rewritten as 362 363.. math:: 364 :label: 365 366 a^\prime\left( t \right) + a^\prime\left( t \right) c\left( t \right) = b^\prime\left( t \right). 367 368Applying the normalised derivative of order :math:`n-1` to both sides yields, via :eq:`eq_norm_der_00` and :eq:`eq_ad_addsub_00`: 369 370.. math:: 371 :label: 372 373 n a^{\left[ n \right]} \left( t \right) + \left[a^\prime\left( t \right) c\left( t \right)\right]^{\left[ n - 1 \right]} = n b^{\left[ n \right]} \left( t \right). 374 375With the help of the general Leibniz rule :eq:`eq_leibniz_00`, after re-arranging we obtain, for :math:`n > 0`: 376 377.. math:: 378 :label: 379 380 a^{\left[ n \right]}\left( t \right) = \frac{1}{n \left[ c^{\left[ 0 \right]}\left( t \right) + 1 \right]}\left[ n b^{\left[ n \right]}\left( t \right) - \sum_{j=1}^{n-1} j c^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right]. 381 382Two-argument inverse tangent 383^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 384 385Given :math:`a\left( t \right) = \operatorname{arctan2}\left( b\left( t \right), c\left( t \right) \right)`, we have 386 387.. math:: 388 :label: eq_ad_atan200 389 390 a^\prime\left( t \right) = \frac{c\left( t \right) b^\prime\left( t \right)-b\left( t \right)c^\prime \left( t \right)} 391 {b^2\left( t \right)+c^2\left( t \right)}. 392 393After the introduction of the auxiliary function 394 395.. math:: 396 :label: 397 398 d\left( t \right) = b^2\left( t \right)+c^2\left( t \right), 399 400:eq:`eq_ad_atan200` can be rewritten as 401 402.. math:: 403 :label: 404 405 d\left( t \right)a^\prime\left( t \right) = c\left( t \right) b^\prime\left( t \right)-b\left( t \right)c^\prime \left( t \right). 406 407We can now apply the normalised derivative of order :math:`n-1` to both sides, and, via :eq:`eq_leibniz_00`, obtain, for :math:`n > 0`: 408 409.. math:: 410 :label: 411 412 \begin{aligned} 413 a^{\left[ n \right]}\left( t \right) &= \frac{1}{nd^{\left[ 0 \right]}\left( t \right)}\left[\vphantom{\sum_{j=1}^{n-1}j\left( \right)} 414 n\left( c^{\left[ 0 \right]}\left( t \right) b^{\left[ n \right]}\left( t \right) - b^{\left[ 0 \right]}\left( t \right) c^{\left[ n \right]}\left( t \right)\right) \right.\\ 415 &\left. + \sum_{j=1}^{n-1}j\left( c^{\left[ n-j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right) - 416 b^{\left[ n-j \right]}\left( t \right) c^{\left[ j \right]}\left( t \right) - 417 d^{\left[ n-j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right) \right]. 418 \end{aligned} 419 420Hyperbolic functions 421-------------------- 422 423.. _ad_sinh: 424 425Hyperbolic sine 426^^^^^^^^^^^^^^^ 427 428Given :math:`a\left( t \right) = \sinh b\left( t \right)`, we have 429 430.. math:: 431 :label: eq_ad_sinh_00 432 433 a^\prime\left( t \right) = b^\prime\left( t \right) \cosh b\left( t \right). 434 435We introduce the auxiliary function 436 437.. math:: 438 :label: 439 440 c\left( t \right) = \cosh b\left( t \right), 441 442so that :eq:`eq_ad_sinh_00` can be rewritten as 443 444.. math:: 445 :label: 446 447 a^\prime\left( t \right) = c\left( t \right) b^\prime\left( t \right). 448 449We can now apply the normalised derivative of order :math:`n-1` to both sides, and, via :eq:`eq_leibniz_00`, obtain, for :math:`n > 0`: 450 451.. math:: 452 :label: 453 454 a^{\left[ n \right]}\left( t \right) = \frac{1}{n} \sum_{j=1}^{n} j c^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right). 455 456Hyperbolic cosine 457^^^^^^^^^^^^^^^^^ 458 459Given :math:`a\left( t \right) = \cosh b\left( t \right)`, the process of deriving :math:`a^{\left[ n \right]}\left( t \right)` is 460identical to the :ref:`hyperbolic sine <ad_sinh>`. After the definition of the auxiliary function 461 462.. math:: 463 :label: 464 465 s\left( t \right) = \sinh b\left( t \right), 466 467the final result, for :math:`n > 0`, is: 468 469.. math:: 470 :label: 471 472 a^{\left[ n \right]}\left( t \right) = \frac{1}{n} \sum_{j=1}^{n} j s^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right). 473 474Hyperbolic tangent 475^^^^^^^^^^^^^^^^^^ 476 477Given :math:`a\left( t \right) = \tanh b\left( t \right)`, the process of deriving :math:`a^{\left[ n \right]}\left( t \right)` is 478identical to the :ref:`tangent <ad_tan>`, apart from a sign change. After the definition of the auxiliary function 479 480.. math:: 481 :label: 482 483 c\left( t \right) = a^2\left( t \right), 484 485the final result, for :math:`n > 0`, is: 486 487.. math:: 488 :label: 489 490 a^{\left[ n \right]}\left( t \right) = b^{\left[ n \right]}\left( t \right) - \frac{1}{n}\sum_{j=1}^{n} j c^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right). 491 492Inverse hyperbolic functions 493---------------------------- 494 495.. _ad_asinh: 496 497Inverse hyperbolic sine 498^^^^^^^^^^^^^^^^^^^^^^^ 499 500Given :math:`a\left( t \right) = \operatorname{arsinh} b\left( t \right)`, the process of deriving :math:`a^{\left[ n \right]}\left( t \right)` is 501identical to the :ref:`inverse sine <ad_asin>`, apart from a sign change. After the definition of the auxiliary function 502 503.. math:: 504 :label: 505 506 c\left( t \right) = \sqrt{1 + b^2\left( t \right) }, 507 508the final result, for :math:`n > 0`, is: 509 510.. math:: 511 :label: 512 513 a^{\left[ n \right]}\left( t \right) = \frac{1}{n c^{\left[ 0 \right]}\left( t \right)}\left[ n b^{\left[ n \right]}\left( t \right) - \sum_{j=1}^{n-1} j c^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right]. 514 515Inverse hyperbolic cosine 516^^^^^^^^^^^^^^^^^^^^^^^^^ 517 518Given :math:`a\left( t \right) = \operatorname{arcosh} b\left( t \right)`, the process of deriving :math:`a^{\left[ n \right]}\left( t \right)` is 519identical to the :ref:`inverse hyperbolic sine <ad_asinh>`, apart from a sign change. After the definition of the auxiliary function 520 521.. math:: 522 :label: 523 524 c\left( t \right) = \sqrt{b^2\left( t \right) - 1 }, 525 526the final result, for :math:`n > 0`, is: 527 528.. math:: 529 :label: 530 531 a^{\left[ n \right]}\left( t \right) = \frac{1}{n c^{\left[ 0 \right]}\left( t \right)}\left[ n b^{\left[ n \right]}\left( t \right) - \sum_{j=1}^{n-1} j c^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right]. 532 533Inverse hyperbolic tangent 534^^^^^^^^^^^^^^^^^^^^^^^^^^ 535 536Given :math:`a\left( t \right) = \operatorname{artanh} b\left( t \right)`, the process of deriving :math:`a^{\left[ n \right]}\left( t \right)` is 537identical to the :ref:`inverse tangent <ad_atan>`, apart from a sign change. After the definition of the auxiliary function 538 539.. math:: 540 :label: 541 542 c\left( t \right) = b^2\left( t \right), 543 544the final result, for :math:`n > 0`, is: 545 546.. math:: 547 :label: 548 549 a^{\left[ n \right]}\left( t \right) = \frac{1}{n \left[1 - c^{\left[ 0 \right]}\left( t \right) \right]}\left[ n b^{\left[ n \right]}\left( t \right) + \sum_{j=1}^{n-1} j c^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right) \right]. 550 551Special functions 552----------------- 553 554.. _ad_erf: 555 556Error function 557^^^^^^^^^^^^^^ 558 559Given :math:`a\left( t \right) = \operatorname{erf} b\left( t \right)`, we have 560 561.. math:: 562 :label: 563 564 a^\prime\left( t \right) = \frac 2{\sqrt\pi} \exp{\left[-b^2\left( t \right)\right]} b^\prime\left( t \right), 565 566which, after the introduction of the auxiliary function 567 568.. math:: 569 :label: 570 571 c\left( t \right) = \exp{\left[ -b^2\left( t \right)\right]} , 572 573becomes 574 575.. math:: 576 :label: 577 578 a^\prime\left( t \right) = \frac 2{\sqrt\pi}c\left( t \right) b^\prime\left( t \right). 579 580After applying the normalised derivative of order :math:`n-1` to both sides, we can use :eq:`eq_norm_der_00` 581and :eq:`eq_leibniz_00` to obtain, for :math:`n > 0`: 582 583.. math:: 584 :label: 585 586 a^{\left[ n \right]}\left( t \right) = \frac 1n \frac 2{\sqrt\pi}\sum_{j=1}^{n} j c^{\left[ n - j \right]}\left( t \right) b^{\left[ j \right]}\left( t \right). 587 588Celestial mechanics 589------------------- 590 591Inverse of Kepler's elliptic equation 592^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 593 594The inverse of Kepler's elliptic equation is the bivariate function :math:`E = E\left( e, M \right)` implicitly defined by the 595trascendental equation 596 597.. math:: 598 :label: 599 600 M = E - e \sin E, 601 602with :math:`e \in \left[ 0, 1 \right)`. Given :math:`a\left( t \right) = E\left( e\left( t \right), M \left( t \right) \right)`, we have 603 604.. math:: 605 :label: 606 607 a^\prime\left( t \right) = \frac{\partial E}{\partial e}e^\prime\left( t \right) + \frac{\partial E}{\partial M}M^\prime\left( t \right), 608 609where the partial derivatives are 610 611.. math:: 612 :label: 613 614 \begin{cases} 615 \frac{\partial E}{\partial e} = \frac{\sin E}{1-e\cos E}, \\ 616 \frac{\partial E}{\partial M} = \frac{1}{1-e\cos E}. \\ 617 \end{cases} 618 619Expanding the partial derivatives yields 620 621.. math:: 622 :label: 623 624 a^\prime\left( t \right) = \frac{e^\prime \left( t \right)\sin a\left(t \right) + M^\prime\left( t \right)}{1-e\left( t \right)\cos a\left(t \right)}, 625 626or, equivalently, 627 628.. math:: 629 :label: eq_ad_kepE_00 630 631 a^\prime\left( t \right) - a^\prime\left( t \right) e \left( t \right) \cos a\left(t \right) = e^\prime \left( t \right)\sin a\left(t \right) + M^\prime\left( t \right). 632 633We can now introduce the auxiliary functions 634 635.. math:: 636 :label: 637 638 \begin{cases} 639 c\left( t \right) = e\left( t \right) \cos a\left(t \right), \\ 640 d\left( t \right) = \sin a\left(t \right), \\ 641 \end{cases} 642 643so that :eq:`eq_ad_kepE_00` can be rewritten as 644 645.. math:: 646 :label: 647 648 a^\prime\left( t \right) - a^\prime\left( t \right) c\left( t \right) = e^\prime \left( t \right)d\left(t \right) + M^\prime\left( t \right). 649 650After applying the normalised derivative of order :math:`n-1` to both sides, we can use :eq:`eq_norm_der_00` 651and :eq:`eq_leibniz_00` and re-arrange to obtain, for :math:`n > 0`: 652 653.. math:: 654 :label: 655 656 a^{\left[ n \right]}\left( t \right) = \frac{1}{n \left(1 - c^{\left[ 0 \right]}\left( t \right)\right)} 657 \left[ 658 n\left( e^{\left[ n \right]}\left( t \right) d^{\left[ 0 \right]}\left( t \right) + M^{\left[ n \right]}\left( t \right)\right) + 659 \sum_{j=1}^{n-1}j\left( c^{\left[ n - j \right]}\left( t \right) a^{\left[ j \right]}\left( t \right)+ 660 d^{\left[ n - j \right]}\left( t \right)e^{\left[ j \right]}\left( t \right) 661 \right) 662 \right]. 663 664Time functions 665-------------- 666 667Time polynomials 668^^^^^^^^^^^^^^^^ 669 670Given the time polynomial of order :math:`n` 671 672.. math:: 673 :label: 674 675 p_n\left( t \right) = \sum_{i=0}^n a_i t^i, 676 677its derivative of order :math:`j` is 678 679.. math:: 680 :label: 681 682 \left(p_n\left( t \right)\right)^{\left( j \right)} = \sum_{i=j}^n \left( i \right)_j a_i t^{i - j}, 683 684where :math:`\left( i \right)_j` is the `falling factorial <https://en.wikipedia.org/wiki/Falling_and_rising_factorials>`__. 685The normalised derivative of order :math:`j` is 686 687.. math:: 688 :label: 689 690 \left(p_n\left( t \right)\right)^{\left[ j \right]} = \frac{1}{j!}\sum_{i=j}^n \left( i \right)_j a_i t^{i - j}, 691 692which, with the help of elementary relations involving factorials and after re-arranging the indices, can be rewritten as 693 694.. math:: 695 :label: 696 697 \left(p_n\left( t \right)\right)^{\left[ j \right]} = \sum_{i=0}^{n-j} {i+j \choose j} a_{i+j} t^i. 698