2
$\begingroup$

I am beginning to learn Mathematica and have the following question: How can I return a derivative with exact numbers instead of one involving numerical approximations?

My original, single variable function contains certain decimals:

f[x_] := 2*10^6 (1 + 1.000696^(-0.333 ((x + 2)/3)^1.7))^-1 - 1*10^6

When I evaluate using D[f[x], {x, 1}] or f'[x], Mathematica returns

$\quad \quad \frac{121.696\times1.0007^{-0.0514444 (2 + x)^{1.7}}(2 + x)^{0.7}}{\left(1+1.0007^{-0.0514444(2 + x)^{1.7}}\right)^2}$

However, the derivative by hand is exactly

$\quad \quad \frac{2\times 10^6\cdot 0.333\cdot 1.7\cdot \frac{1}{3}\cdot ln(1.000696)\left(1.000696^{-0.333\left(\frac{x+2}{3}\right)^{1.7}}\right)\left(\frac{x+2}{3}\right)^{0.7}}{\left(1+1.000696^{-0.333\left(\frac{x+2}{3}\right)^{1.7}}\right)^2}$

$\quad \quad =\frac{377,400\cdot ln(1.000696)\left(1.000696^{-0.333\left(\frac{x+2}{3}\right)^{1.7}}\right)\left(\frac{x+2}{3}\right)^{0.7}}{\left(1+1.000696^{-0.333\left(\frac{x+2}{3}\right)^{1.7}}\right)^2}$

$\approx$ Mathematica result.

Any comments and thoughts are greatly appreciated!

A follow up question is: How does Mathematica propagate approximations? In other words, does Mathematica treat my derivative as displayed or does it think of it exactly?

$\endgroup$
  • 1
    $\begingroup$ Try g=Rationalize[f[x]] and then D[g, {x, 1}] $\endgroup$ – Algohi May 28 '15 at 4:28
  • $\begingroup$ Mathematica does not readily support mixed exact and inexact quantities. If you want to preserved parts of an expression as exact, you should follow @Algohi's advice. Basically, if any inexact quantities are encountered during a computation, all numerics will be coerced to inexact. $\endgroup$ – m_goldberg May 28 '15 at 4:34
  • $\begingroup$ Thank you @Algohi and m_goldberg. I will add Rationalize to my Mathematica vocabulary. Furthermore, thank you for editing my question, m_goldberg; I will keep the changes in mind for future posts. I tried applying Rationalize to my problem, which mostly worked for $f(x)$ (I had to manually change a seemingly irrational term in the output). Unfortunately, the subsequent form of the derivative is much more unwieldy, in part beccause Mathematica's algorithms did not find $ln(1.000696)$. I am starting to see how my original request might be beyond the software's capabilities. $\endgroup$ – Polite Master May 28 '15 at 5:03
  • $\begingroup$ Use something like Rationalize[f[x], 10^-6] to force all the subexpressions in f[x] to be converted to exact quantities (within width-10^-6 bins). $\endgroup$ – Stephen Luttrell May 28 '15 at 9:36
  • $\begingroup$ Thank you @Stephen Luttrell! I will certainly try that next. $\endgroup$ – Polite Master May 30 '15 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.