ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 16 May 2020 02:36:47 -0500Can I simplify a PDE with Sagemath?http://ask.sagemath.org/question/51422/can-i-simplify-a-pde-with-sagemath/I'm a beginner in Sagemath and I search for help with a calculation problem with some derivatives and basic operations.
I need to simplify a PDE that depends of a smooth function $f:U\subset\mathbb{C}\to\mathbb{C}$, something like,
$$Af^2+2fB+C=0\tag{1}$$
where $A$, $B$ and $C$ depends of $f$ and $\bar{f}$ and their complex derivatives, of order until 3.
Of course I can compute this by hand, but in my problem it will be a very long computation and I thought about to try Sagemath for this computation.
I would like to know if I can to define a symbolic complex function on Sagemath and to do basic operations as to compute derivatives in $z$ and $\bar{z}$. For example, if
$A=(f_{z\bar{z}}+|f_{z}|^2+f_zf_{\bar{z}})_z$
$B=((\bar{f}_{z\bar{z}})^2+|\bar{f}_{z}|^4+(\bar{f}_z\bar{f}_{\bar{z}})^2)_z$
$C=((f_{z\bar{z}})^3+|f_{z}|^6+(f_zf_{\bar{z}})^3)_z,$
Can I simplify equation $(1)$ using Sagemath?
Thank for your attention.
I appreciate any help.
----------
Notation:
The derivatives on $z$ and $\bar{z}$ are the [Wirtinger derivatives][1]. Then, given a smooth function $f:U\subset\mathbb{C}\to\mathbb{C}$, we have
$f_z = \frac{\partial f}{\partial z}, \bar{f}_z = \frac{\partial \bar{f}}{\partial z}, f_{\bar{z}} = \frac{\partial f}{\partial {\bar{z}}},\bar{f}_{\bar{z}} = \frac{\partial \bar{f}}{\partial {\bar{z}}}, |f_z|^2=f_z\bar{f}_{\bar{z}}, |\bar{f}_z|^2=\bar{f}_z f_{\bar{z}}, f_{z\bar{z}}=(f_z)_{\bar{z}}$ and $\bar{f}_{z\bar{z}}=(\bar{f}_z)_{\bar{z}}$.
[1]: https://en.wikipedia.org/wiki/Wirtinger_derivativesIrddoSat, 16 May 2020 02:36:47 -0500http://ask.sagemath.org/question/51422/Residue in complex analysishttp://ask.sagemath.org/question/49086/residue-in-complex-analysis/1. is there a way to compute the residue of a meromorphic function $f(z)$ at $z=z_0$ in sage?
2. if so, I'd like to nest such method to compute residue at a flag,
$$ \operatorname{Res}_F f(x_1,\ldots,x_n) := \operatorname{Res}_{x_1=x_1^*,\ldots,x_n=x_n^*}\cdots\operatorname{Res}_{x_2=x_2^*, x_1=x_1^*} \operatorname{Res}_{x_1=x_1^*} f(x_1,\ldots,x_n)$$
where starred values denote a numerical value (same as $z_0$ before) and the flag is
$$F =([x_1=x_1^*,\ldots,x_n=x_n^*] \supset \cdots \supset [x_2=x_2^*, x_1=x_1^*] \supset [x_1=x_1^*])$$
Notice the choice of order matters.
For example, let $f = \frac1{(1-x_1)(1-x_1 x_2)}$ and $F = ( [x_1=1] \subset [x_2=1, x_1=1])$. Then
$$ \operatorname{Res}_F f(x_1,x_2) = 1$$
3. if that works, I'd like to build a function that takes as input the point $(x_1,\ldots,x_n)^*$, for various values of $n$, builds $f$ in a certain way, and gives back the residue as a function of the input: is this achievable?n59rTThu, 19 Dec 2019 08:53:57 -0600http://ask.sagemath.org/question/49086/Calculating Cauchy Integrals in Sagehttp://ask.sagemath.org/question/47017/calculating-cauchy-integrals-in-sage/Hi!
I am relatively new to complex analysis and I am trying to write down the following integral in Sage Math:
$$
I(k) = \frac{1}{2i\pi}\oint\frac{(1-t^2)}{(1-t)^n}\frac{dt}{t^{k+1}}
$$
from a paper that can be found at:
http://magali.bardet.free.fr/Publis/ltx43BF.pdf
The contour is a unit circle around the origin with a radius less than 1.
whereby $$S(n) = \frac{(1-t^2)}{(1-t)^n} $$ is a formal power series. The Cauchy Integral will produce the k-th coefficient of $S(n)$. I tried doing the following:
<!-- language: python -->
def deg_reg_Cauchy(k, n, m):
R.<t> = PowerSeriesRing(CC, 't')
constant_term = 1/(2*I*pi)
s = (1-t**2)**m / (t**(k+1)*(1-t)**n)
s1 = constant_term * s.integral()
return s1
I realize this is probably ***very*** wrong and I used $0$ till $2\pi$ as simple placeholders until I find appropriate values. Does anyone have any tips on how to go about this, please? Below is the error message that is being outputted by Sage.
<!-- language: python -->
ArithmeticError: The integral of is not a Laurent series, since t^-1 has nonzero coefficient.
Thank you!JoaoDDuarteSat, 29 Jun 2019 12:01:11 -0500http://ask.sagemath.org/question/47017/Riemann map between two different domainshttp://ask.sagemath.org/question/44684/riemann-map-between-two-different-domains/Sage has the RiemannMap functions which allow you to plot the Riemann map from a circle to a domain. Is there a way to compose two of these to plot the Riemann map between two different arbitrary domains? ajdSun, 16 Dec 2018 11:54:53 -0600http://ask.sagemath.org/question/44684/How to visualise complex functions on a disk?http://ask.sagemath.org/question/39936/how-to-visualise-complex-functions-on-a-disk/Let $f$ be a function on the unit disk $\mathbb{D}$. I want to look at the images of $f(\mathbb{D})$?
How to do this?
How to see the contours of $|f(z)|$?
How to see the argument (if possible)?nebuckandazzerMon, 04 Dec 2017 03:08:48 -0600http://ask.sagemath.org/question/39936/solve linear system with non-constant coefficientsshttp://ask.sagemath.org/question/39023/solve-linear-system-with-non-constant-coefficientss/ I would like to solve a linear system of two differential equations with non-constant coefficients. Namely a system of the form
$$\begin{pmatrix}u_1 \\\ u_2\end{pmatrix}'=A\begin{pmatrix}u_1 \\\ u_2\end{pmatrix}$$
where $A=\begin{pmatrix}a &b\\\ c& d\end{pmatrix}$ and $a,b,c,d$ are given holomorphic functions.
I'm mainly interested in integrate such a system along pathspippoTue, 03 Oct 2017 05:12:22 -0500http://ask.sagemath.org/question/39023/Help with unstable codehttp://ask.sagemath.org/question/37907/help-with-unstable-code/ This basically continues from a previous post: [generation of certain matrices](https://ask.sagemath.org/question/37860/generation-of-certain-matrices/)
I'm trying to draw circles in the plane by using fractional linear transformations.
Here is my code:
K = NumberField(x^2 + 2, 's')
OK = K.ring_of_integers()
def FLT(M,z):
"""takes the fractional linear transformation/Mobius transformation of a z in CC"""
if z == 'infinity' and M[1,0] != 0:
return M[0,0]/M[1,0]
elif z == 'infinity' and M[1,0] == 0:
return 'infinity'
elif M[1,0] != 0 and z == -M[1,1]/M[1,0]:
return 'infinity'
else:
return (M[0,0]*z+M[0,1])/(M[1,0]*z + M[1,1])
Now generate circles based on 3 image points of a matrix M with entries in the ring OK via FLT:
var('a','b','r','x','y')
func_cir=(x-a)**2+(y-b)**2==r**2
circles = set()
j = 0
while j < 10:
M = random_matrix(OK,2,algorithm = 'unimodular')
if FLT(M,-1) != 'infinity' and FLT(M,0) != 'infinity' and FLT(M,1) != 'infinity':
pta=[FLT(M,-1)[0],FLT(M,-1)[1]]
ptb=[FLT(M,0)[0],FLT(M,0)[1]]
ptc=[FLT(M,1)[0],FLT(M,1)[1]]
eq1 = func_cir.subs(x==pta[0]).subs(y==pta[1])
eq2 = func_cir.subs(x==ptb[0]).subs(y==ptb[1])
eq3 = func_cir.subs(x==ptc[0]).subs(y==ptc[1])
sol = solve([eq1,eq2,eq3],a,b,r)
C = circle((sol[1][0].rhs(),sol[1][1].rhs()),sol[1][2].rhs())
circles.add(C)
j += 1
This second chunk of code throws the error "list index out of range" about 50% of the time. I thought that it may have been due to division by zero, but now I'm not so sure. I've also tried using a for loop with the exact same result.
Thank you very much for the help!
Daniel LSat, 10 Jun 2017 14:16:34 -0500http://ask.sagemath.org/question/37907/Complex analysis. Compute bar derivativehttp://ask.sagemath.org/question/26279/complex-analysis-compute-bar-derivative/ Can sage do complex analysis? I was unable to find documentation upon a quick web search.
For instance, I would like to define $f(z) = z \bar{z}$ and ask sage to compute $\displaystyle \frac{\partial f}{\partial \bar{z}}$, is that possible?
Of course I could treat $z$ and $\bar{z}$ as independent variables, but that is not what I'm asking.SeubSun, 22 Mar 2015 08:10:44 -0500http://ask.sagemath.org/question/26279/Why is diff(conjugate(x),x) unevaluated?http://ask.sagemath.org/question/24027/why-is-diffconjugatexx-unevaluated/Or, can we differentiate holomorphic functions only?
Wirtinger defined two derivations in complex analysis for which we have:
diff(x,conjugate(x)) = 0
and
diff(conjugate(x),x) = 0.
http://en.wikipedia.org/wiki/Wirtinger_derivatives
Wirtinger calculus has important applications in optimization and has been extended to quaternion functions.
Is there any situation in which leaving diff(conjugate(x),x) unevaluated is an advantage?Bill Page _ againTue, 02 Sep 2014 20:25:09 -0500http://ask.sagemath.org/question/24027/Limit of complex functionshttp://ask.sagemath.org/question/10714/limit-of-complex-functions/Hi,
Suppose I have 2 complex numbers, z and z1 , where z = 1+2*I and z1 = 3 + 4*I (just an example). How can I compute the following: some_function = z * z1 and I want to know how to find the limit of some_function when z = z1.
I tried hard to find an answer. I used def to define a function, I could define the complex numbers and I can use the limit with rational / real values, but, when I use a complex number, the limit just return the entire explession.
Thank you for any idea / URL to help me.Luiz Roberto MeierFri, 08 Nov 2013 09:03:01 -0600http://ask.sagemath.org/question/10714/complex rectangular to polarhttp://ask.sagemath.org/question/10614/complex-rectangular-to-polar/I'm new to Sage. How do I convert a complex number like 2+3i into its polar form symbolically to get it in the form r.e^i.theta?BJSSat, 26 Oct 2013 00:25:45 -0500http://ask.sagemath.org/question/10614/3d Complex function plothttp://ask.sagemath.org/question/9843/3d-complex-function-plot/I want to plot a complex function in 3d. And colour it according to the real or imaginary part as in these pictures.
[http://functions.wolfram.com/ElementaryFunctions/Sin/visualizations/5/](http://functions.wolfram.com/ElementaryFunctions/Sin/visualizations/5/)
I know that I can use the complex_plot command to get the 2d plots. But I want the 3d version of the plot like in the above link.
Is there a way to do it with sage ?koukourikosSat, 23 Feb 2013 23:29:57 -0600http://ask.sagemath.org/question/9843/Weird output for differential of a non-analytic complex function.http://ask.sagemath.org/question/8899/weird-output-for-differential-of-a-non-analytic-complex-function/The following code,
var('z')
f = z*z.conjugate()
f.derivative(z)
produces
z*D[0](conjugate)(z) + conjugate(z)
Now I undestand where the problem might be, $z$ and $z^*$ are usually treated as independent variables thus. But does sage mean by this output?d3banjanWed, 18 Apr 2012 02:38:46 -0500http://ask.sagemath.org/question/8899/how to obtain the real part of a complex functionhttp://ask.sagemath.org/question/8793/how-to-obtain-the-real-part-of-a-complex-function/html("<h1>Trajectory of a particle in a viscose medium under a linear oscilator</h1>")
html("<h1>in two cases:</h1>")
html("<h1>1) with an external force that annulates the viscosity</h1>")
html("<h1>2) with a given external force</h1>")
var('t s yes no')
@interact
def newtraph(m = input_box(default=1, label='mass'),
b = input_box(default=0.3, label='air viscosity'),
T = input_box(default=20, label='total time'),
K = input_box(default=[1,1,1], label='eigenvalues'),
V = input_box(default=yes, label='antiviscose force: yes or no'),
F = input_box(default=[0,0,0], label='another external force'),
CI= input_box(default=[1,1,1,1,1,-2], label='CI')):
RDF
assume(t>0)
N=matrix(3)
U=identity_matrix(3)
K=diagonal_matrix([K[0],K[1],K[2]])
A=block_matrix([[N,U],[-K/m, -b*U/m]])
CI=vector(CI)
S=exp(A*t)
Xh=S*CI
Ss=S(t=t-s)
if V==yes:
A0=block_matrix([[N,U],[-K/m, N]])
S0=exp(A0*t)
Xh0=S0*CI
u0=b*vector([Xh0[3],Xh0[4],Xh0[5]])
FA=parametric_plot3d((lambda t: real(u0[0](t=t).n()), lambda t: real(u0[1](t=t).n()), lambda t: real(u0[2](t=t).n())), (t,0,T),rgbcolor=(0,1,0),thickness=0.3,plot_points=[20*T])
C=parametric_plot3d((lambda t: real(Xh0[0](t=t).n()), lambda t: real(Xh0[1](t=t).n()), lambda t: real(Xh0[2](t=t).n())), (t,0,T),rgbcolor=(1,0,0),thickness=0.5,plot_points=[20*T])
show(FA+C)
else:
u=t^0*vector([0,0,0,F[0],F[1],F[2]])/m
u=u(t=s)
B=Ss*u
XP=integral(B,s,0,t)
X=Xh+XP
FC=parametric_plot3d((F[0],F[1],F[2]), (t,0,T),rgbcolor=(0,1,0),thickness=0.3,plot_points=[20*T])
C=parametric_plot3d((lambda t: real(X[0](t=t).n()), lambda t: real(X[1](t=t).n()), lambda t: real(X[2](t=t).n())), (t,0,T),rgbcolor=(1,0,0),thickness=0.5,plot_points=[20*T])
show(FC+C)canisvetusThu, 15 Mar 2012 23:53:02 -0500http://ask.sagemath.org/question/8793/Finding Re() and Im() for complex numbershttp://ask.sagemath.org/question/7490/finding-re-and-im-for-complex-numbers/Hey guys,
Is there a way to find the real and imaginary parts of a complex number in Sage? If so, how is it done?
Thanks.SirFibonacciSat, 18 Feb 2012 17:39:49 -0600http://ask.sagemath.org/question/7490/Complex forms and differentialshttp://ask.sagemath.org/question/8060/complex-forms-and-differentials/Can Sage handle complex differential forms and the \partial and \bar\partial operators? I tried naively defining the d-bar operator before as (in Latex) \bar d \bar u, but I got an error saying that conjugation wasn't defined for the differential form class. Is there a way of handling this other than defining the real and imaginary parts of all variables and brutally defining the \partial and \bar\partial operators?GunnarWed, 06 Apr 2011 07:34:59 -0500http://ask.sagemath.org/question/8060/Differentiating Complex Conjugated Functionshttp://ask.sagemath.org/question/7780/differentiating-complex-conjugated-functions/This is primarily a question of understanding the syntax of some output although there might be a bug hidden underneath. Consider the following code:
sage: var('x,t')
sage: q = function('q',x,t)
sage: f = q*q.conjugate()
sage: print f.derivative(x,1)
q(x, t)*D[0](conjugate)(q(x, t))*D[0](q)(x, t) + conjugate(q(x,t))*D[0](q)(x, t)
The answer is supposed to be $d/dx(q\bar{q}) = q_x \bar{q} + q \bar{q}_x$. The second term in the Sage output is correct but I'm having trouble deciphering the first term. Any thoughts?
I think I can narrow down the differences even further. Check it out:
sage: print q.conjugate().derivative(x,1)
D[0](conjugate)(q(x, t))*D[0](q)(x, t)
sage print q.derivative(x,1).conjugate()
conjugate(D[0](q)(x, t))
The independence of order isn't the issue: $q = u + iv$ means that $q_x = u_x + iv_x$, $\bar{q} = u - iv$. So $\bar{q_x} = u_x - iv_x$ and $(\bar{q})_x = (u - iv)_x = u_x - iv_x$.cswierczTue, 30 Nov 2010 09:18:04 -0600http://ask.sagemath.org/question/7780/How does sage deal with choosing branches? Examples?http://ask.sagemath.org/question/7710/how-does-sage-deal-with-choosing-branches-examples/[http://en.wikipedia.org/wiki/Principal\_branch][1]
[http://en.wikipedia.org/wiki/Exponentiation#Failure\_of\_power\_and\_logarithm\_identities][2]
[1]: http://en.wikipedia.org/wiki/Principal_branch
[2]: http://en.wikipedia.org/wiki/Exponentiation#Failure_of_power_and_logarithm_identitiesccanoncSat, 25 Sep 2010 08:34:50 -0500http://ask.sagemath.org/question/7710/