Re: [sage-support] Re: Symbolic Fourier transform in sagemath.

2021-05-28 Thread Hongyi Zhao


On Saturday, May 29, 2021 at 1:01:38 AM UTC+8 dim...@gmail.com wrote:

> On Fri, May 28, 2021 at 5:38 PM Hongyi Zhao  wrote: 
> > 
> > 
> > 
> > On Friday, May 28, 2021 at 8:19:07 PM UTC+8 Emmanuel Charpentier wrote: 
> >> 
> >> This can be computed “by hand” using (one of) the textbook 
> definition(s) : 
> >> 
> >> sage: var("omega, s") 
> >> (omega, s) 
> >> sage: integrate(sin(x^2)*e^(-I*s*x), x, -oo, oo) 
> >> 1/2*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/2*sqrt(2)*sqrt(pi)*sin(1/4*s^2) 
> >> 
> >> Both sympy and giac have implementations of this transform : 
> >> 
> >> sage: from sympy import fourier_transform, sympify 
> >> sage: fourier_transform(*map(sympify, (sin(x^2),x, s)))._sage_() 
> >> 1/2*sqrt(2)*sqrt(pi)*(cos(pi^2*s^2) - sin(pi^2*s^2)) 
> >> sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x^2), x, 
> s))).sage() 
> >> 1/2*sqrt(2)*sqrt(pi)*(cos(1/4*s^2) - sin(1/4*s^2)) 
> >> 
> >> which do not follow the same definitions… But beware : they may be more 
> or less wrong : 
> >> 
> >> sage: integrate(sin(x)*e^(-I*s*x), x, -oo, oo).factor() 
> >> undef # Wrong 
> >> sage: fourier_transform(*map(sympify, (sin(x),x, s)))._sage_() 
> >> 0 # Wrong AND misleading 
> >> sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x), x, s))).sage() 
> >> I*pi*dirac_delta(s + 1) - I*pi*dirac_delta(s - 1) # Better... 
> >> 
> >> BTW: 
> >> 
> >> sage: mathematica.FourierTransform(sin(x^2), x, s).sage().factor() 
> >> 1/2*cos(1/4*s^2) - 1/2*sin(1/4*s^2) 
> >> sage: mathematica.FourierTransform(sin(x), x, s).sage().factor() 
> >> -1/2*I*sqrt(2)*sqrt(pi)*(dirac_delta(s + 1) - dirac_delta(s - 1)) 
> > 
> > But what I got is different from yours: 
> > 
> > sage: var("omega, s") 
> > (omega, s) 
> > sage: mathematica.FourierTransform(sin(x), x, s).sage().factor() 
> > -I*(dirac_delta(s + 1) - dirac_delta(s - 1))*Sqrt(1/2*pi) 
>
> this depends of a version of Mathematica 
>

Is there a convenient way to prove they are the equivalent forms in sage?

HY

>
> > 
> > BTW: 
> > 
> > How to input the sage computation representation as the code style just 
> like what you've posted? 
> > 
> > HY 
> > 
> >> 
> >> HTH, 
> >> 
> >> Le dimanche 23 mai 2021 à 03:22:06 UTC+2, hongy...@gmail.com a écrit : 
> >>> 
> >>> It seems that all the Fourier transform methods implemented in 
> sagemath is numeric, instead of symbolic/analytic. 
> >>> 
> >>> I want to know whether there are some symbolic/analytic Fourier 
> transform functions, just as we can do in mathematica, in sagemath? 
> >>> 
> >>> I want to know if there are some symbolic/analytical Fourier transform 
> functions available in sagemath, just as the ones in mathematica? 
> >>> 
> >>> Regards, 
> >>> HY 
> >>> 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "sage-support" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to sage-support...@googlegroups.com. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/84095de0-8726-4194-a84f-f2f0c5c876c3n%40googlegroups.com.
>  
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/6ab4a610-d772-4a21-8b96-739e6fde6130n%40googlegroups.com.


Re: [sage-support] Re: Symbolic Fourier transform in sagemath.

2021-05-28 Thread Dima Pasechnik
On Fri, May 28, 2021 at 5:38 PM Hongyi Zhao  wrote:
>
>
>
> On Friday, May 28, 2021 at 8:19:07 PM UTC+8 Emmanuel Charpentier wrote:
>>
>> This can be computed “by hand” using (one of) the textbook definition(s) :
>>
>> sage: var("omega, s")
>> (omega, s)
>> sage: integrate(sin(x^2)*e^(-I*s*x), x, -oo, oo)
>> 1/2*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/2*sqrt(2)*sqrt(pi)*sin(1/4*s^2)
>>
>> Both sympy and giac have implementations of this transform :
>>
>> sage: from sympy import fourier_transform, sympify
>> sage: fourier_transform(*map(sympify, (sin(x^2),x, s)))._sage_()
>> 1/2*sqrt(2)*sqrt(pi)*(cos(pi^2*s^2) - sin(pi^2*s^2))
>> sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x^2), x, s))).sage()
>> 1/2*sqrt(2)*sqrt(pi)*(cos(1/4*s^2) - sin(1/4*s^2))
>>
>> which do not follow the same definitions… But beware : they may be more or 
>> less wrong :
>>
>> sage: integrate(sin(x)*e^(-I*s*x), x, -oo, oo).factor()
>> undef # Wrong
>> sage: fourier_transform(*map(sympify, (sin(x),x, s)))._sage_()
>> 0 # Wrong AND misleading
>> sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x), x, s))).sage()
>> I*pi*dirac_delta(s + 1) - I*pi*dirac_delta(s - 1) # Better...
>>
>> BTW:
>>
>> sage: mathematica.FourierTransform(sin(x^2), x, s).sage().factor()
>> 1/2*cos(1/4*s^2) - 1/2*sin(1/4*s^2)
>> sage: mathematica.FourierTransform(sin(x), x, s).sage().factor()
>> -1/2*I*sqrt(2)*sqrt(pi)*(dirac_delta(s + 1) - dirac_delta(s - 1))
>
> But what I got is different from yours:
>
> sage: sage: var("omega, s")
> (omega, s)
> sage: mathematica.FourierTransform(sin(x), x, s).sage().factor()
> -I*(dirac_delta(s + 1) - dirac_delta(s - 1))*Sqrt(1/2*pi)

this depends of a version of Mathematica

>
>  BTW:
>
> How to input the sage computation representation as the code style just like 
> what you've posted?
>
> HY
>
>>
>> HTH,
>>
>> Le dimanche 23 mai 2021 à 03:22:06 UTC+2, hongy...@gmail.com a écrit :
>>>
>>> It seems that all the Fourier transform methods implemented in sagemath is 
>>> numeric, instead of symbolic/analytic.
>>>
>>> I want to know whether there are some symbolic/analytic Fourier transform 
>>> functions, just as we can do in mathematica, in sagemath?
>>>
>>> I want to know if there are some symbolic/analytical Fourier transform 
>>> functions available in sagemath, just as the ones in mathematica?
>>>
>>> Regards,
>>> HY
>>>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/84095de0-8726-4194-a84f-f2f0c5c876c3n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq0nzxJ5jyV8d%3DPwPHEzEE-XP7NO7PbMyK_SthcEdKNf6g%40mail.gmail.com.


[sage-support] Re: Symbolic Fourier transform in sagemath.

2021-05-28 Thread Hongyi Zhao


On Friday, May 28, 2021 at 8:19:07 PM UTC+8 Emmanuel Charpentier wrote:

> This can be computed “by hand” using (one of) the textbook definition(s) :
>
> sage: var("omega, s")
> (omega, s)
> sage: integrate(sin(x^2)*e^(-I*s*x), x, -oo, oo)
> 1/2*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/2*sqrt(2)*sqrt(pi)*sin(1/4*s^2)
>
> Both sympy and giac have implementations of this transform :
>
> sage: from sympy import fourier_transform, sympify
> sage: fourier_transform(*map(sympify, (sin(x^2),x, s)))._sage_()
> 1/2*sqrt(2)*sqrt(pi)*(cos(pi^2*s^2) - sin(pi^2*s^2))
> sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x^2), x, s))).sage()
> 1/2*sqrt(2)*sqrt(pi)*(cos(1/4*s^2) - sin(1/4*s^2))
>
> which do not follow the same definitions… But beware : they may be more or 
> less wrong :
>
> sage: integrate(sin(x)*e^(-I*s*x), x, -oo, oo).factor()
> undef # Wrong
> sage: fourier_transform(*map(sympify, (sin(x),x, s)))._sage_()
> 0 # Wrong AND misleading
> sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x), x, s))).sage()
> I*pi*dirac_delta(s + 1) - I*pi*dirac_delta(s - 1) # Better...
>
> BTW:
>
> sage: mathematica.FourierTransform(sin(x^2), x, s).sage().factor()
> 1/2*cos(1/4*s^2) - 1/2*sin(1/4*s^2)
> sage: mathematica.FourierTransform(sin(x), x, s).sage().factor()
> -1/2*I*sqrt(2)*sqrt(pi)*(dirac_delta(s + 1) - dirac_delta(s - 1))
>
> But what I got is different from yours:

sage: sage: var("omega, 
s")
(omega, s)
sage: mathematica.FourierTransform(sin(x), x, 
s).sage().factor()   
-I*(dirac_delta(s + 1) - dirac_delta(s - 1))*Sqrt(1/2*pi)

 BTW:

How to input the sage computation representation as the code style just 
like what you've posted?

HY
 

> HTH,
> ​
> Le dimanche 23 mai 2021 à 03:22:06 UTC+2, hongy...@gmail.com a écrit :
>
>> It seems that all the Fourier transform methods implemented in sagemath 
>> is numeric, instead of symbolic/analytic.
>>
>> I want to know whether there are some symbolic/analytic Fourier transform 
>> functions, just as we can do in mathematica, in sagemath?
>>
>> I want to know if there are some symbolic/analytical Fourier transform 
>> functions available in sagemath, just as the ones in mathematica?
>>
>> Regards,
>> HY
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/84095de0-8726-4194-a84f-f2f0c5c876c3n%40googlegroups.com.


[sage-support] Re: memory leak in trivial calculation?

2021-05-28 Thread Emmanuel Charpentier


Nice one…

Indeed:

sage: f.expand()(y=i)
-(3735/1394*I + 405/1394)*z^3 - (606/697*I - 942/697)*z^2 - (8681/6970*I + 
15973/6970)*z + 1
sage: f.partial_fraction(y)(y=i)
-(3735/1394*I + 405/1394)*z^3 - (606/697*I - 942/697)*z^2 - (8681/6970*I + 
15973/6970)*z + 1
sage: f.simplify_full()(y=i)
-(3735/1394*I + 405/1394)*z^3 - (606/697*I - 942/697)*z^2 - (8681/6970*I + 
15973/6970)*z + 1

all work. But :

sage: f.simplify()(y=i)
``` doesn't return (I didn't wait for it to "eat all memory" and brutally 
interrupted it with a raft of C-c...).

A serious bug, IMHO (because it can crash Sage in a trivial calculation...).

For once, this isn't a `maxima` bug :

sage: maxima_calculus.interact()

→ Switching to Maxima_lib ←

maxima_lib: subst([y=%i], -(15*z/(17*y + 11) + 1)*(5*z/(4*y + 1) - 1)*(15
*z/(3*y - 4) + 1));
((15*z)/(3*%i-4)+1)*((5*z)/(4*%i+1)-1)*((-(15*z)/(17*%i+11))-1)
maxima_lib:
→ Exiting back to Sage ←
```

This is now Trac#31869 
​
Le jeudi 27 mai 2021 à 20:20:03 UTC+2, Peter Mueller a écrit :

> The following trivial code eats up all the memory and crashes with 
> an Unhandled SIGSEGV on my Linux machine and sage version 9.3. But it does 
> not work either on the sage cell!
>
> var('z y')
> f = -(15*z/(17*y + 11) + 1)*(5*z/(4*y + 1) - 1)*(15*z/(3*y - 4) + 1)
> f(y=I)
>
> -- Peter Mueller
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/2d33ba07-6db2-4d33-a7a7-539608a7d565n%40googlegroups.com.


[sage-support] Re: Symbolic Fourier transform in sagemath.

2021-05-28 Thread Emmanuel Charpentier


This can be computed “by hand” using (one of) the textbook definition(s) :

sage: var("omega, s")
(omega, s)
sage: integrate(sin(x^2)*e^(-I*s*x), x, -oo, oo)
1/2*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/2*sqrt(2)*sqrt(pi)*sin(1/4*s^2)

Both sympy and giac have implementations of this transform :

sage: from sympy import fourier_transform, sympify
sage: fourier_transform(*map(sympify, (sin(x^2),x, s)))._sage_()
1/2*sqrt(2)*sqrt(pi)*(cos(pi^2*s^2) - sin(pi^2*s^2))
sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x^2), x, s))).sage()
1/2*sqrt(2)*sqrt(pi)*(cos(1/4*s^2) - sin(1/4*s^2))

which do not follow the same definitions… But beware : they may be more or 
less wrong :

sage: integrate(sin(x)*e^(-I*s*x), x, -oo, oo).factor()
undef # Wrong
sage: fourier_transform(*map(sympify, (sin(x),x, s)))._sage_()
0 # Wrong AND misleading
sage: libgiac.fourier(*map(lambda u:u._giac_(), (sin(x), x, s))).sage()
I*pi*dirac_delta(s + 1) - I*pi*dirac_delta(s - 1) # Better...

BTW:

sage: mathematica.FourierTransform(sin(x^2), x, s).sage().factor()
1/2*cos(1/4*s^2) - 1/2*sin(1/4*s^2)
sage: mathematica.FourierTransform(sin(x), x, s).sage().factor()
-1/2*I*sqrt(2)*sqrt(pi)*(dirac_delta(s + 1) - dirac_delta(s - 1))

HTH,
​
Le dimanche 23 mai 2021 à 03:22:06 UTC+2, hongy...@gmail.com a écrit :

> It seems that all the Fourier transform methods implemented in sagemath is 
> numeric, instead of symbolic/analytic.
>
> I want to know whether there are some symbolic/analytic Fourier transform 
> functions, just as we can do in mathematica, in sagemath?
>
> I want to know if there are some symbolic/analytical Fourier transform 
> functions available in sagemath, just as the ones in mathematica?
>
> Regards,
> HY
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/2ae26d1a-b7b6-42a8-8ccd-8b2c4df3e291n%40googlegroups.com.