On Thu, Nov 20, 2014 at 9:16 AM, Ondřej Čertík <ondrej.cer...@gmail.com> wrote:
> 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.

Or to say it with different words, the reason we even have functions
like exp(x), csc(x), sinh(x), asin(x), asinh(x) is that things are
simpler if you use those as opposed to their more elementary function
definition. Perhaps with the exception of csc(x) = 1/sin(x), where I
personally don't see an advantage of introducing a new function for
just 1/sin(x). But with all the other ones, they simplify things,
sometimes. And so the art is to use those in  a way to create the most
simple expression at the end. I think that's all there is to it.

Ondrej

-- 
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.

Reply via email to