apple / swift-numerics

Advanced mathematical types and functions for Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pitch: Partial Differentiation of multivariate polynomials (link to my SPM package)

Sajjon opened this issue · comments

Hey, I already asked in #38 about the scope of swift-numerics, but since I have not got a reply yet I keep on pitching some math stuff.

Last summer I wrote EquationKit(just gave SPM support to it) which offers multivariate polynomial with support for partial differentiation:

let polynomial = (3*x + 5*y - 17) * (7*x - 9*y + 23)
print(polynomial) // 21x² + 8xy - 50x - 45y² + 268y - 391)
let number = polynomial.evaluate() {[ x <- 4, y <- 1 ]}
print(number) // 0

let y= polynomial.differentiateWithRespectTo(x)
print(y') // 42x + 8y - 50
y.evaluate() {[ x <- 1, y <- 1 ]} // 0

let x= polynomial.differentiateWithRespectTo(y)
print(x') // 8x - 90y + 268
 x.evaluate() {[ x <- 11.5,  y <- 4 ]} // 0

Would that fit in here? I saw #42 and would I would mention this.

I have implement Polynomial before, the multiplication of polynomial is done by convolution.
https://github.com/SusanDoggie/Doggie/blob/master/Sources/Doggie/Maths/Polynomial.swift

I use to solving the system of polynomial equations. That's helpful for finding the intersection of two bezier curves.
https://github.com/SusanDoggie/Doggie/blob/69552cd39fdb50fea6e82f7abd09f1b2ccff332a/Sources/Doggie/Maths/Bezier/CubicBezier.swift#L445-L478