### Related

##### set_random_state

? set_random_state;

Calculate

##### set_random_state

? set_random_state;

Calculate

### set_random_state

Run Example
```(%i1)build_info();

Maxima version: 5.21.1
Maxima build date: 7:25 9/18/2010
Host type: x86_64-unknown-linux-gnu
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.7

(%o1)
(%i2) /* compute angles for intrinsic Tait-Bryan angles * on axes y-z'-x'', conventionally named pitch, yaw, and roll * (following terminology on Wikipedia page for "Euler angles") * via method expounded by G. Slabaugh: * http://www.staff.city.ac.uk/~sbbh653/publications/euler.pdf * * Argument R is a 3x3 rotation matrix. * Return value is a list of two triples, [[pitch1, yaw1, roll1], [pitch2, yaw2, roll2]], * because there are always two solutions. */intrinsic_yzx (R) :=  if equal (R[2, 1], 1) or equal (R[2, 1], -1)    then intrinsic_yzx_yaw_pi2 (R)    else block ([pitch1, pitch2, yaw1, yaw2, roll1, roll2],      yaw1 : asin (R[2, 1]),       yaw2 : %pi - yaw1,      pitch1 : atan2 (-R[3, 1]/cos(yaw1), R[1, 1]/cos(yaw1)),      pitch2 : atan2 (-R[3, 1]/cos(yaw2), R[1, 1]/cos(yaw2)),      roll1 : atan2 (-R[2, 3]/cos(yaw1), R[2, 2]/cos(yaw1)),      roll2 : atan2 (-R[2, 3]/cos(yaw2), R[2, 2]/cos(yaw2)),      [[pitch1, yaw1, roll1], [pitch2, yaw2, roll2]]);
(%o2) intrinsic_yzx(R) := if equal(R    , 1) or equal(R    , - 1)
2, 1               2, 1
then intrinsic_yzx_yaw_pi2(R) else block([pitch1, pitch2, yaw1, yaw2, roll1,
roll2], yaw1 : asin(R    ), yaw2 : %pi - yaw1,
2, 1
- R         R                         - R         R
3, 1      1, 1                        3, 1      1, 1
pitch1 : atan2(---------, ---------), pitch2 : atan2(---------, ---------),
cos(yaw1)  cos(yaw1)                  cos(yaw2)  cos(yaw2)
- R         R                        - R         R
2, 3      2, 2                       2, 3      2, 2
roll1 : atan2(---------, ---------), roll2 : atan2(---------, ---------),
cos(yaw1)  cos(yaw1)                 cos(yaw2)  cos(yaw2)
[[pitch1, yaw1, roll1], [pitch2, yaw2, roll2]])
(%i3) intrinsic_yzx_yaw_pi2 (R) :=  block ([pitch1, pitch2, yaw1, yaw2, roll1, roll2],    yaw1 : %pi/2,    roll1 : 0, /* could be anything */    pitch1 : -roll1 + atan2 (R[3, 2], R[3, 3]),    yaw2 : -%pi/2,    roll2 : 0, /* could be anything */    pitch2 : roll2 + atan2 (R[1, 3], R[1, 2]),    [[pitch1, yaw1, roll1], [pitch2, yaw2, roll2]]);
(%o3) intrinsic_yzx_yaw_pi2(R) := block([pitch1, pitch2, yaw1, yaw2, roll1,
%pi
roll2], yaw1 : ---, roll1 : 0, pitch1 : - roll1 + atan2(R    , R    ),
2                                        3, 2   3, 3
- %pi
yaw2 : -----, roll2 : 0, pitch2 : roll2 + atan2(R    , R    ),
2                                       1, 3   1, 2
[[pitch1, yaw1, roll1], [pitch2, yaw2, roll2]])
(%i4) set_random_state (make_random_state (1));
(%o4)                                done
(%i5) random_3d_unit () := (random_3d (), %%/norm(%%));
%%
(%o5)             random_3d_unit() := (random_3d(), --------)
norm(%%)
(%i6) random_3d () := makelist (random (10), i, 1, 3);
(%o6)            random_3d() := makelist(random(10), i, 1, 3)
(%i7) norm (v) := sqrt (lsum (x^2, x, v));
2
(%o7)                   norm(v) := sqrt(lsum(x , x, v))
(%i8) u : random_3d_unit ();
5          9          4
(%o8)                  [---------, ---------, ---------]
sqrt(122)  sqrt(122)  sqrt(122)
(%i9) v : random_3d_unit ();
8         3         3
(%o9)                   [--------, --------, --------]
sqrt(82)  sqrt(82)  sqrt(82)
(%i10) R(a,b):= block ([v, s, c], v:cross(a,b), s:norm(v), c:dot(a,b), ident(length(a)) + ssc(v) + (ssc(v).ssc(v))*(1 - c)/s^2, ratsimp(%%));
(%o10) R(a, b) := block([v, s, c], v : cross(a, b), s : norm(v),
(ssc(v) . ssc(v)) (1 - c)
c : dot(a, b), ident(length(a)) + ssc(v) + -------------------------,
2
s
ratsimp(%%))
(%i11) cross(a,b) := [a[2]*b[3]-b[2]*a[3], -(a[1]*b[3]-b[1]*a[3]), a[1]*b[2]-b[1]*a[2]];
(%o11) cross(a, b) := [a  b  - b  a , - (a  b  - b  a ), a  b  - b  a ]
2  3    2  3      1  3    1  3    1  2    1  2
(%i12) norm(v):= sqrt(v[1]^2 + v[2]^2 + v[3]^2);
2    2    2
(%o12)                   norm(v) := sqrt(v  + v  + v )
1    2    3
(%i13) dot(a,b):= a[1]*b[1]+a[2]*b[2]+a[3]*b[3];
(%o13)                dot(a, b) := a  b  + a  b  + a  b
1  1    2  2    3  3
(%i14) ssc(v) := matrix ([0, -v[3], v[2]], [v[3], 0, -v[1]], [-v[2], v[1], 0]);
(%o14)   ssc(v) := matrix([0, - v , v ], [v , 0, - v ], [- v , v , 0])
3   2     3        1       2   1
(%i15) Ruv : float (R (u, v));
[  0.80240796270139   0.58412740488141   0.12221553199131  ]
[                                                          ]
(%o15)   [ - 0.5556446634958   0.80598226750272  - 0.20408721762966 ]
[                                                          ]
[ - 0.21771648840189  0.09585280036434   0.97129386456431  ]
(%i16) intrinsic_yzx (Ruv);

rat: replaced -1.5556446634958 by -7758/4987 = -1.55564467615801

rat: replaced 0.4443553365042 by 4987/11223 = 0.44435534170899
(%o16) [[0.26495004690786, - 0.58913814199809, 0.24800273610235],
[- 2.876642606681936, %pi + 0.58913814199809, - 2.89358991748744]]
(%i17) ```
Run Example
```load(vect);
(%o1)           /usr/share/maxima/5.21.1/share/vector/vect.mac
(%i2) f(x):=random(x)-x;
(%o2)                        f(x) := random(x) - x
(%i3) set_random_state(make_random_state(true));
(%o3)                                done
(%i4) a:[f(5),f(5),f(5)];
(%o4)                           [- 4, - 4, - 2]
(%i5) set_random_state(make_random_state(true));
(%o5)                                done
(%i6) b:[f(5),f(5),f(5)];
(%o6)                           [- 1, - 5, - 4]
(%i7) c:express(a~b);
(%o7)                            [6, - 14, 16]
(%i8) ```
Run Example
```s1:make_random_state (65);
(%o1) #S(RANDOM-STATE STATE
#(0 2567483615 624 65 1844044454 774032101 4203845980 203315583
207046176 4258646694 3041804320 2166325106 2293249849
2712755537 1194343626 874356515 2278458332 1545458852
3138662952 3036038306 2420290353 110886449 3052044904
2385915366 2334859017 2028806765 502161587 2310074807
4229708162 2423240959 2432590060 1690147842 3210815564
2181604580 2012357853 3125167852 1915836935 1959770752
3326778888 542195067 3427865772 1691865137 954127127 679581499
1538014576 2985080511 2606382524 1842809378 1966652156
1952328447 2736448613 1890073555 3038837771 3441639615
3786483295 3035586176 3918650239 2237985826 3562631383
712439772 43550213 1812499763 659388149 2464943077 282087776
3613162270 254416816 1746438320 2611717910 1219403558
3995183526 915684189 3083546870 2265506954 2827416047
1311786953 99506737 145018527 1441897478 1828933135 3514124755
745959262 2682601061 3970416115 2489540609 2645261441
2782870274 2225424212 62663491 2671307973 3046959578 620026512
1468091177 2773684002 2528974843 1581102745 1396204117
573161346 3867353257 3135036786 968117649 2359047063 1447958316
1970354725 3032822937 2939270285 4230333394 929569501
2323504794 904931938 1327311637 1880863568 555423842 2456490264
2149231025 4147822351 1136577581 4206762446 3647595348
1557217479 3886187667 3154074950 293941323 644952335 1767006820
4041989971 583068427 87203539 2143065276 506123279 4073369962
1757949933 1477719197 3496230414 186413220 3741070648
1251644364 2930771303 3759681120 1662142615 589883831
1547183293 3203603127 2250729205 140955392 4267092878
3873121328 3694760879 1282559853 294527534 1419778745
1820263212 3641333334 1637518623 3142630253 254892643
2760680616 1749152172 68480732 672790888 1787825829 3106376530
3310864175 3614187772 1447722044 160082355 543866690 4249208750
3055443174 3555502746 2044342276 1122672545 3546127049
4014615644 1687902502 3088124943 2391258830 3958524714
451909852 3612937084 2176942284 753405944 4158784907 1205466972
4259994982 3275024015 2970870259 1515789773 917433909 267475107
2736534538 1043386340 2277444017 2457116509 2699409466
331327192 181300217 3137854207 3073756052 3947272434 1967804634
2777946669 549092434 3025727266 3371071593 3882630300
4135453318 3702729797 3008097899 812269883 2742112278
3223014580 3017028612 1991884080 366861864 1334054556
2906048966 3706945322 1094524164 1489445073 1020216041
150149063 974315870 3584047346 1095135474 232889277 881170288
2597302288 2712148475 2131198239 1373700025 1420188796
2961990454 1860565098 3248047646 2395549529 2939445968
1951096772 4066391716 264630223 152462488 1909655782 2320966418
3952371264 1813722208 2422903863 1825560284 1141312293
431598121 1970213923 2877760609 3246348039 2380953997 527990117
4016539348 1055015631 212738984 190904902 3273405597 714821974
1864900079 2354720232 2609666133 2550557271 767717774 526240780
914877891 104016375 761642620 3782771702 1792880052 581690997
1431931446 2462840769 476388350 1003551302 3477877935
2448741614 4261301807 6186096 2819461445 2097828121 840947599
164926339 4033105608 1363851825 1735337483 2356894990 214639321
1102700987 205035905 3137444357 3443557604 2548371269
3783067430 2905186237 2317500032 1619278960 731599548
3870441812 3870054268 894074181 1817205348 3503732741
3713782155 2467525590 175450067 3981288047 746643917 810208275
2906501042 1781236132 1393456206 52112225 3751151484 1219292499
1282966675 3799806164 3176961294 1688091384 147555962
2291751264 3204691689 2110254839 4017942095 3957633342
146707284 3881047400 4254054268 2338282849 1464783958 605902491
3039371120 1865116484 594296964 1540888928 2138959250 869754701
157218736 2329209280 4083616987 2809113226 3674804475
1534094124 653287190 3780266756 4040120858 4222938677
1834410663 3709616856 2481624258 4133974300 3190962584
1977230624 752242788 3293527252 951259444 2605096678 2518725975
2370111725 3230494384 854554885 2875288928 380082962 2006634883
2629909428 2871719481 626375091 857214988 2305344042 1968440119
509029310 4177457511 1971306982 2071797910 1190112263
2076710355 442236752 1562217479 3904992726 1899330434
3989296937 1545821965 4045794616 3498585284 1394682625
3105421439 3946835921 776929627 4200742249 3246782037 252196722
4027048831 1950227826 1818831590 2915339691 3925497398
4284047731 2105041595 409632494 2155049843 1248527907 628072185
3857447629 3270783703 1834451766 3275765062 4122604237 15665883
4212882685 1521369037 3581368596 979662508 2614681462
2555461215 2197315917 2503650504 941901648 1135211567
3137074630 71949301 2542593611 1238560112 727722041 3087360290
2734256966 2717245307 2733108581 1432209996 3814655755
544804819 201337579 594916196 304892962 1294351641 2993681448
3036401731 1200813143 3625348513 2566059166 3708157761
1002834112 3440391543 4197198972 582387412 2146871134 595255606
2994389514 3397179109 2592858236 533004661 1555313129
1059379785 1717186959 3908865225 612476790 637483347 681839237
939283776 1961681928 4022192726 2340115027 1928058048
3375184625 1208075591 1211059308 3716840912 4190015759
2334304141 1497408573 2617829759 1927480613 625822985
4244125539 2804955831 3160737857 3810336584 2940829041
1850084154 809632547 934148524 1978961594 888890534 949325150
3778680311 2069249830 4276341574 579477789 2952959830
1733143050 2616261438 2871671956 305147671 4090946813
2672183329 810169019 159979700 3191543026 2115220639 3787510342
494724138 1837531268 3497714540 272311231 2611958608 520143696
3137527943 2448212849 589736280 1346955698 2579103898
1423676916 1939163302 3998747361 3401400105 3046991762
2020994513 3816498450 3588405944 3078537419 1269604946
2990503877 2224341642 2625866160 7575363 1885506169 2084756323
628490678 3262321883 4285977414 1137985864 720895197 3493071426
2982926007 1984271484 2975169637 2434676152 1539423864
598599892 4077015484 3991042420 2476449037 584777734 2073311866
2451826596 1017920668 2493999019 1579440333 359675549
1019908883 1847997346 338271347 71911044 2235660346 2243061823
3470182201 1978705419 320003612 2182258487 4278136597
3162135515 3864813515 1345049623 711226590 1446964167
2909404496 2829047181 994167455 884804080 2121686502 1111797082
123410975 1925506932 1472196707 1091324645 2049544752 486140050
537716184 4110370935 833203204 3373990869 797969328 1810222771
1277546622 2398632800 929358320 1162253815 4241740374
3077864146 3529360986 647226472 2087503700 2632590294
2690160882 459065599 2250556907 1338689598 233028141 1823836948
3030458013 1733111312 2106673163 2049230921 3114897088
3164153571 1516356127 4031096369 3033093654 3708529729 43534952
1858012519 420133278 1508035511 796444464 261048403 3481335331
477641989 1530577503 1757740925 248916564 259107213 175070219
3732813250 920027281 493180066 2075334744 3693035148))
(%i2) set_random_state (s1);
(%o2)                                done
(%i3) a:1+random(3);
(%o3)                                  1
(%i4) b1:1+random(3);
(%o4)                                  2
(%i5) n1:1+random(3);
(%o5)                                  3
(%i6) k1:1+random(3);
(%o6)                                  2
(%i7) c1:n1^2-a*b1;
(%o7)                                  7
(%i8) d1:b1-k1;
(%o8)                                  0
(%i9) e1:n1^2-d1*a;
(%o9)                                  9
(%i10) b2:1+random(3);
(%o10)                                 3
(%i11) n2:1+random(3);
(%o11)                                 1
(%i12) k2:1+random(3);
(%o12)                                 1
(%i13) c2:n2^2-a*b2;
(%o13)                                - 2
(%i14) d2:b2-k2;
(%o14)                                 2
(%i15) e2:n2^2-d2*a;
(%o15)                                - 1
(%i16) f:(sqrt(b1*x+c1)-sqrt(d1*x+e1))/(sqrt(b2*x+c2)-sqrt(d2*x+e2));
sqrt(2 x + 7) - 3
(%o16)                   -----------------------------
sqrt(3 x - 2) - sqrt(2 x - 1)
(%i17) l:limit(f,x,a);
2
(%o17)                                 -
3
(%i18) ```

### Related Help

Help for Set_random_state