Wed 2017-01-25 11:56:54 UTC+1, João Alberto Ferreira:
> Hi!
>
> Does any one knows a function or a way to return
> the argument of a sinusoidal function? I have the
> following code and wanted to operate on the argument
> of the cosinus function.
>
> # upchirp carrier
> var('t, phi_0, omega_0, omega_1, T')
> k = (omega_1 - omega_0)/T; k
> # linear chirp signal (waveform)
> s1 = cos(phi_0 + k*t^2/2 + omega_0*t); s1
> arg(s1)
> omega = derivative(arg(s1), t); omega
>
> Sagemath returns:
>
> (t, phi_0, omega_0, omega_1, T)
> -(omega_0 - omega_1)/T
> cos(omega_0*t - 1/2*(omega_0 - omega_1)*t^2/T + phi_0)
> arg(cos(omega_0*t - 1/2*(omega_0 - omega_1)*t^2/T + phi_0))
> -(omega_0 - (omega_0 - omega_1)*t/T)*sin(omega_0*t - 1/2*(omega_0 -
omega_1)*t^2/T + phi_0)*D[0](arg)(cos(omega_0*t - 1/2*(omega_0 -
omega_1)*t^2/T + phi_0))
>
> Cordially,
> Joao
Hi Joao,
In Sage, `arg` is for the complex argument, ie if `z = r*exp(i*t)`,
with `r > 0` and `-pi < t <= pi`, then `arg(z)` is `t`.
What you want is to think about the expression `cos(blah)` as an expression
tree,
in this case it has an operator (cos) and a list of operands (with just one
element,
which is blah, and blah is itself an expression).
$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.5.1, Release Date: 2017-01-15 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: t, phi_0, omega_0, omega_1, T = SR.var('t, phi_0, omega_0, omega_1,
T')
sage: k = (omega_1 - omega_0)/T
sage: s1 = cos(phi_0 + k*t^2/2 + omega_0*t)
sage: s1.operator()
cos
sage: s1.operands()
[omega_0*t - 1/2*(omega_0 - omega_1)*t^2/T + phi_0]
sage: s1.operands()[0]
omega_0*t - 1/2*(omega_0 - omega_1)*t^2/T + phi_0
--
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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.