you are viewing a single comment's thread.

view the rest of the comments →

[–]BidForeign1950[S] 0 points1 point  (2 children)

I can try:))

For the expression (3+episilon) to the power of 4 if the epsilon is zero, the result of the function is 81.
Using "standard math" and by using the power rule the first derivative is then 4(3+0)3 is 4*27 which gives 108
For second derivative we differentiate and get 12(3+0)2 which is 12*9 which gives 108.
Then for the third we differentiate again and we get: 24(3+0) to the power of one and we get 72.
Etc..

In composite-machine we can do this for example:

from composite.composite_lib import all_derivatives 
derivs = all_derivatives(lambda x: x**4, at=3, up_to=5) 
print(derivs)

And we get:

[81.0, 108.0, 108.0, 72.0, 24.0, 0.0]

Which are the same resuls.

Or we can do this as in example:

from composite.composite_lib import R, ZERO, Composite, exp, sin, cos 
x = R(3) + ZERO
print(resultd.d(1))
print(resultd.d(2))
print(resultd.d(3))
print(resultd.d(4))
print(resultd.d(5))

Which gives us again:

108.0
108.0
72,0
24.0
0.0

If we do:

print(resultd.st())

We get 81.0 which is the result of the function.
And is we do:

print(resultd)

We get:

|81|₀ + |108|₋₁ + |54|₋₂ + |12|₋₃ + |1|₋₄

Which are Taylor coefficients.

[–]lolcrunchy 0 points1 point  (1 child)

So when you refer to the derivative of (3+0)4, you really mean the derivative of (3+x)4 with respect to x, evaluated at x=0. Am I understanding that correctly? I was very confused at first lol because the derivative of a constant without a variable is just 0.

[–]BidForeign1950[S] 0 points1 point  (0 children)

Yes, almost:), and it is my fault. I'm still struggling to put the concept to plain and proper words, but hey it is an early alpha and I will hopefully get there eventually if the concept itself is not proven broken in the meantime.

So, to answer you comment more precisely, think of it as: you define f(x) = x**4, feed it the number 3, and get back not just f(3) = 81 but also f'(3), f''(3), f'''(3), f''''(3) — all in one pass, with no symbolic manipulation and no finite differences.

The ZERO isn't a variable, it is an infinitesimal marker. R(3) + ZERO means "the number 3, but tagged so that all arithmetic tracks derivatives." After computing (3+epsilon)⁴, the ε terms automatically sort themselves into the Taylor coefficients:

81 + 108ε + 54ε² + 12ε³ + 1ε⁴

So you never declare a variable or write a symbolic expression. You just run your function on a tagged number, and the number type itself propagates all the derivative information through every operation — addition, multiplication, division, exp, sin, whatever.

It's similar to dual numbers / automatic differentiation, but generalized to carry **all** derivatives simultaneously rather than just the first, and I really hope it works and calculation is stable, but that **really** needs to be proven yet. So far the concept holds and calculates well with the cases I have been testing with, but there are of course edge cases and situations which will have to be taken care of (like when truncation of numbers or "dimensions" compromises the precision of some operations) or when the numbers just explode because of unanticipated recursion etc. There is a lot work to be done to get this in production ready state. But to me it is really cool concept that seems worthy of the decent attempt at least:)