Sponsored links: Algebra eBooks
 

Related

printf

x: 101 + 105 * (2**32...

printf(true,"~x",123);

Calculate

printf

printf(false, "~x", 1...

Calculate

printf

/* Definintion von zw...

a:[false,true,false,t...

b:[false,false,true,t...

Calculate

printf

x: 101 + 105 * (2**32...

printf(true,"~x",123);

Calculate

printf

pout:175000;

Uout:2000;

Iout:pout/Uout;

Calculate

printf

printf(false,"~x",803...

Calculate

printf

printf(false,"~x",803...

Calculate

printf

/* Definintion von zw...

b:[false,false,true,t...

eq2: /* Definition ei...

Calculate

printf

Run Example
(%i1)M: matrix( [2,1,5], [1,2,6]);
                                  [ 2  1  5 ]
(%o1)                             [         ]
                                  [ 1  2  6 ]
(%i2) A:submatrix(M,3);
                                   [ 2  1 ]
(%o2)                              [      ]
                                   [ 1  2 ]
(%i3) B:submatrix(submatrix(M,1),1);
                                     [ 5 ]
(%o3)                                [   ]
                                     [ 6 ]
(%i4) X:(invert(A).B);
                                     [ 4 ]
                                     [ - ]
                                     [ 3 ]
(%o4)                                [   ]
                                     [ 7 ]
                                     [ - ]
                                     [ 3 ]
(%i5) printf(true, "x = ~a % y = ~a", X[1,1],X[2,1]);
x = 4/3 % y = 7/3(%o5)                                false
(%i6) 
Run Example
f(a):= a[1] + a[2]*(2**32) + a[3] *(2**(32*2)) + a[4] *(2**(32*3)) + a[5] *(2**(32*4)) + a[6] *(2**(32*5));
                         32       32 2       32 3       32 4       32 5
(%o1)   f(a) := a  + a  2   + a  2     + a  2     + a  2     + a  2
                 1    2        3          4          5          6
(%i2) f2(a):= f(a[1]) + f(a[2])*(2**(32*6*1))+ f(a[2])*(2**(32*6*3));
                                        32 6 1          32 6 3
(%o2)           f2(a) := f(a ) + f(a ) 2       + f(a ) 2
                            1       2               2
(%i3) b:[[1,3408,1,1507328,0,0],[1,0,1,1507328,0,0],[1,2204,1,0,0,0]];
(%o3) [[1, 3408, 1, 1507328, 0, 0], [1, 0, 1, 1507328, 0, 0], 
                                                         [1, 2204, 1, 0, 0, 0]]
(%i4) printf(true,"~x",f(b[1]));
1700000000000100000d5000000001(%o4)                                false
(%i5) printf(true,"~x",f(b[2]));
170000000000010000000000000001(%o5)                                false
(%i6) printf(true,"~x",f(b[3]));
10000089c00000001(%o6)                                false
(%i7) 
Run Example
CoinTosses(n, [Stringp]):=block([ans:"", m:n], Random(n):=block([m:n, ans], ans:random(m)), if(not(emptyp(Stringp))) then block(for i in subst([0=H, 1=T], makelist(Random(2), n, 1, m)) do ans:concat(ans, i)) else subst([0=H, 1=T], makelist(Random(2), n, 1, m)));
(%o1) CoinTosses(n, [Stringp]) := block([ans : "", m : n], 
Random(n) := block([m : n, ans], ans : random(m)), 
if not emptyp(Stringp) then block(for i in subst([0 = H, 1 = T], 
makelist(Random(2), n, 1, m)) do ans : concat(ans, i))
 else subst([0 = H, 1 = T], makelist(Random(2), n, 1, m)))
(%i2) CountHeadsTails(list):=block([Hs:0, Ts:0, x], for x in list do (if(x=H) then Hs:Hs+1 else if(x=T) then Ts:Ts+1), printf(false, "Hs: ~a        Ts: ~a", Hs, Ts));
(%o2) CountHeadsTails(list) := block([Hs : 0, Ts : 0, x], 
for x in list do if x = H then Hs : Hs + 1 else (if x = T then Ts : Ts + 1), 
printf(false, "Hs: ~a        Ts: ~a", Hs, Ts))
(%i3) throws:CoinTosses(20);
(%o3)    [H, H, H, T, H, T, T, T, H, T, T, T, H, H, T, H, T, H, T, H]
(%i4) CountHeadsTails(throws);
(%o4)                        Hs: 10        Ts: 10
(%i5) 

Related Help

Help for Printf