On Tuesday, April 15, 2014 10:36:20 PM UTC-7, John H Palmieri wrote:
>
>
>
> On Tuesday, April 15, 2014 9:58:51 PM UTC-7, jorges wrote:
>>
>> On Wednesday, 16 April 2014 01:24:25 UTC-3, John H Palmieri wrote:
>>>
>>> I'm guessing that the issue is that your integrand simplifies when q=1 
>>> -- at least one term becomes zero -- but you do the integral before doing 
>>> this simplification. Maybe the symbolic integration is not valid when q=1. 
>>> If you plug in the parameters before integrating, you get something very 
>>> different from Sage. Adding these two lines
>>>
>>> qs=integral(((TVcoff(t))^2/moff).subs(**params),t, d*pi/omega, 
>>> 2*pi/omega) # substitute before integrating
>>> Nqs = qs.subs(**params).n()
>>>
>>> gives me something close to Maple's answer:
>>>
>>> sage: Nps
>>> 1057.74513808638 + 3.42074504083530*I
>>> sage: Nqs
>>> 0.0164729319512844 + 5.58793544769287e-9*I
>>>
>>> Indeed, that looks good. I still don't understand what you mean by "the 
>> symbolic integration is not valid when q=1". I would think substituting 
>> before or after should not make a difference. 
>>
>
> It's possible, for example, that when doing the integration, it divides by 
> q-1 to "simplify" some algebra. Maybe it does something else which turns 
> out not to be valid when q=1. This is all just a guess, anyway.
>
>   John
>
>
> Also, I remember that I attempted to simplify before integrating before, 
>> mainly to speed up calculations, but had some bad experience with real 
>> numbers and maxima. I can't recall the precise details right now, but after 
>> that I "learned" to defer substitution to the very end. That is until now. 
>> I love SAGE, but these things, i.e. having to know special cases and how to 
>> handle them, make using it much more difficult, especially for a non-power 
>> user as me.
>> Thanks for pointing out how to avoid this issue.
>>
>> Jorge
>>
>
By the way, you can also do

    numerical_integral(((TVcoff(t))^2/moff).subs(**params).real(), pi, 2*pi)
    numerical_integral(((TVcoff(t))^2/moff).subs(**params).imag(), pi, 2*pi)

This function seems to require a real function, so I've put in .real() and 
.imag() to break it into pieces.

-- 
John

 

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to