︠5eb59663-18d3-476e-b13b-74e56e07e3fcs︠ %sage x = var('x') @interact def _(k = (1..10)): print(k) plot(x * sin(x), (x, -k*pi, k*pi)) print("k = %s" % k) ︡94c69393-5e1c-4541-a137-20f3fafa58b1︡{"interact":{"style":"None","flicker":false,"layout":[[["k",12,null]],[["",12,null]]],"id":"e07198e5-64ef-40e7-a7ce-f649b7907d84","controls":[{"control_type":"slider","default":0,"var":"k","width":null,"vals":["1","2","3","4","5","6","7","8","9","10"],"animate":true,"label":"k","display_value":true}]}}︡ ︠a6b7f9a7-9241-4031-b2b7-46daa72421d5s︠ %sage k = 2 plot(x * sin(x), (x, -k*pi, k*pi)) ︡9aea29ba-7568-4c41-9205-f2c76d966164︡{"once":false,"file":{"show":true,"uuid":"ff63ac2e-e23b-45bf-9395-d9bb82c181c2","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute1-us/626/tmp_1DDusF.svg"}}︡{"html":"
"}︡ ︠0463e329-cd14-41f4-b707-d5d8b40339af︠ %r attach(faithful) hist(eruptions, seq(1.6, 5.2, 0.2), prob=TRUE) lines(density(eruptions, bw=0.1)) rug(eruptions) ︡2414be60-66a1-4649-ba1b-c09976163b67︡{"stdout":"\n"}︡{"once":false,"file":{"show":true,"uuid":"f1113810-c52d-4783-9969-f898e1f17762","filename":"/tmp/9f3e0cd6-d74d-4faf-bc89-53d448225371.svg"}}︡{"stdout":"\n"}︡ ︠d171039b-29a5-4ead-a97c-59681784b196︠ @interact def demof(a = slider(-5, 5, .01, 4)): x = var("x") plot(sin(a*x), (-pi, 2*pi)).show() ︡058e30b8-6b6e-49b8-9669-24aaa9ccf485︡{"interact":{"style":"None","flicker":false,"layout":[[["a",12,null]],[["",12,null]]],"id":"a900df6c-bcba-4287-be17-2d1c3c2257af","controls":[{"control_type":"slider","default":450,"var":"a","width":null,"vals":["-5.00000000000000","-4.98000000000000","-4.96000000000000","-4.94000000000000","-4.92000000000000","-4.90000000000000","-4.88000000000000","-4.86000000000000","-4.84000000000000","-4.82000000000000","-4.80000000000000","-4.78000000000000","-4.76000000000001","-4.74000000000001","-4.72000000000001","-4.70000000000001","-4.68000000000001","-4.66000000000001","-4.64000000000001","-4.62000000000001","-4.60000000000001","-4.58000000000001","-4.56000000000001","-4.54000000000001","-4.52000000000001","-4.50000000000001","-4.48000000000001","-4.46000000000001","-4.44000000000001","-4.42000000000001","-4.40000000000001","-4.38000000000001","-4.36000000000001","-4.34000000000001","-4.32000000000001","-4.30000000000001","-4.28000000000002","-4.26000000000002","-4.24000000000002","-4.22000000000002","-4.20000000000002","-4.18000000000002","-4.16000000000002","-4.14000000000002","-4.12000000000002","-4.10000000000002","-4.08000000000002","-4.06000000000002","-4.04000000000002","-4.02000000000002","-4.00000000000002","-3.98000000000002","-3.96000000000002","-3.94000000000002","-3.92000000000002","-3.90000000000002","-3.88000000000002","-3.86000000000002","-3.84000000000002","-3.82000000000003","-3.80000000000003","-3.78000000000003","-3.76000000000003","-3.74000000000003","-3.72000000000003","-3.70000000000003","-3.68000000000003","-3.66000000000003","-3.64000000000003","-3.62000000000003","-3.60000000000003","-3.58000000000003","-3.56000000000003","-3.54000000000003","-3.52000000000003","-3.50000000000003","-3.48000000000003","-3.46000000000003","-3.44000000000003","-3.42000000000003","-3.40000000000003","-3.38000000000003","-3.36000000000003","-3.34000000000004","-3.32000000000004","-3.30000000000004","-3.28000000000004","-3.26000000000004","-3.24000000000004","-3.22000000000004","-3.20000000000004","-3.18000000000004","-3.16000000000004","-3.14000000000004","-3.12000000000004","-3.10000000000004","-3.08000000000004","-3.06000000000004","-3.04000000000004","-3.02000000000004","-3.00000000000004","-2.98000000000004","-2.96000000000004","-2.94000000000004","-2.92000000000004","-2.90000000000004","-2.88000000000005","-2.86000000000005","-2.84000000000005","-2.82000000000005","-2.80000000000005","-2.78000000000005","-2.76000000000005","-2.74000000000005","-2.72000000000005","-2.70000000000005","-2.68000000000005","-2.66000000000005","-2.64000000000005","-2.62000000000005","-2.60000000000005","-2.58000000000005","-2.56000000000005","-2.54000000000005","-2.52000000000005","-2.50000000000005","-2.48000000000005","-2.46000000000005","-2.44000000000005","-2.42000000000005","-2.40000000000006","-2.38000000000006","-2.36000000000006","-2.34000000000006","-2.32000000000006","-2.30000000000006","-2.28000000000006","-2.26000000000006","-2.24000000000006","-2.22000000000006","-2.20000000000006","-2.18000000000006","-2.16000000000006","-2.14000000000006","-2.12000000000006","-2.10000000000006","-2.08000000000006","-2.06000000000006","-2.04000000000006","-2.02000000000006","-2.00000000000006","-1.98000000000006","-1.96000000000006","-1.94000000000006","-1.92000000000006","-1.90000000000006","-1.88000000000006","-1.86000000000006","-1.84000000000006","-1.82000000000006","-1.80000000000006","-1.78000000000006","-1.76000000000006","-1.74000000000006","-1.72000000000006","-1.70000000000006","-1.68000000000006","-1.66000000000006","-1.64000000000006","-1.62000000000006","-1.60000000000006","-1.58000000000006","-1.56000000000006","-1.54000000000006","-1.52000000000006","-1.50000000000006","-1.48000000000006","-1.46000000000006","-1.44000000000006","-1.42000000000006","-1.40000000000006","-1.38000000000006","-1.36000000000006","-1.34000000000006","-1.32000000000006","-1.30000000000006","-1.28000000000006","-1.26000000000006","-1.24000000000006","-1.22000000000006","-1.20000000000006","-1.18000000000006","-1.16000000000006","-1.14000000000006","-1.12000000000006","-1.10000000000006","-1.08000000000006","-1.06000000000006","-1.04000000000006","-1.02000000000006","-1.00000000000006","-0.980000000000063","-0.960000000000063","-0.940000000000063","-0.920000000000063","-0.900000000000063","-0.880000000000063","-0.860000000000063","-0.840000000000063","-0.820000000000063","-0.800000000000063","-0.780000000000063","-0.760000000000063","-0.740000000000063","-0.720000000000063","-0.700000000000063","-0.680000000000063","-0.660000000000063","-0.640000000000063","-0.620000000000063","-0.600000000000063","-0.580000000000063","-0.560000000000063","-0.540000000000063","-0.520000000000063","-0.500000000000063","-0.480000000000063","-0.460000000000063","-0.440000000000063","-0.420000000000063","-0.400000000000063","-0.380000000000063","-0.360000000000062","-0.340000000000062","-0.320000000000062","-0.300000000000062","-0.280000000000062","-0.260000000000062","-0.240000000000062","-0.220000000000062","-0.200000000000062","-0.180000000000062","-0.160000000000062","-0.140000000000062","-0.120000000000062","-0.100000000000062","-0.0800000000000623","-0.0600000000000623","-0.0400000000000623","-0.0200000000000623","-6.23077978101350e-14","0.0199999999999377","0.0399999999999377","0.0599999999999377","0.0799999999999377","0.0999999999999377","0.119999999999938","0.139999999999938","0.159999999999938","0.179999999999938","0.199999999999938","0.219999999999938","0.239999999999938","0.259999999999938","0.279999999999938","0.299999999999938","0.319999999999938","0.339999999999938","0.359999999999938","0.379999999999938","0.399999999999938","0.419999999999938","0.439999999999938","0.459999999999938","0.479999999999938","0.499999999999938","0.519999999999938","0.539999999999938","0.559999999999938","0.579999999999938","0.599999999999938","0.619999999999938","0.639999999999938","0.659999999999938","0.679999999999938","0.699999999999938","0.719999999999938","0.739999999999938","0.759999999999938","0.779999999999938","0.799999999999938","0.819999999999938","0.839999999999938","0.859999999999938","0.879999999999938","0.899999999999938","0.919999999999938","0.939999999999938","0.959999999999938","0.979999999999938","0.999999999999938","1.01999999999994","1.03999999999994","1.05999999999994","1.07999999999994","1.09999999999994","1.11999999999994","1.13999999999994","1.15999999999994","1.17999999999994","1.19999999999994","1.21999999999994","1.23999999999994","1.25999999999994","1.27999999999994","1.29999999999994","1.31999999999994","1.33999999999994","1.35999999999994","1.37999999999994","1.39999999999994","1.41999999999994","1.43999999999994","1.45999999999994","1.47999999999994","1.49999999999994","1.51999999999994","1.53999999999994","1.55999999999994","1.57999999999994","1.59999999999994","1.61999999999994","1.63999999999994","1.65999999999994","1.67999999999994","1.69999999999994","1.71999999999994","1.73999999999994","1.75999999999994","1.77999999999994","1.79999999999994","1.81999999999994","1.83999999999994","1.85999999999994","1.87999999999994","1.89999999999994","1.91999999999994","1.93999999999994","1.95999999999994","1.97999999999994","1.99999999999994","2.01999999999994","2.03999999999994","2.05999999999994","2.07999999999994","2.09999999999994","2.11999999999994","2.13999999999994","2.15999999999994","2.17999999999994","2.19999999999993","2.21999999999993","2.23999999999993","2.25999999999993","2.27999999999993","2.29999999999993","2.31999999999993","2.33999999999993","2.35999999999993","2.37999999999993","2.39999999999993","2.41999999999993","2.43999999999993","2.45999999999993","2.47999999999993","2.49999999999993","2.51999999999993","2.53999999999993","2.55999999999993","2.57999999999993","2.59999999999993","2.61999999999993","2.63999999999993","2.65999999999993","2.67999999999992","2.69999999999992","2.71999999999992","2.73999999999992","2.75999999999992","2.77999999999992","2.79999999999992","2.81999999999992","2.83999999999992","2.85999999999992","2.87999999999992","2.89999999999992","2.91999999999992","2.93999999999992","2.95999999999992","2.97999999999992","2.99999999999992","3.01999999999992","3.03999999999992","3.05999999999992","3.07999999999992","3.09999999999992","3.11999999999992","3.13999999999991","3.15999999999991","3.17999999999991","3.19999999999991","3.21999999999991","3.23999999999991","3.25999999999991","3.27999999999991","3.29999999999991","3.31999999999991","3.33999999999991","3.35999999999991","3.37999999999991","3.39999999999991","3.41999999999991","3.43999999999991","3.45999999999991","3.47999999999991","3.49999999999991","3.51999999999991","3.53999999999991","3.55999999999991","3.57999999999991","3.59999999999991","3.61999999999990","3.63999999999990","3.65999999999990","3.67999999999990","3.69999999999990","3.71999999999990","3.73999999999990","3.75999999999990","3.77999999999990","3.79999999999990","3.81999999999990","3.83999999999990","3.85999999999990","3.87999999999990","3.89999999999990","3.91999999999990","3.93999999999990","3.95999999999990","3.97999999999990","3.99999999999990","4.01999999999990","4.03999999999990","4.05999999999990","4.07999999999990","4.09999999999989","4.11999999999989","4.13999999999989","4.15999999999989","4.17999999999989","4.19999999999989","4.21999999999989","4.23999999999989","4.25999999999989","4.27999999999989","4.29999999999989","4.31999999999989","4.33999999999989","4.35999999999989","4.37999999999989","4.39999999999989","4.41999999999989","4.43999999999989","4.45999999999989","4.47999999999989","4.49999999999989","4.51999999999989","4.53999999999989","4.55999999999989","4.57999999999988","4.59999999999988","4.61999999999988","4.63999999999988","4.65999999999988","4.67999999999988","4.69999999999988","4.71999999999988","4.73999999999988","4.75999999999988","4.77999999999988","4.79999999999988","4.81999999999988","4.83999999999988","4.85999999999988","4.87999999999988","4.89999999999988","4.91999999999988","4.93999999999988","4.95999999999988","4.97999999999988"],"animate":true,"label":"a","display_value":true}]}}︡ ︠17f8e077-6809-450c-8645-280c13833f92︠ import numpy as np from scipy import misc I = misc.lena() E = np.asarray(I) U,s,V=np.linalg.svd(E) ︡1f574b26-c2a1-46c8-8407-46d4dc2952d9︡ ︠695d0642-0aad-42e7-93b3-844b4339f150︠ N = 75 # U.shape[0] graphics_array([matrix_plot(U[:,:N]), matrix_plot(np.diag(s[:N])), matrix_plot(V[:N,:].T)]) ︡a090744a-fd0d-4f84-8348-935313eb40d5︡{"once":false,"file":{"show":true,"uuid":"4a23004e-afa5-47c9-b24d-a4871cbc1b4a","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_kbY0Sg.svg"}}︡{"html":"
"}︡ ︠0e3f00ef-463c-4389-be8a-4beb43f9fed7︠ @interact def svd_demo(N=slider(0, E.shape[0], 1, 50, 15)): reconstr = U[:,:N].dot(np.diag(s[:N]).dot(V[:N,:])) show(graphics_array([matrix_plot(I), matrix_plot(reconstr)])) ︡a7b52832-0159-4acd-a9f0-502bd5081ded︡{"interact":{"style":"None","flicker":false,"layout":[[["N",12,null]],[["",12,null]]],"id":"d8c61666-7626-401c-968f-83282bc41d3c","controls":[{"control_type":"slider","default":50,"var":"N","width":null,"vals":["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","137","138","139","140","141","142","143","144","145","146","147","148","149","150","151","152","153","154","155","156","157","158","159","160","161","162","163","164","165","166","167","168","169","170","171","172","173","174","175","176","177","178","179","180","181","182","183","184","185","186","187","188","189","190","191","192","193","194","195","196","197","198","199","200","201","202","203","204","205","206","207","208","209","210","211","212","213","214","215","216","217","218","219","220","221","222","223","224","225","226","227","228","229","230","231","232","233","234","235","236","237","238","239","240","241","242","243","244","245","246","247","248","249","250","251","252","253","254","255","256","257","258","259","260","261","262","263","264","265","266","267","268","269","270","271","272","273","274","275","276","277","278","279","280","281","282","283","284","285","286","287","288","289","290","291","292","293","294","295","296","297","298","299","300","301","302","303","304","305","306","307","308","309","310","311","312","313","314","315","316","317","318","319","320","321","322","323","324","325","326","327","328","329","330","331","332","333","334","335","336","337","338","339","340","341","342","343","344","345","346","347","348","349","350","351","352","353","354","355","356","357","358","359","360","361","362","363","364","365","366","367","368","369","370","371","372","373","374","375","376","377","378","379","380","381","382","383","384","385","386","387","388","389","390","391","392","393","394","395","396","397","398","399","400","401","402","403","404","405","406","407","408","409","410","411","412","413","414","415","416","417","418","419","420","421","422","423","424","425","426","427","428","429","430","431","432","433","434","435","436","437","438","439","440","441","442","443","444","445","446","447","448","449","450","451","452","453","454","455","456","457","458","459","460","461","462","463","464","465","466","467","468","469","470","471","472","473","474","475","476","477","478","479","480","481","482","483","484","485","486","487","488","489","490","491","492","493","494","495","496","497","498","499","500","501","502","503","504","505","506","507","508","509","510","511","512"],"animate":true,"label":15,"display_value":true}]}}︡ ︠bc08559f-59bf-4a2b-a296-ce3a03ff5d72︠ svd_demo(N = 256) ︡1791af88-4612-44dd-bee6-ac5b06dc3aae︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 256, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"c6aa3d6c-0f12-4a12-8ec2-89f3d7f3634d","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_TmGQmP.svg"}}︡{"html":"
"}︡ ︠f62d3c80-2417-497e-851a-1532df0be990︠ svd_demo(N = 100) ︡b9565cf2-4826-4697-8f88-96bb728f8738︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 100, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"2970a8f9-6aa0-4d64-84d5-96b061288924","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_jOGLwC.svg"}}︡{"html":"
"}︡ ︠33e24721-9080-4412-b92a-392715f74bd6︠ svd_demo(N = 50) ︡498e32ba-b2d4-49a6-9019-f2331d5c7b80︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 50, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"611b8fab-1342-449a-a839-17bba6f9535b","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_HDl_be.svg"}}︡{"html":"
"}︡ ︠7103e54a-8ea3-485b-a4af-498eb3d2a67d︠ svd_demo(N = 32) ︡bcb48c70-a1de-4fc0-be3d-c00f774f8c7a︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 32, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"55ced121-f3f6-4dff-b95b-5af34d306fcb","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_LDZ_oV.svg"}}︡{"html":"
"}︡ ︠7f3d4cec-3bef-412c-8814-c490ae37ed24︠ svd_demo(N = 15) ︡e649945b-0883-44cc-93fe-87ffe99ead23︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 15, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"6ed4c8a8-af2f-41b4-8451-92f38268aa37","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_EGmgGs.svg"}}︡{"html":"
"}︡ ︠d9e9654d-594d-47a3-ab56-99c5c8c76194︠ svd_demo(N = 10) ︡8d8ab53f-0e3f-4f95-a32a-f51c9da86284︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 10, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"332e1a2d-df24-49b1-82c2-fbd1c711ad35","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_IVO3e4.svg"}}︡{"html":"
"}︡ ︠43b7d1a1-dc46-413c-b299-56eaa864f18d︠ svd_demo(N = 5) ︡1a4aae8e-c976-4af1-ae5f-1b775ff76bc4︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 5, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"0a56f457-d145-49be-b429-bc477281fd81","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp__pBzgL.svg"}}︡{"html":"
"}︡ ︠1104dc01-6ea0-48e6-9e4e-25635ba1bc5f︠ svd_demo(N = 1) ︡4f2d4dac-496f-4b29-83ee-3d7d6f2321df︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 1, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"2d079766-8db7-4373-8b94-0fcc7b9414ac","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_WVLs7g.svg"}}︡{"html":"
"}︡ ︠43697651-2ea2-424d-8846-dee37a366be8︠ svd_demo(N = 0) ︡b9b13045-74fe-42af-9b1d-b78158062eb5︡{"clear":true}︡{"obj":"{\"var\": \"N\", \"default\": 0, \"id\": \"8663f545-ea5a-4187-9761-10995762bab9\"}","javascript":{"coffeescript":false,"code":"worksheet.set_interact_var(obj)"},"once":false}︡{"once":false,"file":{"show":true,"uuid":"f83a0c36-82fa-4e4e-9637-d7d412c43288","filename":"/projects/20e4a191-73ea-4921-80e9-0a5d792fc511/.sage/temp/compute2dc1/14351/tmp_JGKNu7.svg"}}︡{"html":"
"}︡ ︠826d906f-9a07-4647-bde8-1e49548c6516︠ import numpy as np U, s, V = np.linalg.svd(E) U.shape, s.shape, V.shape ︡117d00a9-4e88-439f-ade1-e68676a4c483︡{"stdout":"((512, 512), (512,), (512, 512))\n"}︡ ︠55afd89a-0206-4808-a943-2224d883e0a8︠ N = 50 U[:,:N].dot(np.diag(s[:N]).dot(V[:,:N].T)) ︡1b66fc89-b430-45b6-820c-d87ca3941ec7︡{"stdout":"array([[ 62.17166002, -49.14283225, 55.58897907, ..., -38.44414064,\n -12.96930387, 27.74346039],\n [ 62.17166002, -49.14283225, 55.58897907, ..., -38.44414064,\n -12.96930387, 27.74346039],\n [ 62.17166002, -49.14283225, 55.58897907, ..., -38.44414064,\n -12.96930387, 27.74346039],\n ..., \n [ 102.9419529 , -115.29743923, -38.9206326 , ..., 33.99282739,\n 15.88387515, 16.2630756 ],\n [ 102.06058 , -116.69180488, -36.45098782, ..., 38.87899566,\n 22.05276646, 14.78230945],\n [ 102.06058 , -116.69180488, -36.45098782, ..., 38.87899566,\n 22.05276646, 14.78230945]])\n"}︡ ︠c389f9df-8138-420c-a5cb-d6757617e8b2︠ np.linalg.svd? ︡181bfb13-1b40-4d23-a7d5-5bc354bf8ae5︡{"code":{"source":"File: /usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/numpy/linalg/linalg.py\nSignature : np.linalg.svd(a, full_matrices=1, compute_uv=1)\nDocstring :\nSingular Value Decomposition.\n\nFactors the matrix a as \"u * np.diag(s) * v\", where u and v are\nunitary and s is a 1-d array of a's singular values.\n\na : (..., M, N) array_like\n A real or complex matrix of shape (M, N) .\n\nfull_matrices : bool, optional\n If True (default), u and v have the shapes (M, M) and (N, N),\n respectively. Otherwise, the shapes are (M, K) and (K, N),\n respectively, where K = min(M, N).\n\ncompute_uv : bool, optional\n Whether or not to compute u and v in addition to s. True by\n default.\n\nu : { (..., M, M), (..., M, K) } array\n Unitary matrices. The actual shape depends on the value of\n \"full_matrices\". Only returned when \"compute_uv\" is True.\n\ns : (..., K) array\n The singular values for every matrix, sorted in descending\n order.\n\nv : { (..., N, N), (..., K, N) } array\n Unitary matrices. The actual shape depends on the value of\n \"full_matrices\". Only returned when \"compute_uv\" is True.\n\nLinAlgError\n If SVD computation does not converge.\n\nBroadcasting rules apply, see the numpy.linalg documentation for\ndetails.\n\nThe decomposition is performed using LAPACK routine _gesdd\n\nThe SVD is commonly written as \"a = U S V.H\". The v returned by\nthis function is \"V.H\" and \"u = U\".\n\nIf \"U\" is a unitary matrix, it means that it satisfies \"U.H =\ninv(U)\".\n\nThe rows of v are the eigenvectors of \"a.H a\". The columns of u are\nthe eigenvectors of \"a a.H\". For row \"i\" in v and column \"i\" in u,\nthe corresponding eigenvalue is \"s[i]**2\".\n\nIf a is a matrix object (as opposed to an ndarray), then so are all\nthe return values.\n\n>>> a = np.random.randn(9, 6) + 1j*np.random.randn(9, 6)\n\nReconstruction based on full SVD:\n\n>>> U, s, V = np.linalg.svd(a, full_matrices=True)\n>>> U.shape, V.shape, s.shape\n((9, 9), (6, 6), (6,))\n>>> S = np.zeros((9, 6), dtype=complex)\n>>> S[:6, :6] = np.diag(s)\n>>> np.allclose(a, np.dot(U, np.dot(S, V)))\nTrue\n\nReconstruction based on reduced SVD:\n\n>>> U, s, V = np.linalg.svd(a, full_matrices=False)\n>>> U.shape, V.shape, s.shape\n((9, 6), (6, 6), (6,))\n>>> S = np.diag(s)\n>>> np.allclose(a, np.dot(U, np.dot(S, V)))\nTrue","mode":"text/x-rst","lineno":-1,"filename":null}}︡ ︠d7a8860b-9497-4b5f-adb9-436102020cbe︠ E2 = matrix(E) E3 = E2.change_ring(RDF) ︡2a862125-7431-4615-b8a3-b92dae189f5f︡ ︠bf41fb79-9f8d-45d2-9237-f8c1e4270541︠ type(E) E.dtype E2.parent() ︡31aa1b77-15f3-433f-9f43-ad734fc16c8a︡{"stdout":"\n"}︡{"stdout":"dtype('int64')\n"}︡{"stdout":"Full MatrixSpace of 512 by 512 dense matrices over Integer Ring\n"}︡ ︠1ba18cf0-2461-403e-8b0d-245096f3d831︠ E3.parent() ︡e6c18b56-9960-4ea3-aac0-14bbeba83470︡{"stdout":"Full MatrixSpace of 512 by 512 dense matrices over Real Double Field\n"}︡ ︠bdb4a5b1-0196-42d0-9e07-553bc7e8540a︠ type(E3.numpy()) ︡faa22cfc-6e52-4a68-855c-9d2c7b8b726b︡{"stdout":"\n"}︡ ︠f3d04975-a5f4-4ef8-b46c-33af3d6d976c︠ ︡7b65c7db-56e4-403d-a11f-b9ae9686aa51︡ ︠e1f53042-ba35-453d-a637-e3a4db718d53︠