Dear list.
Sorry for the strange title, I couldn't come up with anything more
meaningful ...
I'm working with non-uniform cubic splines and I created a simple
polynomial where the input t in the range [t0, t1] is mapped to the
range [0, 1]:
>>> import sympy as sp
>>> t, t0, t1 = sp.symbols('t t:2')
>>> coefficients = sp.Matrix(sp.symbols('a:4')[::-1])
>>> p = sp.Matrix([t**3, t**2, t, 1]).dot(coefficients).subs(t, (t - t0) / (t1
>>> - t0))
>>> p
a0 + a1*(t - t0)/(-t0 + t1) + a2*(t - t0)**2/(-t0 + t1)**2 + a3*(t -
t0)**3/(-t0 + t1)**3
So far so good.
The problem occurs when I'm getting the derivative:
>>> p.diff(t)
a1/(-t0 + t1) + a2*(2*t - 2*t0)/(-t0 + t1)**2 + 3*a3*(t - t0)**2/(-t0 + t1)**3
I'm talking about the numerator of the second term:
a2*(2*t - 2*t0)
I would expect that to be:
2*a2*(t - t0)
... and in fact that's how it is done in the third term!
It gets worse when I substitute t1 for t:
>>> p.diff(t).subs(t, t1)
a1/(-t0 + t1) + a2*(-2*t0 + 2*t1)/(-t0 + t1)**2 + 3*a3/(-t0 + t1)
Now the second term contains some parts that should cancel each other
out. The second term should be:
2*a2*/(-t0 + t1)
Again, the third term already has this form.
Is there a way I can tell SymPy to show the terms as I like it?
BTW, I'm using SymPy version 1.1.1.
cheers,
Matthias
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAFesC-eTWCiQuWuc11jiuonrny%2BjfNdT2mC0CfGm_2V72KBqDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.