On Thu, Nov 20, 2014 at 7:52 AM, Bill Page <bill.p...@newsynthesis.org> wrote: > So here (20) is a simpler expression for derivative of arg: > > (16) -> abs(x)==sqrt(x*conjugate(x)) > Compiled code for abs has been cleared. > Compiled code for arg has been cleared. > 1 old definition(s) deleted for function or rule abs > Type: > Void > (17) -> arg(x)==log(x/abs(x))/%i > 1 old definition(s) deleted for function or rule arg > Type: > Void > (18) -> arg %i > Compiling function abs with type Complex(Integer) -> Expression( > Complex(Integer)) > Compiling function arg with type Complex(Integer) -> Expression( > Complex(Integer)) > > (18) - %i log(%i) > Type: > Expression(Complex(Integer)) > (19) -> complexNumeric % > > (19) 1.5707963267_948966192 > Type: > Complex(Float) > (20) -> D(arg(x),x) > Compiling function abs with type Variable(x) -> Expression(Integer) > Compiling function arg with type Variable(x) -> Expression(Complex( > Integer)) > > _ > - %ix + %i x > (20) ------------ > _ > 2xx > Type: > Expression(Complex(Integer)) > > > In general I am a little uncertain if, how and when to deal with > simplifications of expressions like abs that can be expressed in terms of > more fundamental/elementary functions. What do you think?
The identity abs(z) = sqrt(z*conjugate(z)) is just the same problem as for things like exp(x) = E^x, csc(x) = 1/sin(x), sinh(x) = (exp(x)-exp(-x)/2, asin(x) = -i*log(i*x+sqrt(1-x^2)), asinh(x) = log(x+sqrt(1+x^2)), ... Essentially a lot of functions can be written using simpler functions. The expression is sometimes simpler using abs() and sometimes simpler using sqrt(x*conjugate(x)), and that is true for all the other cases too. So a CAS needs to be able to handle both, and allow the user to convert one to the other. For example in SymPy, we can do: In [1]: sinh(x)**2+1 Out[1]: 2 sinh (x) + 1 In [2]: (sinh(x)**2+1).rewrite(exp) Out[2]: 2 ⎛ x -x⎞ ⎜ℯ ℯ ⎟ ⎜── - ───⎟ + 1 ⎝2 2 ⎠ In [3]: _.expand() Out[3]: 2⋅x -2⋅x ℯ 1 ℯ ──── + ─ + ───── 4 2 4 In general, my approach is that I try to define the derivative of abs(x) in the simplest possible way, which seems to be in terms of abs(x) as well, instead of sqrt(x*conjugate(x)). But the CAS needs to be able to rewrite it later if needed, because sometimes things can simplify. Ondrej > > Bill. > > On 20 November 2014 09:41, Bill Page <bill.p...@newsynthesis.org> wrote: >> ... >> >> I had a thought. I suppose that all non-analytic (nonholomorphic) >> functions of interest can be written in terms of conjugate and some analytic >> functions, e.g. >> >> abs(x)=sqrt(x*conjugate(x)) >> >> so perhaps all we really need is to know how to differentiate conjugate >> properly? >> >> Bill > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.