ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 06 Jun 2022 14:54:02 +0200calling multivariate Taylor with arbitrary number of variableshttps://ask.sagemath.org/question/62755/calling-multivariate-taylor-with-arbitrary-number-of-variables/If we have, say, variables x and y, then we can use
f = x^2*y^3 - x - y
f.taylor((x,0), (y,1), 3)
If we want to deal with an arbitrary number of variables, we should presumably write code to first create a tuple of the right form (I omit that here since it is easy), and then pass it to taylor, but I can't get it to work. The following fails ("wrong arguments passed to taylor"). Presumably I don't know how to call a function with a tuple of arguments in the right way.
a = (x,0), (y, 1), 3
f.taylor(a)MCWMon, 06 Jun 2022 14:54:02 +0200https://ask.sagemath.org/question/62755/listing all those pairs of tuples which are permutations of each otherhttps://ask.sagemath.org/question/62464/listing-all-those-pairs-of-tuples-which-are-permutations-of-each-other/Suppose I have a list of tuples like
import itertools
l=range(0,6)
m=itertools.combinations(l,2)
list(m)
How do I get those pairs of tuples `(i,j);(x,y)` such that `(i,j)=(y,x)`? Also, is there a way to generalize this, that is, I would to have pairs of tuples `(a,b,c,...);(x,y,z...)` such that `(a,b,c...)=(z,y,x...)`. Is there any efficent way of doing this? Thanks beforehand.vidyarthiMon, 16 May 2022 14:30:00 +0200https://ask.sagemath.org/question/62464/TypeError: 'tuple' object is not callable on notebook but not on terminalhttps://ask.sagemath.org/question/55874/typeerror-tuple-object-is-not-callable-on-notebook-but-not-on-terminal/Code :
x=var('x')
y=function('y')(x)
k= var('k')
assume(k>0)
harmonic2 = diff(y,x,2)+k*y == 0
desolve(harmonic2, y, ivar = x)
Error :
TypeError Traceback (most recent call last) <ipython-input-54-ef4195c42a80> in <module>
4 assume(k>Integer(0))
5 harmonic2 = diff(y,x,Integer(2))+k*y == Integer(0)
----> 6 desolve(harmonic2, y, ivar = x)
TypeError: 'tuple' object is not callable
Why does this happen when i tried it in notebook but when i tried it in notepad but it ran fine on the terminalmath1styearstudentWed, 24 Feb 2021 12:41:31 +0100https://ask.sagemath.org/question/55874/Get TypeError: 'tuple' object is not callablehttps://ask.sagemath.org/question/39844/get-typeerror-tuple-object-is-not-callable/Just downloaded sage-8.0-Debian_GNU_Linux_8-x86_64.tar.bz2.
Seems to be working well.
Great work as always!
Trying to solve simultaneous equations.
Get error "TypeError: 'tuple' object is not callable."
Found exactly the examples I needed in Basic Algebra and Calculus. Solving Equations (online Sage reference).
Copied and pasted Jason Grout's example and also the examples above it.
Get error message "TypeError: 'tuple' object is not callable." in notebook() , but examples work in terminal.
Here is one of the examples that gives the error in notebook() (but works in terminal).
sage: x, b, c = var('x b c')
sage: solve([x^2 + b*x + c == 0],x)
What am I missing here?
Any ideas?
Thanks.
bbtpThu, 30 Nov 2017 11:26:36 +0100https://ask.sagemath.org/question/39844/Iterating over list of tupleshttps://ask.sagemath.org/question/36727/iterating-over-list-of-tuples/I am attempting to index into the y-coordinates of each tuple to count how many tuples have a y-coordinate of 0, 1, or 2 but am receiving an error message which looks like this:
Error in lines 1-1
Traceback (most recent call last):
File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 982, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
TypeError: 'sage.rings.integer.Integer' object is not iterable
My code is below:
zero_count, one_count, two_count = 0
for i in range(len([list])):
if list[i][1] == 0:
zero_count += 1
elif list[i][1] == 1:
one_count += 1
else:
two_count += 1collegesistaSat, 25 Feb 2017 01:29:42 +0100https://ask.sagemath.org/question/36727/how to convert a sage 1-row matrix into tuple ?https://ask.sagemath.org/question/34007/how-to-convert-a-sage-1-row-matrix-into-tuple/> import numpy as np
> a=random_matrix(ZZ,1,5)
>
> tuple(np.array(a).tolist()[0])
is there something more native ?
motivation: sagematrix,it seems, are not "hashable" and cannot be used as keys in lists to do groupby/countbyfaguiMon, 04 Jul 2016 06:41:39 +0200https://ask.sagemath.org/question/34007/'list indices must be integers, not tuple' error in newbie scripthttps://ask.sagemath.org/question/10196/list-indices-must-be-integers-not-tuple-error-in-newbie-script/Hi expers!!
Im a new user of SAGE. Right now im writing a script that plot 'N' random lines of lenght=1 in a rectangle of b*h center in axes. The code is shhow below:
N=float(raw_input('Número de rectas aleatóreos (N)?:\n'))
b=float(raw_input('Base del rectángulo (b>1)?:\n'))
h=float(raw_input('Altura del cuadrado (h>1)?:\n'))
uniforme_x=RealDistribution('uniform',[-b/2,b/2])
uniforme_y=RealDistribution('uniform',[-h/2,h/2])
lista_x=[uniforme_x.get_random_element() for j in srange(N)]
lista_y=[uniforme_y.get_random_element() for j in srange(N)]
lista_xy = zip(lista_x , lista_y)
lineas=[]
d2=1*1*2
for j in lista_xy:
x1 = lista_xy[j][0]
y1 = lista_xy[j][1]
while d2>1*1:
x2 = uniforme_x.get_random_element()
y2 = uniforme_x.get_random_element()
d2=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)
lineas.append(line([lista_xy[j],(x2,y2)]))
grafico=sum(lineas)
grafico.show()
When i execute this code I get the error messege
'list indices must be integers, not tuple'.
Whats the problem?
Waiting for your answers.
Thanks a lot!
mresimulatorWed, 05 Jun 2013 22:41:32 +0200https://ask.sagemath.org/question/10196/