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.Sat, 19 Dec 2015 15:50:36 +0100Best way to represent a pointhttps://ask.sagemath.org/question/31699/best-way-to-represent-a-point/ Hello,
I have a point p1(x1, y1) and a point p2(x2, y2).
For example I want p1 = 2 * p2
For the moment I store the points in lists so I have to do like:
p1[0] = 2 * p2[0]
p1[1] = 2 * p2[1]
It's very ugly.
What's the best way to do that ?
Thanks in advanceNeabfiSat, 19 Dec 2015 15:50:36 +0100https://ask.sagemath.org/question/31699/Why is sage giving me wrong answers?https://ask.sagemath.org/question/26490/why-is-sage-giving-me-wrong-answers/ Let's say I want to multiply $(\frac{-1 - i \sqrt{3}}{2})(\frac{-1 + i \sqrt{3}}{2})$. Doing it by hand, we easily see that the answer is 1.
However, when I type
n(((-1 + sqrt(-3))/2)*((-1-sqrt(-3))/2))
in sage, I get
1 - 5.55111512312578 x 10^(-17)i
which is (of course) very close to 1...but its not exactly 1. Why is that? How do I fix this??ArtusSat, 11 Apr 2015 00:39:58 +0200https://ask.sagemath.org/question/26490/collect multiple variables and simplify their coefficientshttps://ask.sagemath.org/question/8369/collect-multiple-variables-and-simplify-their-coefficients/Hi there!
In Mathematica you can do the following: Collect[expr, {var1, var2, var3}, Simplify]
This transforms
expr = var1*expr11 + var2*expr22 + var1*var2*expr12 + ...
to
var1*Simplify[expr11] + var2*Simplify[expr22] + var1*var2*Simplify[expr12] + ...
I was wondering if there is an easy way to do this in Sage.
So my questions are:
1) How can you collect multiple variables?
2) How can you manipulate their coefficients? (each coefficient is independent)
3*) How can you print the result in a pretty way? (e.g. collecting the expression by coefficients and printing each term in a new line)
Thanks for your help!
nablaoperatorSun, 09 Oct 2011 16:50:44 +0200https://ask.sagemath.org/question/8369/How to multiply vector by numberhttps://ask.sagemath.org/question/8539/how-to-multiply-vector-by-number/I have vector
W = [1, 8, 4, 7, 10, 1, 6, 3]
I need to multiply it by number, but command 2*W gives just concatenated vector by itself
[1, 8, 4, 7, 10, 1, 6, 3, 1, 8, 4, 7, 10, 1, 6, 3]
I dont need it, I need multiply all elements of vector to numberkoteWed, 14 Dec 2011 03:25:23 +0100https://ask.sagemath.org/question/8539/