On 02/12/11 08:58, D. S. McNeil wrote:
Normally I can differentiate analytically to get the slope and
inflection points. While trying to have a quick look into these points
with numerical differentiation I noticed that mpmath is giving me
values quite distant from the ones obtained with analytical formulas.
I think there's a missing term in your analytical derivatives. Your
three functions are
# fundamental mode
def phi(x):
return mpmath.cos(k*x) - mpmath.cosh(k*x) + alpha* (
mpmath.sin(k*x) - mpmath.sinh(k*x) )
# slope of fundamental
def phi_dx(x):
return -mpmath.sin(k*x) - mpmath.sinh(k*x) + alpha* (
mpmath.cos(k*x) - mpmath.cosh(k*x) )
# curvature of fundamental
def phi_dx2(x):
return -mpmath.cos(k*x) - mpmath.cosh(k*x) - alpha* (
mpmath.sin(k*x) + mpmath.sinh(k*x) )
and it looks to me like you're missing a factor of k in phi_dx and k^2
in phi_dx2. Inserting them seems to get rid of the discrepancy.
Doug
Hi Doug,
You are right! I did the derivatives using only 'x' as argument...
That's good though, since I was actually relying on mpmath to do some
derivatives on some other functions...
Thank you for your time!
Regards.
Guilherme
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org