Christian Wolinski

MaplePrimes Activity


These are answers submitted by Christian Wolinski

Your comparison is not elementwise:

(a, b, c, d) := (1, -1, 1, -1);
c := NULL; d := 1, -1;
if (a, b, c, d) = (1, -1, 1, -1) then
    print("foo");
end if;

If it is a polynomial in x you are working with then use:
convert(series(P, x, n+1), polynom);

However, if P contains other series as coefficients then those too will be converted.

Matrix(3, 1, proc(k, c) local i, j, r, C, R; r:=Row(DOFe, k); Matrix(6, 6, unapply('`if`(member(i, r, 'R') and member(j, r, 'C' ), (KTe[k, 1])[R, C], 0), i, j'))  end);
 

The above code requires Matrix initialization be executed sequentially, which I think it is.

restart;
with(ListTools);
with(LinearAlgebra);

assign(
KTe = Matrix(3, 1),
KTe[1,1] = Matrix(4, 4, [[216, -288, -216, 288], [-288, 384, 288, -384], [-216, 288, 216, -288], [288, -384, -288, 384]]),
KTe[2,1] = Matrix(4, 4, [[216, 288, -216, -288], [288, 384, -288, -384], [-216, -288, 216, 288], [-288, -384, 288, 384]]),
KTe[3,1] = Matrix(4, 4, [[500, 0, -500, 0], [0, 0, 0, 0], [-500, 0, 500, 0], [0, 0, 0, 0]]),
DOFe = Matrix(3, 4, [[1, 2, 3, 4], [3, 4, 5, 6], [5, 6, 1, 2]])
);

KG := Matrix(3, 1): for k from 1 to 3 do nn:=Row(DOFe,k); KG1 := Matrix(6, 6); for i from 1 to 4 do for j from 1 to 4 do KG1[nn[i],nn[j]]:=(KTe[k,1])[i,j]; end do; end do; KG[k,1]:=KG1; end do:

print('KG' = KG);
 

C := proc(E, T)
   if type('E, T') then 1 elif hastype('E, T') then add(map(procname, [op]('E'), 'T')) else 0 fi;
end;

L := ifactors(10^128+3, easyfunc);
remove(type, L[2], [prime, posint]);

add~(combinat:-choose([a, b, c], 2));
 

A := 3.123123;
L := convert(A, confrac, 'Ac');
Ac;
evalf(Ac[-3], 32);

B := 3.123123123123;
L := convert(B, confrac, 'Bc');
Bc;
evalf(Bc[-2], 32);

C := 7.421232323;
L := convert(C, confrac, 'Cc');
Cc;
evalf(Cc[-3], 32);

A := {1, 2, 3, 4, 6, 8, 12, 17, 19, 20};
select(is, A , RealRange(5, 15));
select(proc(x, y, z) x>=y and z>=x end, A, 5, 15);

 

A := x*y/(y-x*sqrt(y)-x^2);
(simplify@@2)(A, [y = sq^2]) assuming sq>0;
A_PS := convert(%, FormalPowerSeries, x);
B := op(1, A_PS);
simplify(B) assuming sq>0, k, nonnegint;
subs(sq=sqrt(y), %);
collect(add(%, subsop([2,2]=8, op(2, A_PS))), x, radnormal)
;

assign('Q = Q, R = R');
collect(collect(A, epsilon, Q), Q, proc(x) if type(x, identical(epsilon)^anything) then R(epsilon, op(2, x)) elif type(x, identical(epsilon)) then R(epsilon, 1) else x fi end);
seq(eval(P = coeff(%, P), [Q = (x -> x), R = ((x, y) -> x^y)]), P = sort([op@indets](%, 'R(identical(epsilon), anything)'), ((x, y) -> (op(2, x) < op(2, y)))));

 

convert(eliminate({eq_5_23, eq_5_23x, eq_5_22}, {Psi__ad, L__ad})[1], parfrac, L__fd);
 

F := 2*y*sin(beta*x)+6*z*cos(beta*x)+24*sin(beta*x)*cos(beta*x):
W := coeffs(F, {sin, cos}(beta*x), 'V'):
[W], [V];
if member(sin(beta*x), [V], 'i') then op(i, [W]) else 0 fi;
if member(cos(beta*x), [V], 'i') then op(i, [W]) else 0 fi;

 

Replace relevant lines (from Eq3..Sols) with:
Eq3 := factor(expand(value(algsubs(subs(params, tr3), Eq2))))
Eq31 := collect(numer(lhs(Eq3)), exp(z))
sys1 := [coeffs(Eq31, exp(z)), c=c0];
vars := indets([sys1], name) minus {c0};
Sols := map(allvalues, [solve(sys1, vars)]); NSols := nops(Sols);


Alternatively you can try:
Eq3 := factor(expand(value(algsubs(subs(params, tr3), Eq2))))
vars := {c, mu, seq(a[i], i = -1 .. 1), seq(b[j], j = -1 .. 1)}
Sols := map(allvalues, [solve]({c=c0, identity(Eq3,z)},vars)); NSols := nops(Sols);

This groups by leading coefficient:

Q:=proc(E)
local X;
if type(E, `+`) then X := [op]('E') else X := ['E'] fi;
ListTools:-Categorize(proc(x, y) lcoeff(x) = lcoeff(y) end, X);
end;
Q(pn);
map(add, [Q(expand(pn))]);
(add@map)(add, [Q(expand(pn))]);
(add@map)(proc(E) ``(lcoeff(E))*normal(E/lcoeff(E)) end@add, [Q(expand(pn))]);

 

1 2 3 4 5 6 7 Last Page 1 of 19