diff function bug

7 views
Skip to first unread message

John Dickson

unread,
Mar 11, 2024, 8:14:20 AMMar 11
to numbas...@googlegroups.com
Hi,

I think there may be a bug in the diff function.

The function returns an error when trying to differentiate a power which has a negative denominator.

For example 

For a variable name, test with value: expression("x^(1/-3)")

and then a variable name, diff_test with value: diff(test,"x")

I am getting the error message: Error evaluating variable diff_test: Don't know how to differentiate x^(1/(-3))

Not a huge issue but thought I'd flag it up.

John

Christian Lawson-Perfect

unread,
Mar 12, 2024, 5:59:05 AMMar 12
to numbas...@googlegroups.com
Thanks for reporting this

I've made the differentiation routine run the expression through the basic simplification rules first, to deal with cases like this. The rule for differentiating a power looks for plus-or-minus a rational number as the exponent, and (1/(-3)) doesn't match that. After rewriting it to -(1/3), it does match and the differentiation proceeds.

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/CAKO9%3DtWke-KuRtm0Beh2hkvsxfApghdtkegTziSsxHBko-8%2BrQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages