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, 03 Jun 2019 12:31:17 -0500Matrix projection blueshttp://ask.sagemath.org/question/46779/matrix-projection-blues/Hi
on OpenCourseware MIT site:
[Lecture 15: Projections onto subspaces](https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/video-lectures/lecture-15-projections-onto-subspaces/)
[edited :the code on sagecell sagemath org was not the good one ! it was the first version I wrote.
when I updated the code in the cell, that does not work, I had to open a new cell]
[code on sagecell sagemath org ](https://sagecell.sagemath.org/?z=eJytVMFuozAQvfsrRvQQHNykkKaHlXwAqYeVshKVcogURSsDDvGW2Ajclu7Xrw2UkKbpaW_DzLw38-Y5YSu6XZDlDgBuIFWqyoRkmtdQiFrDK0-1qoChxLbNA3K_-6YtQcWKLueBadmzNsObkslaKAlaQSbqsmDvUPHMwCQHIYcBpliZ0HQidAMHXnH4CSxTpQZ94GaifOXSlk1rjxG1iVNVvBwlHJmuRINC2gXu0xNhKzzTlZleqpq72OzU14LGxygadSbfdt5AXKk_3W7wqy0AgZQVhZGxsRrsgq8i4wpt5MuRhjAFNxwznighaAK0ybikrnvRNIUQ8CzjukPUZgar0IZa1rkFjTcLMKoP6s11DOgHOCQk4EDUhpENLaj9skGbsARtwgRtovvCKPeptcPdbm-L1ZTD3hpnhYUz666Ld2R7pbAjUPCcy-x3wRJe0ImxpDydy9JOhhbjlaroxNg_IaPYLBDQslDa7Yx1I9yXnbziXDrkTWT6QJfk06iPV3cxoYVZ3sUZbzjwJgVLnz94F1d4wwveFmZ42RooaN5o12EO-czet5G9kroWfzkN7jBKTpBkgAxC-43PITHdTKPxy_H_k-PEgbiNYgBzpPuzI8UjGS_GvCu37002P4H-WvEX1zJ4jMqT8nJQHuOpP7tbno8a1C-M-kca3cbn6vNltymrKnOGeJYqvt-LVJg_htrFJPqc6MlLIZ-v6ui3v3ylLQpjxE_r82H9RzwPvK-ldNPOjGxdy30vD7x84eX3Xr702NpL1l659via7EXe9roPBB4waY5C0tvhiWzvdibFGjrOeAvyPsqFeOvvPN_kLNTH_wDXithb&lang=sage&interacts=eJyLjgUAARUAuQ==)
Q1:
p is the b projected vector on vector a
below all letters are matrices
E=B-P with P=X*A
E=B-X*A as E perpendicular to A => dot product(A,E)) = 0 means A.transpose()*E=0
then A^T*(B-X*A)=0 so A^T*(X*A)=A^T*B (and this is false !)
but Gilbert Strang write X*A^T*A=A^T*B (and this is good !)
but we are not allowed to commute A^T*X*A by X*A^T*A if X is a matrix !
I know I made a mistake in my raisonning but I fail to find it !
Q2 : Why I must write X=A * (A.transpose())/(( (A.transpose()) * A ).det())
instead of X=A * (A.transpose())/(( (A.transpose()) * A ))
why I need to add .det() ?ortolljMon, 03 Jun 2019 12:31:17 -0500http://ask.sagemath.org/question/46779/Projection along affine hullhttp://ask.sagemath.org/question/35487/projection-along-affine-hull/Let `n_1,...,n_r` be integral points in a polyhedron `P`. The paper I am reading refers to "the projection of `P` along `aff(n_1,...,n_r)`". Here `aff(n_1,...,n_r)` is the affine hull of `n_1,...,n_r`. Can I accomplish this projection in sage?done_with_fishTue, 08 Nov 2016 13:09:57 -0600http://ask.sagemath.org/question/35487/plotting 3d polytope in R^4http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/ I'm trying to plot the following polytope on the cloud:
P=Polyhedron(vertices=[[0, 1, 0, 4] , [0, 1, 1, 3] , [3, 1, 1, 0] , [3, 1, 0, 1] , [0, 3, 0, 2] , [0, 3, 1, 1] , [1, 0, 0, 4] , [1, 0, 1, 3] , [3, 0, 1, 1] , [3, 0, 0, 2] , [1, 3, 1, 0] , [1, 3, 0, 1]])
P.plot()
This is a polytope living in R^4, but in fact the sum of the coordinates of each vertex is 5, so it is a 3D polytope. In some cases, sage gives me a nice 3D view of how the polytope looks like, but in this case it gives me something that doesn't even looks convex, so it is not the right projection. I would like to know what is going on and try to solve this issue, so I appreciate ideas on how to correct this, and where to look at on the code. EmersonLWed, 23 Nov 2016 14:27:10 -0600http://ask.sagemath.org/question/35704/Projection of vectorhttp://ask.sagemath.org/question/34190/projection-of-vector/ I'm working to reproduce an example made in GeoGebra* using Sage. What I got in GeoGebra looks like this,
![image description](http://i.stack.imgur.com/gLkEJ.png)
* would add link if I could …
The goal is to find the length of _j_ only knowing _A_, _B_, and _C_.
Here's where I'm at in Sage, it seems really smart, but all help files and templates I find online feels way too advanced for where I'm currently at. I've written the code below and it's currently look like this,
![image description](http://i.stack.imgur.com/8TOHN.png)
code (thanks to [@tmonteil](http://ask.sagemath.org/users/1305/tmonteil/) I've been able to update my code with some calculations, I am still struggling to produce the plot),
A = (9, 5); B = (2, 4); C = (16, -2);
AB = vector(B)-vector(A)
BC = vector(C)-vector(B)
P = plot(x,(x,2,5), color='red')
P += AB.plot(color='green', start=A)
P += BC.plot(color='green', start=B)
print "Length of AB proj. onto BC"
show(P, figsize=5, aspect_ratio=1)
# show(AB.inner_product(BC)/BC.norm()^2*v2)
show(AB.inner_product(BC)/BC.norm())
RDF(AB.inner_product(BC)/BC.norm())
etbFri, 22 Jul 2016 07:45:26 -0500http://ask.sagemath.org/question/34190/How can I change the projection in the webgl renderer?http://ask.sagemath.org/question/24673/how-can-i-change-the-projection-in-the-webgl-renderer/ I'm using plot3d in the sage cloud. How can I tell the webgl renderer to use the orthographic projection?David GuichardTue, 28 Oct 2014 21:58:22 -0500http://ask.sagemath.org/question/24673/projection_direction broken for polytopes?http://ask.sagemath.org/question/23223/projection_direction-broken-for-polytopes/Some years back (probably 2 or 3) Marshall very kindly sent me a notebook of polytope commands.
In that notebook there were the following:
poly = polytopes.twenty_four_cell()
poly.show()
poly.show(projection_direction=[2,5,11,17])
These last two commands produced different green diagrams... two years ago.
Today, they produce identical blue diagrams.
I search "sage projection_direction" and http://www.sagemath.org/doc/reference/geometry/sage/geometry/polyhedron/plot.html seems to indicate that the projection_direction option is still valid (not deprecated? should work? what's the correct phrasing here?).
Anyone know what's up with that?
smbelcasSat, 05 Jul 2014 08:43:45 -0500http://ask.sagemath.org/question/23223/How quickly minimizing $M*x-v$ (numerically) ?http://ask.sagemath.org/question/10643/how-quickly-minimizing-mx-v-numerically/Let $v$ in $R^m$ and let $M$ be a matrix from $R^n$ to $R^m$, with $m>n$ big numbers.
I want to compute a vector $x$ in $R^n$ such that the norm of $M*x-v$ is minimal.
One way is to compute the projection $w$ of $v$ on the image of $M$.
For so, we can compute the projection $p$ on the image of $M$, as follows :
MTGS=M.transpose().gram_schmidt()[0] # it's orthogonalization, not orthonormalization
l=MTGS.rank()
U=[]
for i in range(l):
v=MTGS[i]
u=v/(v.norm())
L=list(u)
U.append(L)
N=matrix(m,l,U)
p=N.transpose()*N
Then:
w=p*v
x=M.solve_right(w)
This vector $x$ minimizes the norm of $M*x-v$, but this method is very expensive in time, because it computes $p$ and $w$, while I just need $x$.
> Is there another method, less expensive in time, for computing $x$ ?
**Remark** : I'm ok with numerical methods.
Sébastien PalcouxMon, 21 Oct 2013 13:03:37 -0500http://ask.sagemath.org/question/10643/How to orthogonaly project a 3d plot to coordinate planes?http://ask.sagemath.org/question/8863/how-to-orthogonaly-project-a-3d-plot-to-coordinate-planes/Hi, I created a 3d plot with
parametric_plot3d( (cos(t)^3, sin(t)^3, cos(2*t)), (t, 0, 2*pi))
I looked over at google for some projection() functions but I didn't find much.
Basically what I need to do is orthogonally project that plot onto coordinate planes (x, y, z).
If anyone has any idea or an approximate algorithm, that would be nice.
Edit: is it possible that this is an orthogonal projection to coordinate planes? I'm showing 3 plots, first has z = 0, second has x = 0 and third has y = 0.
show( parametric_plot3d((cos(t)^3, sin(t)^3, 0), (t, 0, 2*pi)) + parametric_plot3d( (0, sin(t)^3, cos(2*t)), (t, 0, 2*pi)) + parametric_plot3d( (cos(t)^3, 0, cos(2*t)), (t, 0, 2*pi)));
dnizeticFri, 06 Apr 2012 05:54:47 -0500http://ask.sagemath.org/question/8863/Viewing Stereographic Projection of an Imagehttp://ask.sagemath.org/question/8824/viewing-stereographic-projection-of-an-image/I'm trying to write a program that takes an image and projects it onto a sphere that I can then view using 3dplot. I'm using pylab to read the image, numpy to put it into an array and then a stereographic projection to actually project it onto a sphere. I'm fairly certain the program is working correctly.
The problem I have is that 3dplot is not letting me view an image. The plot doesn't load. I tried the tachyon viewer, and I could get an image of my picture on a sphere, but I would prefer if I had the ability to rotate the sphere that 3dplot provides. Is there a better way to accomplish what I'm trying other than using pylab? I don't know much about other python imaging systems.
SeikishiSat, 24 Mar 2012 12:15:43 -0500http://ask.sagemath.org/question/8824/transforming 2D plots to the surface of a spherehttp://ask.sagemath.org/question/8174/transforming-2d-plots-to-the-surface-of-a-sphere/Hi there Sagers:
I'm trying to use a cartographic projection $f:\mathbb{R}^2\to S^2\subset\mathbb{R}^3$ to map Sage 2D graphics objects onto the sphere $S^2$. Projecting points is easy, but how can i project polygons or function plots? Do i somehow grab the graphics object points and use point3d and $f$?
Thanks for your attention.
Alex araichevWed, 20 Jul 2011 17:48:57 -0500http://ask.sagemath.org/question/8174/