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.Mon, 02 Sep 2019 12:07:52 -0500how do I enter 2sin|1−3√2|cos|1+ 2√3|http://ask.sagemath.org/question/47722/how-do-i-enter-2sin1-32cos1-23/when I enter it in SageMath as `2 * sin * abs(1-3 * sqrt(2))*cos*abs(1+2 * sqrt(3))` it does not run the code? your help would be very appreciated :)ariaaaaaaaaMon, 02 Sep 2019 10:44:08 -0500http://ask.sagemath.org/question/47722/error for (3*e+2*I)*(-3+pi*I)http://ask.sagemath.org/question/47729/error-for-3e2i-3pii/so, I have to type in the problem (3e+2i)(−3+πi)...I enter in `(3*e+2*I)*(-3+pi*I)` on SageMath but come up with the answer, -30.74772176 + 19.61920267*I....am I dumb or is the correct answer?ariaaaaaaaaMon, 02 Sep 2019 12:07:52 -0500http://ask.sagemath.org/question/47729/how do I enter (3e+2i)(−3+πi)?http://ask.sagemath.org/question/47715/how-do-i-enter-3e2i-3pi/every time I enter I to represent i, it comes as an invalid syntax? pls help :)ariaaaaaaaaSun, 01 Sep 2019 17:10:09 -0500http://ask.sagemath.org/question/47715/how do I enter (3e+2i)(−3+πi)?http://ask.sagemath.org/question/47714/how-do-i-enter-3e2i-3pi/ every time I enter i as I it comes up as an invalid syntax? Pls help ariaaaaaaaaSun, 01 Sep 2019 17:09:14 -0500http://ask.sagemath.org/question/47714/Computing a formula in SAGEhttp://ask.sagemath.org/question/47509/computing-a-formula-in-sage/Fix the positive integer numbers $t_1, t_2, t_3,t_4, t_5.$ We have the following formula:
$$ S= \sum_{i, j, h, m, k_1 + k_2+k_3+k_4 = i-t_1, \ell_1+\ell_2 + \ell_3 = j -t_2 + k_4, u_1 + u_2 = h - t_3+k_3+\ell_3 }M_1.M_2.M_3. M_4,$$
where
$$ M_1 = \binom{t_5-k_1}{k_1}\binom{t_4-k_2}{k_2}\binom{t_3-k_3}{k_3}\binom{t_2-k_4}{k_4}$$
$$ M_2 = \binom{t_5-k_1-\ell_1}{\ell_1}\binom{t_4-k_2-\ell_2}{\ell_2}\binom{t_3-k_3-\ell_3}{\ell_3}$$
$$ M_3 = \binom{t_5-k_1-\ell_1-u_1}{u_1}\binom{t_4-k_2-\ell_2-u_2}{u_2};$$
$$ M_4=\binom{t_1+t_2+t_3+t_4 +t_5-i - j-h-m}{m - t_4 + k_2+ \ell_2 + u_2}.\lambda_i\lambda_j\lambda_h\lambda_m\lambda_{t_1+t_2 + t_3+t_4+t_5 - i - j-h-m}$$
Here, the binomial factors $\binom{n}{k}$ mod 2 and the value of $S$ mod 2. By convention, $\binom{n}{k} \equiv 0$ (mod 2) if either $k < 0$ or $n < 0$ or $k > n.$
I don't how to construct this formula in SAGE. Can someone show me how to compute it using SAGE?VochauMon, 19 Aug 2019 08:27:56 -0500http://ask.sagemath.org/question/47509/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/2D Points, best paractive to store Pointshttp://ask.sagemath.org/question/45444/2d-points-best-paractive-to-store-points/
sage: from sage.plot.point import Point
sage: P = Point([1,2],[2,3],{'alpha':.5})
sage: P
Point set defined by 2 point(s)
sage: P.options()['alpha']
0.500000000000000
sage: P.xdata
[1, 2]
Why is this not working:
sage: P = Point([1,2],[2,3])
Why do I need this alpha Parameter?
thethaWed, 13 Feb 2019 04:33:40 -0600http://ask.sagemath.org/question/45444/Importing Sage functions into Cython?http://ask.sagemath.org/question/42277/importing-sage-functions-into-cython/ I am trying to define variables in Cython part of my code like this
a,b,c = var('a,b,c')
But in this line I cant import var() function from Sage
from sage.calculus.var import var
I got this error:
$ sage -python real_sage.sage
Compiling ./real_sage.spyx...
Traceback (most recent call last):
File "real_sage.sage", line 6, in <module>
from real_sage import foo
File "real_sage.pyx", line 10, in init real_sage
File "sage/calculus/var.pyx", line 6, in init sage.calculus.var
File "/home/tunamustafakemal/sega/SageMath/local/lib/python2.7/site-packages/sage/symbolic/function_factory.py", line 15, in <module>
from sage.symbolic.function import SymbolicFunction, sfunctions_funcs, \
File "sage/rings/integer.pxd", line 7, in init sage.symbolic.function
File "sage/rings/rational.pxd", line 8, in init sage.rings.integer
File "sage/rings/rational.pyx", line 89, in init sage.rings.rational
File "sage/rings/real_mpfr.pyx", line 1, in init sage.rings.real_mpfr
File "sage/rings/complex_number.pxd", line 6, in init sage.libs.mpmath.utils
File "sage/rings/complex_double.pxd", line 10, in init sage.rings.complex_number
File "sage/rings/complex_double.pyx", line 94, in init sage.rings.complex_double
ImportError: cannot import name complex_number
Thanks for any support.tunaSun, 06 May 2018 23:14:53 -0500http://ask.sagemath.org/question/42277/Is matrix calculus possible within sagemath?http://ask.sagemath.org/question/32414/is-matrix-calculus-possible-within-sagemath/For example, is it possible to compute the following partial derivative in Sagemath:
$$
A_{ij} = \frac{\partial e_{ij}(x)}{\partial x_i} = \begin{pmatrix}
-R_{ij}^T R_i^T & R_{ij}^T \frac{\partial R_i^T}{\partial \theta_i} (t_j - t_i) \\\
0^T & -1
\end{pmatrix}
$$
for
$$
e_{ij}(x) = \begin{pmatrix}
R_{ij}^T (R_i^T (t_j - t_i) - t_{ij}) \\\
\theta_j - \theta_i - \theta_{ij}
\end{pmatrix}
$$
and
$$
x_i^T = (t_i^T, \theta_i)
$$
$$
z_{ij}^T = (t_{ij}^T, \theta_{ij})
$$
The background shouldn't be important, but just for completeness: this example is an excerpt from Robotics, especially the problem of Pose Graph Simultaneous Mapping and Localization. $x_i$ defines a pose in $\mathbb{R}^2$ with translation $t_i$ and rotation angle $\theta_i$, $z_{ij}$ defines a transform between two poses and $e_{ij}(x)$ defines the error between two poses, i.e. a transform between them.
morphTue, 02 Feb 2016 03:20:41 -0600http://ask.sagemath.org/question/32414/help on using chain rule in Sagehttp://ask.sagemath.org/question/36673/help-on-using-chain-rule-in-sage/Does anyone have any tips for using Sage to take derivatives of functions of many variables?
For example, if I define
```w(x,y) = x^2 + y^2``` (say)
and then if I suppose that ```x``` and ```y``` depend on an independent variable ```t```, the chain rule applies for finding ```w.diff(t)```. The only way I found to do this in Sage is
```var('t')```
```x(t) = cos(t)``` (say)
```y(t) = sin(t)```
```w(x,y) = x^2 + y^2```
```w.diff(t)```
But this isn't really using the chain rule. If I instead try
```var('x,y')```
```(define w again)```
```(define x and y again)```
```w.diff(t)```
```Out: (x,y) |--> 0```
Apparently it thinks the derivative is zero because it still thinks ```x``` and ```y``` are two independent variables where they appear in ```w```, even though you get
```x```
```Out: t |--> cos(t)```
and similarly for ```y```. Any suggestions? Thanks.
lefthandstanderMon, 20 Feb 2017 01:25:01 -0600http://ask.sagemath.org/question/36673/Code error in sagemathhttp://ask.sagemath.org/question/36579/code-error-in-sagemath/ My code in sagemath
def bruteforce
count = 0
s = [0, 1, 2, 4, 8]
s.each do |a|
s.each do |b|
s.each do |c|
s.each do |d|
s.each do |e|
if a+b+c+d+e == 8
count += 1
puts "#{count}.: #{a}+#{b}+#{c}+#{d}+#{e}"
end
end
end
end
end
end
count
end
but it was an error as below
File "<ipython-input-1-87370adfacc9>", line 1
def brutefor
SyntaxError: invalid syntaxdavisSat, 11 Feb 2017 20:08:47 -0600http://ask.sagemath.org/question/36579/Find all non-negative integer solutions of $a+b+c+d+e = 8$ in Sagemathhttp://ask.sagemath.org/question/36564/find-all-non-negative-integer-solutions-of-abcde-8-in-sagemath/Find all non-negative integer a, b, c,d, e such that
$$a+b+c+d+e = 8$$
Is there any method for this? I have no idea. I can just fix the limit.davisSat, 11 Feb 2017 03:30:54 -0600http://ask.sagemath.org/question/36564/solution to homogeneous system of linear equations with coefficients over field $\mathbb{F}_2$http://ask.sagemath.org/question/36580/solution-to-homogeneous-system-of-linear-equations-with-coefficients-over-field-mathbbf_2/Solve the following homogeneous systems of linear equations with coefficients over field $\mathbb{F}_2$:
x1+x2+x3+x4+x5+x6+x7 = 0
x1=0
x2+x3+x4 =0
x5=0
I want to output on the sage following:
x1=x5=0
x6=x7
x2+x3+x4=0
I want to solve a general homogeneous systems with coefficients over field $\mathbb{F}_2$ and output same as above.
I hope that someone can help. Thanks!davisSat, 11 Feb 2017 20:31:11 -0600http://ask.sagemath.org/question/36580/Construction of formula in Sagemath programhttp://ask.sagemath.org/question/36533/construction-of-formula-in-sagemath-program/Let $P_k:= \mathbb{F}_2[x_1,x_2,\ldots ,x_k]$ be the polynomial algebra in $k$ variables with the degree of each $x_i$ being $1,$ regarded as a module over the mod-$2$ Steenrod algebra $\mathcal{A}.$ Here $\mathcal{A} = \langle Sq^{2^m}\,\,|\,\,m\geq 0\rangle.$
Being the cohomology of a space, $P_k$ is a module over the mod-2 Steenrod algebra $\mathscr{A}.$ The action of $\mathscr{A}$ on $P_k$ is explicitly given by the formula
$$Sq^m(x_j^d) = \binom{d}{m}x_j^{m+d},$$
where $ \binom{d}{m}$ is reduced mod-2 and $\binom{d}{m} = 0$ if $m > d.$
Now, I want to use the Steenrod algebra package and Multi Polynomial ring package and using formular above to construction of formula following in Sagemath program
$$
Sq^m(f) = \sum\limits_{2^{m_1} + 2^{m_2} + \cdots + 2^{m_k}= m}\binom{d_1}{2^{m_1}}x_1^{2^{m_1}+d_1}\binom{d_1}{2^{m_2}}x_2^{2^{m_2}+d_2}\ldots \binom{d_k}{2^{m_k}}x_k^{2^{m_k}+d_k}.$$
forall $f = x_1^{d_1}x_2^{d_2}\ldots x_k^{d_k}\in P_k$
Example: Let $k = 5, m = 2$ and $f = x_1^2x_2^3x_3^2x_4x_5\in P_5.$ We have
$$
Sq^2(x_1^2x_2^3x_3^2x_4x_5) = x_1^4x_2^3x_3^2x_4x_5 + x_1^2x_2^5x_3^2x_4x_5 + x_1^2x_2^3x_3^4x_4x_5
+x_1^2x_2^3x_3^2x_4^2x_5^2 + x_1^2x_2^4x_3^2x_4x_5^2 + x_1^2x_2^4x_3^2x_4^2x_5^1.$$
I hope that someone can help. Thanks!davisFri, 10 Feb 2017 00:29:40 -0600http://ask.sagemath.org/question/36533/Integration and differentiation symbolshttp://ask.sagemath.org/question/36441/integration-and-differentiation-symbols/I have seen this in the examples but it doesn't appear to be very easy unless I am totally missing something. It is important that the proper symbology be used in presentation form to show the integration symbol and or differentiation symbol. But can't seem to find any way of doing it . This should be straight forward like show(integral()) and it puts the integral symbol on the screen especially in showing symbolic calculations.
How do you get the symbols on the screen? NT4MAXIMUSDThu, 02 Feb 2017 07:15:53 -0600http://ask.sagemath.org/question/36441/Coordinate Transformshttp://ask.sagemath.org/question/9966/coordinate-transforms/Is there something in sage that does the same thing that `CoordinateTransform` and `TransformedField` in Mathematica 9 ?
The idea is that `CoordinateTransform` is given some coordinates, e.g. (r,th) and asked to transform them from "polar" to "cartesian", thus gives the expression of the cartesian coordinates in terms of the polar coordinates, e.g.
(x(r,th), y(r,th)) = (r*cos(th), r*sin(th))
Obvioulsly, it also works with other coordinates systems.
`TransformedField` makes the transformation between a scalar, vector, or tensor field in, say, cartesian coordinates, to spherical coordinates.
These actions are not very complicated, nor difficult to implement when needed, but they are also very common.
Thanks.
references :
* http://reference.wolfram.com/mathematica/ref/CoordinateTransform.html
* http://reference.wolfram.com/mathematica/ref/TransformedField.htmlConvenient TruthSun, 31 Mar 2013 13:04:28 -0500http://ask.sagemath.org/question/9966/A simple problem related to symbolic calculationhttp://ask.sagemath.org/question/26982/a-simple-problem-related-to-symbolic-calculation/Could anyone let me know how you can define a variable as some function of another variable without specific definition? For example, how can you define theta as some function of x and then differentiate the 'sin(theta)' by x?
The following is my code that doesn't work. I couldn't find how to fix it in reference manuals. Any help will be appreciated.
var('theta, y, f')
y=sin(theta) ; theta=f(x);
y.derivative(x)Nownuri1Sat, 30 May 2015 07:15:05 -0500http://ask.sagemath.org/question/26982/A symbolic convolution of arbitrary functionshttp://ask.sagemath.org/question/8507/a-symbolic-convolution-of-arbitrary-functions/In [this manual](http://www.sagemath.org/doc/constructions/calculus.html#convolution) it is described how to get a symbolic result of "the convolution of any piecewise defined function with another". However, when I try this with functions like exponent, this does not work:
x = PolynomialRing(QQ, 'x').gen()
f = Piecewise([[(0,1),exp(x)]])
f.convolution(f)
I get an error "RuntimeError: Symbolic Ring still using old coercion framework"
If I use a 'RR' ring instead of 'QQ', Piecewise() returns another error "TypeError: cannot coerce arguments: __call__() takes exactly 1 positional argument (0 given)"
I have 2 questions:
1. Is there a way to get a function, which represent convolution of a gaussian function and a decaying exponent (and, generally, any functions)? I want to fit my data with such a function.
2. How to get a symbolical convolution of functions with parameters (they should be assumed to be constants during convolution computation)?ADuC812Wed, 23 Nov 2011 17:01:36 -0600http://ask.sagemath.org/question/8507/cannot calculate limithttp://ask.sagemath.org/question/25647/cannot-calculate-limit/No answer from Sage-6.4.1 for this limit :
var('n');
u = (1+sqrt(n))^(-n);
limit(u(n=n+1)/u,n=infinity)
Sage 4.7 gives 0 (correct). Why ?marguinFri, 30 Jan 2015 04:20:28 -0600http://ask.sagemath.org/question/25647/computing integralhttp://ask.sagemath.org/question/24395/computing-integral/ Hello, I would like to compute for example this double integral:
exp(i*x*cos(y))
0 < x < pi
0 < y < 2
Could you please advice how to do that?
Thank you very much for your answer.
MartinMartin MaxaSat, 04 Oct 2014 09:15:30 -0500http://ask.sagemath.org/question/24395/derivatives of variable orderhttp://ask.sagemath.org/question/24045/derivatives-of-variable-order/ Using `diff/derivative` it does not seem easily possible to specify derivatives of variable order, e.g., to define a function `P(m,n)` that applies the `diff` `m+n` times to a polynomial:
sage: x=var('x')
sage: P(m,n)=derivative((1-x^2)^n,x,m+n)
...
TypeError: argument symb must be a symbol
sage: R.<x> = PolynomialRing(QQ, 'x')
sage: p=(1-x^2)^11
sage: P(m,n)=derivative(p,x,m+n)
...
ValueError: Cannot differentiate with respect to m + n
This is obviously because `diff` supports such syntactic sugar like `diff(p,x,x,x)`. So how to differentiate to a variable order?
rwsMon, 08 Sep 2014 04:12:11 -0500http://ask.sagemath.org/question/24045/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/Sinc functionhttp://ask.sagemath.org/question/23761/sinc-function/I am trying to perform some calculus involving the function $f(x) = \sin(x)/x$ in Sage. This function has a removable sigularity at the origin. Is there a way that I can "modify" the function in Sage to set $f(0) = 1$ while preserving the ability to do things like symbolically differentiate it?ajdWed, 13 Aug 2014 12:57:09 -0500http://ask.sagemath.org/question/23761/how to get the Values from an expressionhttp://ask.sagemath.org/question/11013/how-to-get-the-values-from-an-expression/ #Sum of n-th roots of unity is zero.
n=10;
for i in range(1,n):
v=solve(x^i - 1,x);
sum_roots = 0;
m=i;
for j in range(0,i):
sum_roots += v[j]; # error here .. I want the values, not the expression
print ' sum of n-th roots of ' ;
print m;
print ' is ';
print sum_roots ;
How do i get the values from the list of expressions returned by solve?
I have another Question-: How can I see all the member functions of any type,say expression..I have tried putting ? sfter the command, but that does not give all the member functions.
srikanth sskSat, 08 Feb 2014 23:10:18 -0600http://ask.sagemath.org/question/11013/derivative of multivariate equation with nested sumhttp://ask.sagemath.org/question/10869/derivative-of-multivariate-equation-with-nested-sum/Hello,
I often have to deal with functions like the one below, take derivatives and
so on. I would really like to know if I could use a CAS like SAGE to do this tedious and error prone calculations but I couldn't find a similar kind of function in the docs and tutorials.
My questions are:
* how can I write this function in SAGE ?
for $x\in \mathbf{R}^p; v \in \mathbf{R}^{p \times k}$
$$y(x, v) := \sum^p_{i=1} \sum^p_{j>i} \sum_{f=1}^k v_{i,f} v_{j,f} x_i x_j =
\sum^p_{i=1} \sum^p_{j>i} \langle v_{:,i}, v_{;,j} \rangle x_i x_j$$
* calculate the partial derivatives $\frac{\partial y(x,v)}{\partial v_{i,j}}$ ?
* or the the derivative with respect to the column-vector $\frac{\partial y(x,v)}{\partial v_{:, i} }$ ?
Or is there a better way to work with this kind of function in SAGE? (the function above is only an example)
ThanksibayerMon, 30 Dec 2013 06:36:27 -0600http://ask.sagemath.org/question/10869/Can sage be used to solve the following kind of problem?http://ask.sagemath.org/question/10604/can-sage-be-used-to-solve-the-following-kind-of-problem/"Given that f(1) = 9, f'(1) = 5, g(9) = 6 and g'(9) = 4, what is the approximate value of g(f(1.05))?"SnapThu, 10 Oct 2013 12:02:53 -0500http://ask.sagemath.org/question/10604/Sage Calculus Tutorial -- continuity practice problemshttp://ask.sagemath.org/question/10572/sage-calculus-tutorial-continuity-practice-problems/Can anyone help me understand how to do some of the practice problems in the sage calculus tutorial? In particular, I'm stuck on problems 5 and on at the bottom of this page http://www.sagemath.org/calctut/continuity.html
For example, I am not sure how to define 'k'. As it stands, graphing the function in problem 5, sage does not know what to do with the variable 'k', because it is not defined. SnapFri, 27 Sep 2013 03:20:25 -0500http://ask.sagemath.org/question/10572/How to integrate in 2D, along the locus of a line.http://ask.sagemath.org/question/10348/how-to-integrate-in-2d-along-the-locus-of-a-line/If I have a 2D continuous and differentiable function (f(x,y)) and a general 2D line L (ax + by + c = 0), how do I evaluate the definite integral of f with respect to x and y along the line L between an arbitrary start and end point that both lie on the line?mmsood99Thu, 11 Jul 2013 12:56:46 -0500http://ask.sagemath.org/question/10348/Is it better practice to show SAGE code on a web use of SAGE?http://ask.sagemath.org/question/10305/is-it-better-practice-to-show-sage-code-on-a-web-use-of-sage/If you go to my page for The Sensible Calculus Book http://users.humboldt.edu/flashman/senscalca_x.html you will find how I've added SAGE to this page- with interacts for graphs, direction fields and Euler's Method for DE's as well as one of the mapping diagram interacts I am developing from the assistance of Jeff Denny, Jason Grout, and others at Sage Edu Days 5 . I would like feedback on this if you have suggestions- I have currently hidden the code from the users using the interact buttons. Is it better practice to show the Sage code?Martin FlashmanMon, 01 Jul 2013 06:27:00 -0500http://ask.sagemath.org/question/10305/Calculus graphing. Urgent help appreciated!http://ask.sagemath.org/question/10132/calculus-graphing-urgent-help-appreciated/A math student writes a proof of the derivative of a certain trigonometric function. The last line she writes before stating her conclusion is...
**d/d?(sin(?+?/2))=cos(?+?/2)**
These are the graphs of sin(?+?/2) and cos(?+?/2)
**sin(?+?/2)** = http://www.wolframalpha.com/input/?i=sin%28theta%2Bpi%2F2%29&lk=4
**cos(?+?/2)**= http://www.wolframalpha.com/input/?i=cos%28theta%2Bpi%2F2%29&lk=4&num=1
Hence, write the statement of her conclusion beginning with the word, "Therefore...".ArielaFri, 17 May 2013 21:41:43 -0500http://ask.sagemath.org/question/10132/