Featured Post

8755

diff(abs(z), z)  returns abs(1, z)  and the latter, for a numeric z, is defined only for a nonzero real z.
However,  functions such as abs(I+sin(t)) are (real) differentiable for a real t and diff should work. It usually does, but not always.

restart
f:= t -> abs(GAMMA(2*t+I)):  # We want D(f)(1)
D(f)(1): 
evalf(%);  # Error, (in simpl/abs) abs is not differentiable at non-real arguments
D(f)(1); simplify(%); 
evalf(%);   # 0.3808979508 + 1.161104935*I,  wrong

The same wrong results are obtained with diff instead of D

diff(f(t),t):   # or  diff(f(t),t) assuming t::real; 
eval(%,t=1);
simplify(%); evalf(%);   # wrong, should be real

To obtain the correct result, we could use the definition of the derivative:

limit((f(t)-f(1))/(t-1), t=1); evalf(%); # OK 
fdiff(f(t), t=1);    # numeric, OK

   

       0.8772316598
       0.8772316599

Note that abs(1, GAMMA(2 + I)); returns 1; this is also wrong, it should produce an error because  GAMMA(2+I) is not real;
 

Let's redefine now `diff/abs`  and redo the computations.

restart
`diff/abs` := proc(u, z)   # implements d/dx |f(x+i*y|) when f is analytic and f(...)<>0
local u1:=diff(u,z);
1/abs(u)*( Re(u)*Re(u1) + Im(u)*Im(u1) )
end:
f:= t -> abs(GAMMA(2*t+I));
D(f)(1); evalf(%);   # OK now

               

         0.8772316597

Now diff works too.

diff(f(t),t);
eval(%,t=1);
simplify(%); evalf(%);   # it works

This is a probably a very old bug which may make diff(u,x)  fail for expressions having subespressions abs(...) depending on x.

However it works  using assuming x::real, but only if evalc simplifies u.
The problem is actually more serious because diff/ for Re, Im, conjugate should be revized too. Plus some other related things. 

Featured Post

            We announce the release of a new book, of title Fourier Transforms for Chemistry, which is in the form of a Maple worksheet.  This book is freely available through Maple Application Centre, either as a Maple worksheet with no output from commands or as a .pdf file with all output and plots.

            This interactive electronic book in the form of a Maple worksheet comprises six chapters containing Maple commands, plus an overview 0 as an introduction.  The chapters have content as follows.

  -   1    continuous Fourier transformation

  -   2    electron diffraction of a gaseous sample

  -   3    xray diffraction of a crystal and a powder

  -   4    microwave spectrum of a gaseous sample

  -   5    infrared and Raman spectra of a liquid sample

  -   6    nuclear magnetic resonance of various samples

            This book will be useful in courses of physical chemistry or devoted to the determination of molecular structure by physical methods.  Some content, duly acknowledged, has been derived and adapted from other authors, with permission.



Can I make a "library"?

Maple 2015 asked by RHERWOLF 57 Yesterday

simply sin solution

Maple 2015 asked by lucaud 25 March 04

derivate simply step please

Maple asked by lucaud 25 March 04

root(x,3) behavior

Maple 17 asked by Zeineb 210 March 04

System of PDE's

Maple 2020 asked by kjell 10 Yesterday

Deleted questions again

MaplePrimes asked by vv 8755 Today

Import and plot data

Maple asked by Nick_99 40 Today