Sponsored links: Algebra eBooks
 

Related

lmax-max

lmax([2,3]);

Calculate

lmax-max-solve

lmax([solve(x=2,x),so...

Calculate

lmax-max-solve

lmax([solve(x=2,x),so...

Calculate

lmax-max

lmax([2,3]);

Calculate

lmax

Run Example
(%i1)nrm1(x) := block([ms],ms : matrix_size(x), lmax(makelist(sum(abs(x[i, j]), i, 1,ms[1]), j, 1,ms[2])));
(%o1) nrm1(x) := block([ms], ms : matrix_size(x), 
                            lmax(makelist(sum(!x    !, i, 1, ms ), j, 1, ms )))
                                              ! i, j!          1           2
(%i2) preob(m) := block([s], n : length(m),(s : 1, for i : 1 while ((i <
 n + 1) and (2*abs(m[i, i])) >
 sum(abs(m[i, j]), j, 1, n)) do s : i),if s = n then "eSTX PREOBLADANIE DIG. \L."else "nET PREOBLADANIQ DIAG. \L.");
(%o2) preob(m) := block([s], n : length(m), 
(s : 1, for i while (i < n + 1) and (2 !m    ! > sum(!m    !, j, 1, n)) 
                                       ! i, i!       ! i, j!
do s : i), if s = n then "eSTX PREOBLADANIE DIG. L."
 else "nET PREOBLADANIQ DIAG. L.")
(%i3) 
Run Example
cut(l,m,k,h,[p]):=block( cut_segment(l, m, k, [p]):=block( elimn(l,index):=block([ans, indi:map("=", index, makelist(0, n, 1, length(index)))], ans:subst([0="_"], l*subst(indi, makelist(n, n, 1, length(l)))/makelist(n, n, 1, length(l))), if(not(emptyp(p))) then return(delete("_", ans)) else return(ans)), elimn(l, makelist(n, n, m, k))), cut_flanks(l, m, k, [p]):=block( elimn(l,index):=block([ans, indi:map("=", index, makelist(0, n, 1, length(index)))], ans:subst([0="_"], l*map(lambda([x], if(x=1) then 0 else 1), subst(indi, makelist(n, n, 1, length(l)))/makelist(n, n, 1, length(l)))), if(not(emptyp(p))) then return(delete("_", ans)) else return(ans)), elimn(l, makelist(n, n, m, k))), if(h=s and emptyp(p)) then return(cut_flanks(l,m,k)) else if(h=s and not(emptyp(p))) then return(cut_flanks(l,m,k,t)) else if(h=f and emptyp(p)) then return(cut_segment(l,m,k)) else if(h=f and not(emptyp(p))) then return(cut_segment(l,m,k,t)));
(%o1) cut(l, m, k, h, [p]) := block(cut_segment(l, m, k, [p]) := 
block(elimn(l, index) := block([ans, indi : 
map("=", index, makelist(0, n, 1, length(index)))], 
                       l subst(indi, makelist(n, n, 1, length(l)))
ans : subst([0 = "_"], -------------------------------------------), 
                              makelist(n, n, 1, length(l))
if not emptyp(p) then return(delete("_", ans)) else return(ans)), 
elimn(l, makelist(n, n, m, k))), cut_flanks(l, m, k, [p]) := 
block(elimn(l, index) := block([ans, indi : 
map("=", index, makelist(0, n, 1, length(index)))], 
ans : subst([0 = "_"], l map(lambda([x], if x = 1 then 0 else 1), 
subst(indi, makelist(n, n, 1, length(l)))
-----------------------------------------)), 
      makelist(n, n, 1, length(l))
if not emptyp(p) then return(delete("_", ans)) else return(ans)), 
elimn(l, makelist(n, n, m, k))), if (h = s) and emptyp(p)
 then return(cut_flanks(l, m, k)) else (if (h = s) and (not emptyp(p))
 then return(cut_flanks(l, m, k, t)) else (if (h = f) and emptyp(p)
 then return(cut_segment(l, m, k)) else (if (h = f) and (not emptyp(p))
 then return(cut_segment(l, m, k, t))))))
(%i2) find(s,l,h,[p]):=block([ans:[], rep:[], final:[], parts:makelist(part(l, makelist(n, n, 1+m, length(s)+m)), m, 0, length(l)-length(s)), res, count:0, pos:[]], for n:1 thru length(parts) do  (ans:append(ans, [map(lambda([x], if(is(x)) then lhs(x)), map("=", part(parts, n), s))])), for i in ans do (if(freeof(false, i)) then (res:i)), count:length(delete([], map(lambda([x], if(freeof(false, x)) then x else []), ans))), for i:1 thru length(ans) do (if(freeof(false, ans[i])) then pos:append(pos, [[i, i+length(ans[i])-1]])), if(h=f) then (if(not(emptyp(p))) then print(ans) else (print(res, ":", count), [pos])) else (for i in pos do (rep:append(rep, makelist(n, n, lmin(i), lmax(i)))), final:map(lambda([x], if(member(x, rep)) then l[x] else "_"), sublist_indices(l, atom)), return(final)));
(%o2) find(s, l, h, [p]) := block([ans : [], rep : [], final : [], 
parts : makelist(part(l, makelist(n, n, 1 + m, length(s) + m)), m, 0, 
length(l) - length(s)), res, count : 0, pos : []], 
for n thru length(parts) do ans : append(ans, 
[map(lambda([x], if is(x) then lhs(x)), map("=", part(parts, n), s))]), 
for i in ans do if freeof(false, i) then res : i, 
count : length(delete([], map(lambda([x], if freeof(false, x) then x else []), 
ans))), for i thru length(ans) do if freeof(false, ans )
                                                      i
 then pos : append(pos, [[i, i + length(ans ) - 1]]), 
                                           i
if h = f then (if not emptyp(p) then print(ans)
 else (print(res, ":", count), [pos])) else (for i in pos do rep : 
append(rep, makelist(n, n, lmin(i), lmax(i))), 
final : map(lambda([x], if member(x, rep) then l  else "_"), 
                                                x
sublist_indices(l, atom)), return(final)))
(%i3) M:[C,A,T,G,C,A,T,C,A];
(%o3)                     [C, A, T, G, C, A, T, C, A]
(%i4) M;
(%o4)                     [C, A, T, G, C, A, T, C, A]
(%i5) "";
(%o5) 
(%i6) find([C,A,T], M, f);
[C, A, T] : 2 
(%o6)                         [[[1, 3], [5, 7]]]
(%i7) "";
(%o7) 
(%i8) find([C,A,T], M, t);
(%o8)                     [C, A, T, _, C, A, T, _, _]
(%i9) cut(M, 1, 3, s);
(%o9)                     [C, A, T, _, _, _, _, _, _]
(%i10) cut(M, 5, 7, s);
(%o10)                    [_, _, _, _, C, A, T, _, _]
(%i11) cut(M, 8, 10, s);
(%o11)                    [_, _, _, _, _, _, _, C, A]
(%i12) find([C, A, T], M, f);
[C, A, T] : 2 
(%o12)                        [[[1, 3], [5, 7]]]
(%i13) 
Run Example
/* Enter the data */A:matrix([2,7.2],[4.5,7.1],[5.25,6],[7.81,5],[9.2,3.5],[10.6,5]);
                          [         2          7.2 ]
                          [                        ]
                          [        4.5         7.1 ]
                          [                        ]
                          [       5.25          6  ]
(%o1)                     [                        ]
                          [       7.81          5  ]
                          [                        ]
                          [ 9.199999999999999  3.5 ]
                          [                        ]
                          [       10.6          5  ]
(%i2) kmax:length(A)-1;
(%o2)                                  5
(%i3) x0:lmin(list_matrix_entries(submatrix(A,2)));
(%o3)                                  2
(%i4) x1:lmax(list_matrix_entries(submatrix(A,2)));
(%o4)                                10.6
(%i5) /* Nth order polynomial using Lagrangian interpolation */load(interpol);
(%o5)         /usr/share/maxima/5.21.1/share/numeric/interpol.mac
(%i6) f_nth: lagrange(A);
(%o6) 0.0045609540521954 (x - 9.199999999999999) (x - 7.81) (x - 5.25)
 (x - 4.5) (x - 2) - 0.013455435490014 (x - 10.6) (x - 7.81) (x - 5.25)
 (x - 4.5) (x - 2) + 0.026188275999857 (x - 10.6) (x - 9.199999999999999)
 (x - 5.25) (x - 4.5) (x - 2) - 0.045500459554642 (x - 10.6)
 (x - 9.199999999999999) (x - 7.81) (x - 4.5) (x - 2)
 + 0.039902617941917 (x - 10.6) (x - 9.199999999999999) (x - 7.81) (x - 5.25)
 (x - 2) - 0.0024632134466822 (x - 10.6) (x - 9.199999999999999) (x - 7.81)
 (x - 5.25) (x - 4.5)
(%i7) df_nth: sqrt(1+(diff(f_nth,x)^2));
(%o7) sqrt(expt(- 0.0088944814378182 (x - 7.81) (x - 5.25) (x - 4.5) (x - 2)
 + 0.030749230052053 (x - 9.199999999999999) (x - 5.25) (x - 4.5) (x - 2)
 + 0.012732840509843 (x - 10.6) (x - 5.25) (x - 4.5) (x - 2)
 - 0.040939505502446 (x - 9.199999999999999) (x - 7.81) (x - 4.5) (x - 2)
 - 0.058955895044655 (x - 10.6) (x - 7.81) (x - 4.5) (x - 2)
 - 0.019312183554784 (x - 10.6) (x - 9.199999999999999) (x - 4.5) (x - 2)
 + 0.044463571994113 (x - 9.199999999999999) (x - 7.81) (x - 5.25) (x - 2)
 + 0.026447182451904 (x - 10.6) (x - 7.81) (x - 5.25) (x - 2)
 + 0.066090893941774 (x - 10.6) (x - 9.199999999999999) (x - 5.25) (x - 2)
 - 0.0055978416127244 (x - 10.6) (x - 9.199999999999999) (x - 7.81) (x - 2)
 + 0.0020977406055132 (x - 9.199999999999999) (x - 7.81) (x - 5.25) (x - 4.5)
 - 0.015918648936696 (x - 10.6) (x - 7.81) (x - 5.25) (x - 4.5)
 + 0.023725062553175 (x - 10.6) (x - 9.199999999999999) (x - 5.25) (x - 4.5)
 - 0.047963673001324 (x - 10.6) (x - 9.199999999999999) (x - 7.81) (x - 4.5)
 + 0.037439404495235 (x - 10.6) (x - 9.199999999999999) (x - 7.81) (x - 5.25), 
2) + 1)
(%i8) L_nth:romberg(df_nth,x,x0,x1);
(%o8)                          14.91932689837202
(%i9) /* Cubic spline interpolation *//* Calculate the splines */f_cs:cspline(A);
                           3                     2
(%o9) (- 0.10128092075623 x  + 0.60768552453737 x  - 0.62236529434831 x
 + 6.824235856596975) charfun2(x, minf, 4.5)
                        3                      2
 + (- 0.32174713198646 x  + 10.23155879716957 x  - 106.7524702998754 x
 + 370.1642208786973) charfun2(x, 9.199999999999999, inf)
                      3                      2
 + (0.51190065309656 x  - 12.77712007112198 x  + 104.9273752884069 x
 - 278.9873055920348) charfun2(x, 7.81, 9.199999999999999)
                        3                      2
 + (- 0.21613033223407 x  + 4.280645915174853 x  - 28.29377706457142 x
 + 67.83176103355189) charfun2(x, 5.25, 7.81)
                      3                      2
 + (0.72720003918217 x  - 10.57680743463106 x  + 49.70785302190961 x
 - 68.67109161778993) charfun2(x, 4.5, 5.25)
(%i10) /* Pull out the cubic polynomial for each subinterval */h1[i,j]:=1;
(%o10)                            h1     := 1
                                    i, j
(%i11)  L_splines:0;
(%o11)                                 0
(%i12) f_splines: matrix([0]);
(%o12)                               [ 0 ]
(%i13) for k:1 thru kmax do    (   kill(h2,h3),        h2[i,j]:=A[k,1]+(i-1)/3*(A[k+1,1]-A[k,1]),         h3[i,j]:=ev(f_cs,x=C2[i,1]),        C1:genmatrix(h1,4,1), C2:genmatrix(h2,4,1), C3:C2^2, C4:C2^3,        C:addcol(C1,C2,C3,C4),        D:genmatrix(h3,4,1),        aCS:invert(C).D,        f_spline:matrix([1,x,x^2,x^3]).aCS,        f_splines:addrow(f_splines,[f_spline]),        df_spline:sqrt(1+(diff(f_spline,x))^2),        L_splines:L_splines+romberg(df_spline,x,A[k,1],A[k+1,1])    );
(%o13)                               done
(%i14) /* The result */f_splines:submatrix(1,f_splines);
                                   3                     2
(%o14) matrix([- 0.10128092075624 x  + 0.60768552453739 x  - 0.6223652943483 x
                                          3                      2
 + 6.824235856596928], [0.72720003918268 x  - 10.57680743463845 x
 + 49.70785302194418 x - 68.67109161785083], 
                     3                      2
[- 0.21613033223416 x  + 4.280645915174812 x  - 28.29377706457055 x
                                          3                      2
 + 67.83176103356539], [0.51190065306942 x  - 12.77712007045025 x
 + 104.9273752828524 x - 278.9873055767034], 
                     3                      2
[- 0.32174713192974 x  + 10.23155879530677 x  - 106.7524702812943 x
 + 370.164220821478])
(%i15) L_splines;
(%o15)                         11.24759514348632
(%i16) L_nth;
(%o16)                         14.91932689837202
(%i17) L_diff:(L_nth-L_splines)/L_nth * 100;
(%o17)                         24.61057244671245
(%i18) plot2d ([f_nth, f_cs], [x, x0, x1], [legend, "Nth Order Polynomial", "Cubic Splines"]);
plotplot2d ([f_nth, f_cs], [x, x0, x1], [legend, "Nth Order Polynomial", "Cubic Splines"]);

Related Help

Help for Lmax