Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

You had a lot of duplication in your subroutines so I removed it.

Perhaps this will help?

#!/usr/bin/perl use warnings; use strict; use PDL; use PDL::Complex; my $eprim = 0.001; my $X = pdl( [ [ 0, -sqrt( 1 ), 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +0 ], [ sqrt( 1 ), 0, sqrt( 2 ), 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +0 ], [ 0, sqrt( 2 ), 0, sqrt( 3 ), 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +0 ], [ 0, 0, sqrt( 3 ), 0, sqrt( 4 ), 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +0 ], [ 0, 0, 0, sqrt( 4 ), 0, sqrt( 5 +), 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +0 ], [ 0, 0, 0, 0, sqrt( 5 ), 0, + sqrt( 6 ), 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +0 ], [ 0, 0, 0, 0, 0, sqrt( 6 +), 0, sqrt( 7 ), 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +0 ], [ 0, 0, 0, 0, 0, 0, + sqrt( 7 ), 0, sqrt( 8 ), 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 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], [ 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, sqrt( 26 ), 0, sqrt( 27 ), +0 ], [ 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, sqrt( 27 ), 0, +sqrt( 27 ) ], [ 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, sqrt( 28 ), +0 ], [ 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, +sqrt( 28 ) ], ] ); my $vec = pdl( [ [ -0.4037003675364034, -0.0000000000000169, -0.8381213708160592, - +0.0000000000000158, -0.3190879932741590, 0.0000000000000003, 0.1693 +552581542248, 0.0000000000000032, 0.0251289794138005, -0.0000000000 +000012, -0.0536300581595280, -0.0000000000000003, 0.0217496956429717 +, 0.0000000000000005, 0.0021651419544516, -0.0000000000000002, -0.0 +080249333137898, 0.0000000000000000, 0.0051470455076793, 0.0000000 +000000001, -0.0013650508619321, -0.0000000000000001, -0.0006214095672 +646, 0.0000000000000000, 0.0010251417156844, -0.0000000000000000, - +0.0007344546098787, -0.0000000000000000, 0.0003358368423501, 0.0000 +000000000000 ], [ -0.0000000000000095, 0.7226441842331763, -0.0000000000000196, +0.6743694628487641, -0.0000000000000074, -0.0126709869133627, 0.0000 +000000000039, -0.1390097337149938, 0.0000000000000004, 0.0532637295 +249766, -0.0000000000000012, 0.0108058217041577, 0.0000000000000004 +, -0.0211856923535512, -0.0000000000000004, 0.0104565487807121, 0.0 +000000000000001, -0.0008021321669403, -0.0000000000000003, -0.0027244 +498764788, 0.0000000000000004, 0.0023881197288006, -0.0000000000000 +006, -0.0010161248442056, 0.0000000000000009, 0.0000173027596815, - +0.0000000000000008, 0.0003416491521171, 0.0000000000000006, -0.0002 +612727358195 ], [ -0.7265845261792991, 0.0000000000000004, 0.0822771629823105, - +0.0000000000000005, 0.6492960190820365, -0.0000000000000003, -0.0423 +366396915736, 0.0000000000000002, -0.1758256491790640, 0.0000000000 +000000, 0.0979409067513942, -0.0000000000000001, -0.0028801939655116 +, 0.0000000000000000, -0.0292811602848338, 0.0000000000000000, 0.0 +218748117671870, -0.0000000000000000, -0.0068869463649583, 0.0000000 +000000000, -0.0019130055021425, -0.0000000000000000, 0.0039694711332 +578, 0.0000000000000000, -0.0028100428723103, -0.0000000000000000, +0.0012454407121507, -0.0000000000000000, -0.0003466238255135, 0.0000 +000000000000 ], [ 0.0000000000000006, 0.6010733799547240, -0.0000000000000001, - +0.5937368797404066, -0.0000000000000004, -0.4447140685185609, 0.0000 +000000000001, 0.2753043611569276, 0.0000000000000001, 0.0177297849 +332504, -0.0000000000000001, -0.0947825000175309, 0.0000000000000001 +, 0.0539543068519576, -0.0000000000000003, -0.0064734473245184, 0.0 +000000000000001, -0.0131918455031492, 0.0000000000000004, 0.0125678 +040256591, 0.0000000000000000, -0.0057077804477274, -0.0000000000000 +002, 0.0003357404158152, 0.0000000000000007, 0.0018880365733295, - +0.0000000000000005, -0.0019443492967520, 0.0000000000000001, 0.0010 +789173843832 ], [ 0.5430269760782945, -0.0000000000000001, -0.4474156032695855, - +0.0000000000000000, 0.5801000179013242, 0.0000000000000002, 0.2404 +758383494775, -0.0000000000000002, -0.3088519136114667, 0.0000000000 +000001, 0.0823788344472166, 0.0000000000000000, 0.0541280464126355 +, -0.0000000000000001, -0.0660462396199596, 0.0000000000000000, 0.0 +305535579726857, -0.0000000000000000, -0.0009344967473301, -0.0000000 +000000000, -0.0099964129968316, 0.0000000000000000, 0.0087666379065 +681, -0.0000000000000000, -0.0040952318231305, 0.0000000000000000, +0.0007413411176992, -0.0000000000000000, 0.0003124230406161, 0.0000 +000000000000 ], [ 0.0000000000000000, 0.3321617007160794, -0.0000000000000001, - +0.3314564696269089, -0.0000000000000002, 0.7974495377138241, -0.0000 +000000000004, -0.0513734221888449, 0.0000000000000001, -0.3011617902 +587023, 0.0000000000000004, 0.2082370289532634, -0.0000000000000003 +, -0.0347605467840875, -0.0000000000000001, -0.0497057528447874, 0.0 +000000000000006, 0.0521296336393288, -0.0000000000000008, -0.0250539 +045206587, 0.0000000000000008, 0.0023068831550118, -0.0000000000000 +003, 0.0074112442261458, 0.0000000000000001, -0.0079651410760186, +0.0000000000000001, 0.0051288837146889, -0.0000000000000001, -0.0022 +324847785247 ], [ 0.1172897082030818, -0.0000000000000002, -0.2964728523725000, +0.0000000000000003, 0.1841483714928239, -0.0000000000000005, -0.8047 +717594409407, 0.0000000000000009, 0.3242847252115117, -0.0000000000 +000004, 0.1636497762965390, 0.0000000000000000, -0.2529941067981705 +, 0.0000000000000002, 0.1294310921497701, -0.0000000000000002, -0.0 +062237278459524, 0.0000000000000001, -0.0444860334138650, 0.0000000 +000000000, 0.0406263992613470, -0.0000000000000001, -0.0185369919706 +947, 0.0000000000000001, 0.0007534586982924, -0.0000000000000000, +0.0063516252770288, 0.0000000000000000, -0.0050724227338856, -0.0000 +000000000000 ], [ -0.0000000000000000, -0.0746816751641777, 0.0000000000000003, +0.2799603944858002, 0.0000000000000004, -0.0369884510514530, 0.0000 +000000000016, 0.7185111750625419, 0.0000000000000002, -0.5499552865 +074182, -0.0000000000000006, 0.0532991069401313, -0.0000000000000002 +, 0.2088524831915762, 0.0000000000000011, -0.1984245945881420, -0.0 +000000000000011, 0.0856956117134249, 0.0000000000000004, 0.0038508 +424287722, 0.0000000000000007, -0.0373833868060850, -0.0000000000000 +012, 0.0329127019021361, 0.0000000000000010, -0.0166509762582109, - +0.0000000000000004, 0.0042911848981398, -0.0000000000000001, 0.0002 +821243295013 ], [ -0.0214780579913734, -0.0000000000000003, 0.0372177058109391, +0.0000000000000003, -0.2944751450270211, -0.0000000000000008, -0.0756 +830241404122, 0.0000000000000008, -0.5412748833836341, -0.0000000000 +000006, 0.6686762866715919, 0.0000000000000003, -0.2932317876571968 +, 0.0000000000000000, -0.0735660926692254, -0.0000000000000002, 0.2 +050075536886243, 0.0000000000000001, -0.1583105998876948, -0.0000000 +000000000, 0.0602462844067277, -0.0000000000000001, 0.0115818910911 +991, 0.0000000000000001, -0.0397160230068139, -0.0000000000000001, +0.0369608788819537, 0.0000000000000001, -0.0202264690881708, -0.0000 +000000000000 ], [ -0.0000000000000000, 0.0238139307663168, 0.0000000000000000, +0.0126527912037899, -0.0000000000000002, 0.3264304157504123, -0.0000 +000000000002, 0.1354442358079246, -0.0000000000000006, 0.3188188145 +305269, 0.0000000000000004, -0.6646875721923707, -0.0000000000000002 +, 0.4961929745611114, 0.0000000000000003, -0.1255681225264503, -0.0 +000000000000002, -0.1270009315120212, 0.0000000000000003, 0.1845765 +986762271, -0.0000000000000001, -0.1230738673852459, -0.0000000000000 +004, 0.0376175711869895, 0.0000000000000006, 0.0187532845837444, - +0.0000000000000005, -0.0354892349606020, 0.0000000000000004, 0.0238 +711615056090 ], [ 0.0017318840561273, -0.0000000000000002, -0.0324109249717848, +0.0000000000000007, -0.0699841577530595, -0.0000000000000002, -0.3493 +020100003451, 0.0000000000000011, -0.1121863328196896, -0.0000000000 +000014, -0.1092103091430736, -0.0000000000000000, 0.5420611831710406 +, 0.0000000000000013, -0.6097584088048894, -0.0000000000000015, 0.3 +508901747526678, 0.0000000000000009, -0.0471175681506413, -0.0000000 +000000002, -0.1258773221542367, -0.0000000000000002, 0.1564524321190 +749, 0.0000000000000002, -0.1120328335999530, -0.0000000000000002, +0.0570522771318334, 0.0000000000000001, -0.0203908274536104, -0.0000 +000000000001 ], [ 0.0000000000000000, -0.0016213341083221, 0.0000000000000001, - +0.0510987268286506, 0.0000000000000003, -0.1334540474130648, 0.0000 +000000000009, -0.3479817094912636, 0.0000000000000007, -0.0311921491 +179282, 0.0000000000000001, 0.0444673033625089, -0.0000000000000014 +, 0.3398228370041564, 0.0000000000000012, -0.5916539149462523, -0.0 +000000000000005, 0.5108305696513560, -0.0000000000000002, -0.2420842 +730477737, -0.0000000000000003, -0.0103981442743016, 0.0000000000000 +013, 0.1459764073717070, -0.0000000000000019, -0.1690313714662625, +0.0000000000000019, 0.1276772440329932, -0.0000000000000014, -0.0644 +813878617362 ], [ 0.0011147979892237, -0.0000000000000003, 0.0124527283486975, +0.0000000000000002, 0.0947114844587487, -0.0000000000000008, 0.2372 +976408624008, 0.0000000000000005, 0.3557847566629774, 0.0000000000 +000003, -0.0635298085436199, -0.0000000000000005, -0.1713173200400193 +, 0.0000000000000002, -0.0972899291799430, 0.0000000000000004, 0.4 +717862901085890, -0.0000000000000011, -0.5720800153535275, 0.0000000 +000000016, 0.3811052943887194, -0.0000000000000018, -0.0912455512043 +619, 0.0000000000000014, -0.1192978755879619, -0.0000000000000009, +0.1817055145006404, 0.0000000000000005, -0.1202320521959933, -0.0000 +000000000002 ], [ -0.0000000000000000, -0.0034343034398039, -0.0000000000000001, - +0.0299555389414543, -0.0000000000000004, -0.1423655878081122, -0.0000 +000000000012, -0.2861228319386651, -0.0000000000000016, -0.2698629683 +232922, -0.0000000000000006, 0.1808943245053649, 0.0000000000000014 +, 0.1391051824361962, 0.0000000000000000, -0.0647414559720777, -0.0 +000000000000010, -0.2908420542400688, 0.0000000000000007, 0.5446044 +409698884, 0.0000000000000011, -0.5243579846618940, -0.0000000000000 +024, 0.3154050447298352, 0.0000000000000033, -0.0894563929271685, - +0.0000000000000028, -0.0389334639461899, 0.0000000000000014, 0.0522 +795627061793 ], [ -0.0002173011090244, -0.0000000000000015, -0.0060764847307131, - +0.0000000000000005, -0.0347032140814115, 0.0000000000000003, -0.1214 +115309280255, 0.0000000000000004, -0.1627557440827222, 0.0000000000 +000027, -0.0825798997978443, -0.0000000000000007, 0.1886866183315523 +, -0.0000000000000009, -0.0554160985866513, -0.0000000000000009, -0.0 +016082286660558, 0.0000000000000035, -0.1445886337968438, -0.0000000 +000000039, 0.3734410579584759, 0.0000000000000024, -0.5230941284069 +114, 0.0000000000000000, 0.5241670456105690, -0.0000000000000016, - +0.3997788067656795, 0.0000000000000018, 0.2084878025028327, -0.0000 +000000000011 ], [ -0.0000000000000000, 0.0018740215138967, -0.0000000000000000, +0.0209143122794822, -0.0000000000000002, 0.0937250582686831, -0.0000 +000000000006, 0.2263227689510601, -0.0000000000000010, 0.2136068393 +701215, -0.0000000000000003, -0.0343030148937000, 0.0000000000000006 +, -0.2374515116591406, 0.0000000000000009, 0.1543298788071321, -0.0 +000000000000014, 0.0484106488830808, 0.0000000000000011, -0.0556695 +757276321, -0.0000000000000009, -0.1585122753165241, 0.0000000000000 +015, 0.4164529081832608, -0.0000000000000016, -0.5455319030422324, +0.0000000000000021, 0.4850082730133928, -0.0000000000000015, -0.2751 +494973249398 ], [ 0.0003983422749079, -0.0000000000000003, 0.0084162036010590, - +0.0000000000000008, 0.0612865660082999, 0.0000000000000003, 0.2247 +020891769621, 0.0000000000000001, 0.4305239272210992, -0.0000000000 +000002, 0.3202309758153931, 0.0000000000000001, -0.1918139117119362 +, -0.0000000000000002, -0.3095871293039516, -0.0000000000000002, 0.2 +464518281395873, 0.0000000000000006, 0.1656482308020451, -0.0000000 +000000006, -0.3359183916702893, 0.0000000000000000, 0.1094739661795 +629, 0.0000000000000012, 0.2430290521749586, -0.0000000000000017, - +0.4099538699310810, 0.0000000000000015, 0.2915777578643249, -0.0000 +000000000009 ], [ 0.0000000000000000, 0.0014954639775851, 0.0000000000000000, +0.0179685965171856, 0.0000000000000000, 0.0988989956441026, 0.0000 +000000000001, 0.2952876521886211, 0.0000000000000003, 0.4627556007 +193223, 0.0000000000000004, 0.2320927274343102, 0.0000000000000000 +, -0.2873578852921854, -0.0000000000000001, -0.2359945232765174, 0.0 +000000000000001, 0.3116801240310712, 0.0000000000000003, 0.0798333 +562246646, -0.0000000000000004, -0.3417288746164391, 0.0000000000000 +003, 0.1906004227513239, -0.0000000000000001, 0.1610665397841304, - +0.0000000000000002, -0.3676708309232274, 0.0000000000000002, 0.2804 +853923818191 ], [ 0.0001084747877321, 0.0000000000000000, 0.0027208960217152, +0.0000000000000002, 0.0242704434475306, -0.0000000000000001, 0.1153 +670170379691, -0.0000000000000005, 0.3193789054222693, -0.0000000000 +000001, 0.4908523839275092, 0.0000000000000001, 0.2761691414257316 +, 0.0000000000000000, -0.2600143419201901, 0.0000000000000001, -0.3 +068704363306086, -0.0000000000000002, 0.2542843527027897, 0.0000000 +000000000, 0.2086903757180524, -0.0000000000000002, -0.3365315876512 +961, -0.0000000000000002, 0.0165372489897550, 0.0000000000000002, +0.3099014215132993, -0.0000000000000001, -0.2955175636216057, 0.0000 +000000000000 ], [ -0.0000000000000000, -0.0003844645253044, -0.0000000000000000, - +0.0055700399702677, -0.0000000000000000, -0.0384100619532071, -0.0000 +000000000000, -0.1533025985895169, -0.0000000000000000, -0.3681698917 +672083, -0.0000000000000001, -0.4889286723129618, -0.0000000000000002 +, -0.1942962641619352, -0.0000000000000001, 0.3158440934858354, -0.0 +000000000000001, 0.2496900204706467, -0.0000000000000001, -0.2959512 +116085838, -0.0000000000000000, -0.1552508901502876, -0.0000000000000 +001, 0.3427579648786467, -0.0000000000000002, -0.0541435546335990, +0.0000000000000000, -0.2876031326588631, -0.0000000000000001, 0.2927 +760031123848 ], [ 0.0000181563100889, 0.0000000000000002, 0.0005488425504935, - +0.0000000000000000, 0.0060688055327925, -0.0000000000000002, 0.0372 +631786179999, -0.0000000000000002, 0.1425926143202678, -0.0000000000 +000000, 0.3478710011662555, 0.0000000000000002, 0.5076314191518138 +, 0.0000000000000006, 0.3123574515561076, 0.0000000000000001, -0.2 +091284023204721, -0.0000000000000002, -0.3689178831666572, -0.0000000 +000000000, 0.1344053015043881, 0.0000000000000001, 0.3299092963194 +629, 0.0000000000000004, -0.2082278951025315, -0.0000000000000003, - +0.2240489250735314, -0.0000000000000001, 0.3188632967650468, 0.0000 +000000000002 ], [ -0.0000000000000000, 0.0000646482239263, -0.0000000000000000, +0.0011385375166878, -0.0000000000000000, 0.0098338922987181, -0.0000 +000000000000, 0.0513935599025939, -0.0000000000000001, 0.1741934371 +091206, -0.0000000000000002, 0.3836429445985159, -0.0000000000000004 +, 0.5045604175490942, -0.0000000000000004, 0.2522551752686503, 0.0 +000000000000001, -0.2579441025360375, 0.0000000000000004, -0.3397702 +320139469, 0.0000000000000003, 0.1752821352580565, -0.0000000000000 +001, 0.3071408379256653, 0.0000000000000001, -0.2279977492913131, +0.0000000000000002, -0.2051227648591225, -0.0000000000000004, 0.3168 +989287342151 ], [ 0.0000019661699240, 0.0000000000000002, 0.0000719533317298, +0.0000000000000001, 0.0009846334801556, -0.0000000000000002, 0.0077 +074332169402, -0.0000000000000004, 0.0392493847315142, 0.0000000000 +000002, 0.1365860267496776, 0.0000000000000000, 0.3260488848298075 +, -0.0000000000000001, 0.5075095625005354, 0.0000000000000000, 0.4 +189127624432365, -0.0000000000000003, -0.0412751650984030, -0.0000000 +000000002, -0.4061413387987063, 0.0000000000000002, -0.1232820067450 +982, 0.0000000000000001, 0.3525839817655427, -0.0000000000000002, +0.1125603524749182, -0.0000000000000002, -0.3486308267332468, 0.0000 +000000000004 ], [ -0.0000000000000000, -0.0000071522511841, -0.0000000000000000, - +0.0001531738843782, -0.0000000000000000, -0.0016457996800569, -0.0000 +000000000000, -0.0110351632854802, -0.0000000000000000, -0.0502042359 +369793, -0.0000000000000001, -0.1598827125229744, -0.0000000000000002 +, -0.3541055995816644, -0.0000000000000003, -0.5131002961113091, -0.0 +000000000000004, -0.3827211429896542, -0.0000000000000001, 0.0868953 +534697583, 0.0000000000000002, 0.4060663544932935, 0.0000000000000 +002, 0.0906849061585278, 0.0000000000000001, -0.3565218256839784, +0.0000000000000002, -0.0954798894669647, -0.0000000000000000, 0.3460 +718461864576 ], [ -0.0000001292972631, -0.0000000000000001, -0.0000057407224638, +0.0000000000000000, -0.0000969677496746, 0.0000000000000000, -0.0009 +576391156081, -0.0000000000000002, -0.0063336604552633, 0.0000000000 +000000, -0.0298194086989161, 0.0000000000000001, -0.1025898937974792 +, 0.0000000000000004, -0.2581306279126550, 0.0000000000000004, -0.4 +608777058952639, 0.0000000000000003, -0.5289025115880573, 0.0000000 +000000000, -0.2501979027713430, -0.0000000000000003, 0.2459229288491 +326, -0.0000000000000000, 0.3976890721949536, 0.0000000000000001, - +0.0441899989974140, -0.0000000000000001, -0.3828591066315501, 0.0000 +000000000001 ], [ 0.0000000000000000, 0.0000004836289753, 0.0000000000000000, +0.0000125935691119, 0.0000000000000000, 0.0001674328686760, 0.0000 +000000000000, 0.0014204630187498, 0.0000000000000000, 0.0084233556 +059741, 0.0000000000000000, 0.0364726872642141, 0.0000000000000000 +, 0.1173353239240527, 0.0000000000000001, 0.2791623093846674, 0.0 +000000000000001, 0.4743110004921181, 0.0000000000000002, 0.5168194 +754141317, 0.0000000000000002, 0.2172212810095154, 0.0000000000000 +001, -0.2660675030932704, 0.0000000000000000, -0.3868615369372250, - +0.0000000000000001, 0.0582093189941330, 0.0000000000000002, 0.3792 +058820414961 ], [ 0.0000000043467313, -0.0000000000000002, 0.0000002354338414, +0.0000000000000001, 0.0000049191205605, -0.0000000000000001, 0.0000 +611103982443, 0.0000000000000001, 0.0005191484660093, 0.0000000000 +000002, 0.0032251377193584, -0.0000000000000002, 0.0151840473609755 +, -0.0000000000000001, 0.0551258405915315, 0.0000000000000001, 0.1 +547931322781031, 0.0000000000000001, 0.3318050095086971, -0.0000000 +000000004, 0.5216362528850688, -0.0000000000000001, 0.5386522451902 +931, -0.0000000000000004, 0.2190409351878887, 0.0000000000000002, - +0.2724800121518238, 0.0000000000000002, -0.4221250094454858, 0.0000 +000000000001 ], [ -0.0000000000000000, -0.0000000167699136, -0.0000000000000000, - +0.0000005331602679, -0.0000000000000000, -0.0000087760999773, -0.0000 +000000000000, -0.0000937543740401, -0.0000000000000000, -0.0007150017 +363018, -0.0000000000000000, -0.0040915831845336, -0.0000000000000000 +, -0.0180530719106190, -0.0000000000000000, -0.0621905012332527, -0.0 +000000000000000, -0.1672502296997740, -0.0000000000000001, -0.3457819 +876105404, -0.0000000000000002, -0.5268406404622072, -0.0000000000000 +002, -0.5273801655434678, -0.0000000000000002, -0.1998433947965230, +0.0000000000000000, 0.2805004874860440, 0.0000000000000003, 0.4170 +641909080779 ], [ 0.0000000000469012, 0.0000000000000001, 0.0000000031569888, - +0.0000000000000001, 0.0000000829508766, 0.0000000000000000, 0.0000 +013139183774, -0.0000000000000001, 0.0000144662736142, 0.0000000000 +000001, 0.0001187954144757, -0.0000000000000001, 0.0007576595856397 +, 0.0000000000000002, 0.0038457059058298, -0.0000000000000001, 0.0 +157544770583618, 0.0000000000000002, 0.0524034914224598, -0.0000000 +000000002, 0.1412730634268711, 0.0000000000000000, 0.3051191205191 +895, -0.0000000000000000, 0.5135323458897670, 0.0000000000000002, +0.6319248579965772, -0.0000000000000001, 0.4699894042726668, -0.0000 +000000000000 ], [ -0.0000000000000000, 0.0000000001872384, -0.0000000000000000, +0.0000000073974097, -0.0000000000000000, 0.0000001531161950, -0.0000 +000000000000, 0.0000020854332860, -0.0000000000000000, 0.0000206106 +783438, -0.0000000000000000, 0.0001558996179038, -0.0000000000000000 +, 0.0009318666076831, -0.0000000000000000, 0.0044889011562547, -0.0 +000000000000000, 0.0176207946824076, -0.0000000000000000, 0.0565953 +635430333, -0.0000000000000000, 0.1482728021860708, -0.0000000000000 +000, 0.3129386149972143, -0.0000000000000000, 0.5172629611893457, - +0.0000000000000001, 0.6280792712999990, -0.0000000000000001, 0.4631 +473700646182 ], ] ); # matrix T de los vectores del doblepozo my $vect = transpose( $vec ); # matrix con los vectores en la columna # <n|V|m> my $V = $vec x $X x $vect; my $step = 0.1; my $hbar = 1; #print Vnm( 0,1 ); #print Vnm( 1,0 ); my @Em = ( -3.49090786, -3.48609059, -0.94249804, + -0.72223315, 0.84486159, 1.98334101, 3.52168993, 5.19562490, + 7.00900149, 8.96758961, 11.0614444444542760, 13.1282317263938650, 15.4597663541535190, + 18.2923955058715430, 19.5751133106800170, 21.3254642902799140, 27.3060148356095880, 33.6153274807702470, + 48.2864949409823790, 58.1657460989797170, 83.0782032408711330, 97.3475523518670660, 137.5307666823436800, +157.3985331875067300, 221.5161226004345300, 248.6116702653141900, 353.3740736965299900, 390.0680354316574500, +577.9792266930371600, 628.4681868621187300, ); my $w = $Em[ 1 ] - $Em[ 0 ]; sub Vnm { my ( $x1, $x2 ) = @_; return $V->range( [ $x1, $x2 ] ); } my @c = ( 1, 0, 0, 0 ); #INITIAL CONDITIONS #@c = F = ( F0, F1, F2, F3 ) sub F { my ( $m, $t, @c ) = @_; my $f = 0; for my $n ( 0 .. 3 ) { my $a = Vnm( $n, $m ) * exp( -( i ) * ( $Em[ $m ] - $Em[ $n ] +) * ( $t / $hbar ) ); if ( $n != $m ) { $f += $a * ( -( i ) * ( -$eprim ) * cos( $w * $t ) * $c[ $ +n ] ); } } return $f; } sub RK4_c { my ( $m, $t, @c ) = @_; my $k1 = sub { my ( $t, @c ) = @_; return $step * F( $m, $t, @c ); }; my $k2 = sub { my ( $t, @c ) = @_; return $step * F( $m, ( $t + $step / 2 ), ( @c + ( $k1->( $t ) + / 2 ) ) ); }; my $k3 = sub { my ( $t, @c ) = @_; return $step * F( $m, ( $t + $step / 2 ), ( @c + ( $k2->( $t ) + / 2 ) ) ); }; my $k4 = sub { my ( $t, @c ) = @_; return $step * F( $m, ( $t + $step ), ( @c + $k3->( $t ) + ) ); }; return $c[ $m ] + ( 1 / 6 ) * ( $k1->( $t, @c ) + 2 * ( $k2->( $t, + @c ) + $k3->( $t, @c ) ) + $k4->( $t, @c ) ); } open my $FILE, '>', 'C0_V1W01p2.dat'; for ( my $t = 0; $t < 2500; $t += $step ) { #print " @c $t \n"; #print abs( $c[ 0 ] ) * abs( $c[ 0 ] ), "\n"; my ( $x, $b, $s, $d ) = map abs( RK4_c( $_, $t, @c ) ) ** 2, 0 .. +3; print $FILE "$x $b $s $d $t\n"; } close $FILE;

In reply to Re: RK4 for a vectorial function by jwkrahn
in thread RK4 for a vectorial function by Lucero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-05-23 23:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?