acer

32373 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

restart;

L1 := [t-2,(t-2)^2]:        
L2 := [(3*t/2)-4,(3*t/2)-2]:

solve(Equate(L1,L2));

                            {t = 4}

My guess is that you are looking for something like the effect of the plots:-dualaxisplot command.

See this revision: GaußKronrodQuadraturFehlerbehandlung_ac.mw

Don't use the word function like that in relation to Maple. Nobody will know for sure whether you are talking about an expression (which could be evaluated at values for its unknowns) or a procedure (which can be called with values).

I am going to guess that you mean a procedure (of which an arrow-printing operator is one variant).

Have you set up your procedure to do something special (eg, return unevaluated) if it is called with a simple name for its parameter x?

If not, when why not do something like evalf[4](f(x)) where x is some unassigned name?

There is no blazingly simple way to print the body of a procedure and have it be pretty-printed in a modified manner. (There are ways, but advanced.)

restart;

plots:-display(
        seq( plot([cos(t)-q*sin(t), sin(t)+q*cos(t), q=-1..1]),
             t=0..evalf(2*Pi), evalf(Pi/30) ),
        gridlines=false
              );

 

Download some_tangents.mw

And for fun,

Explore(plots:-display(
          seq( plot([cos(n*2*Pi/N)-q*sin(n*2*Pi/N),
                     sin(n*2*Pi/N)+q*cos(n*2*Pi/N), q=-2..2]),
               n=0..N-1 ),
          gridlines=false),
        parameters=[N=1..50], initialvalues=[N=30]);

[edited] The original formulation is not efficient. Each line segments really requires only its two end-points. They are lots of ways to accomplish that: plottools:-line, forced numpoints, pointplot with linestyle, etc. So this runs more smoothly,

Explore(plots:-display(
          seq( plot([seq([cos(n*2*Pi/N)-q*sin(n*2*Pi/N),
                          sin(n*2*Pi/N)+q*cos(n*2*Pi/N)],
                         q=[-2,2])]),
               n=0..N-1 ),
          gridlines=false),
        parameters=[N=1..200], initialvalues=[N=30]);

And, even though the earlier code wasn't unbearably slow,

plots:-display(
          seq( plot([seq([cos(n*2*Pi/60)-q*sin(n*2*Pi/60),
                          sin(n*2*Pi/60)+q*cos(n*2*Pi/60)],
                         q=[-2,2])]),
               n=0..60 ),
          gridlines=false);

or (better than the original, but not as quick as that immediately above),

plots:-display(
        seq( plot([cos(t)-q*sin(t), sin(t)+q*cos(t), q=-2..2],
                  adaptive=false, numpoints=2),
             t=0..evalf(2*Pi), evalf(Pi/30) ),
        gridlines=false
              );

The eigenvectors associated with eigenvalue evals[i] can be computed as the Null Space of the Characteristic Matrix using at lambda = evals[i] .

restart;

XCov:=Matrix([[4048/5, -817/5, -122/5], [-817/5, 921/10, -1999/10], [-122/5, -1999/10, 8341/10]]);

Matrix(3, 3, {(1, 1) = 4048/5, (1, 2) = -817/5, (1, 3) = -122/5, (2, 1) = -817/5, (2, 2) = 921/10, (2, 3) = -1999/10, (3, 1) = -122/5, (3, 2) = -1999/10, (3, 3) = 8341/10})

with(LinearAlgebra):

det := Determinant(XCov-lambda*IdentityMatrix(3));

11846839/2-(3797086/5)*lambda+(8679/5)*lambda^2-lambda^3

evals := Vector([solve(det=0.0, lambda)]);

Vector(3, {(1) = 7.943520930, (2) = 837.8501420, (3) = 890.0063371})

CharacteristicMatrix(XCov, lambda);

Matrix(3, 3, {(1, 1) = lambda-4048/5, (1, 2) = 817/5, (1, 3) = 122/5, (2, 1) = 817/5, (2, 2) = lambda-921/10, (2, 3) = 1999/10, (3, 1) = 122/5, (3, 2) = 1999/10, (3, 3) = lambda-8341/10})

CharacteristicMatrix(XCov, evals[1]);

Matrix(3, 3, {(1, 1) = -801.6564791, (1, 2) = 817/5, (1, 3) = 122/5, (2, 1) = 817/5, (2, 2) = -84.15647907, (2, 3) = 1999/10, (3, 1) = 122/5, (3, 2) = 1999/10, (3, 3) = -826.1564791})

evecs[1] := NullSpace(CharacteristicMatrix(XCov, evals[1]));

{Vector(3, {(1) = -.20097171043526135, (2) = -.950748499500729, (3) = -.23598233472410096})}

evecs[2] := NullSpace(CharacteristicMatrix(XCov, evals[2]))

{Vector(3, {(1) = -.9265946969725416, (2) = .10633405707523064, (3) = .36071503413121725})}

evecs[3] := NullSpace(CharacteristicMatrix(XCov, evals[3]))

{Vector(3, {(1) = .3178563183964183, (2) = -.29115349733256674, (3) = .9023286551176849})}

# test the first of the eigenvectors corresponding to the third eigenvalue.
# (There's only one such eigenvector, as evecs[3] is a set with just one element.)
XCov . evecs[3][1] - evals[3] . evecs[3][1];

Vector(3, {(1) = -0.7077403552e-8, (2) = 0.6482935078e-8, (3) = -0.2009130640e-7})

seq( seq( Norm( XCov . evecs[i][j] - evals[i] . evecs[i][j] ), j=1..nops(evecs[i])), i=1..3 );

0.643466080418875208e-8, 0.702686975273536518e-8, 0.200913063963525929e-7

# All eigenvectors in a Matrix, as columns
Evecs := `<|>`( seq(seq(evecs[i][j], j=1..nops(evecs[i])), i=1..3 ) );

Matrix(3, 3, {(1, 1) = -.20097171043526135, (1, 2) = -.9265946969725416, (1, 3) = .3178563183964183, (2, 1) = -.950748499500729, (2, 2) = .10633405707523064, (2, 3) = -.29115349733256674, (3, 1) = -.23598233472410096, (3, 2) = .36071503413121725, (3, 3) = .9023286551176849})

# test them all at once
XCov . Evecs - Evecs . DiagonalMatrix(evals);

Matrix(3, 3, {(1, 1) = 0.5480002008e-8, (1, 2) = 0.7026869753e-8, (1, 3) = -0.7077460396e-8, (2, 1) = -0.2597509763e-8, (2, 2) = -0.8063665291e-9, (2, 3) = 0.6482935078e-8, (3, 1) = 0.6434661026e-8, (3, 2) = -0.2735532689e-8, (3, 3) = -0.2009142008e-7})

 

Download eigenvects.mw

There are various ways to simplify your examples. Presumably you want approaches which are understandable and less ad hoc. (In the first examples in this attachment, the evala command does as well as radnormal.)

If the denominators (of the arguments of the ln calls) are factored after expanding, then one of the factors will cancel automatically with part of the corresponding numerator, for your examples. See the last two lines in this attachment, for insight on that as well as expansion without that factoring.

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

f:=ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2));

ln((1-x)^2*(x+1)^2/((-I*x-I+(-x^2+1)^(1/2))^2*(I*x+I+(-x^2+1)^(1/2))^2))

f2:=ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2))*ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2))*ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2))*ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2)) + ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2))*ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2)) + ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2)) + ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2))*ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2));

ln((1-x)^2*(x+1)^2/((-I*x-I+(-x^2+1)^(1/2))^2*(I*x+I+(-x^2+1)^(1/2))^2))^4+2*ln((1-x)^2*(x+1)^2/((-I*x-I+(-x^2+1)^(1/2))^2*(I*x+I+(-x^2+1)^(1/2))^2))^2+ln((1-x)^2*(x+1)^2/((-I*x-I+(-x^2+1)^(1/2))^2*(I*x+I+(-x^2+1)^(1/2))^2))

radnormal(f);

ln((1/4)*(-1+x)^2)

frontend(expand,[radnormal(f2)]);

ln((1/4)*(-1+x)^2)^4+2*ln((1/4)*(-1+x)^2)^2+ln((1/4)*(-1+x)^2)

subsindets(f, specfunc(ln), radnormal);

ln((1/4)*(-1+x)^2)

subsindets(f2, specfunc(ln), radnormal);

ln((1/4)*(-1+x)^2)^4+2*ln((1/4)*(-1+x)^2)^2+ln((1/4)*(-1+x)^2)

subsindets(f2, specfunc(ln), u->ln(numer(op(u))/expand(denom(op(u)))));

ln((-1+x)^2*(x+1)^2/(4*x^2+8*x+4))^4+2*ln((-1+x)^2*(x+1)^2/(4*x^2+8*x+4))^2+ln((-1+x)^2*(x+1)^2/(4*x^2+8*x+4))

subsindets(f2, specfunc(ln), u->ln(numer(op(u))/factor(expand(denom(op(u))))));

ln((1/4)*(-1+x)^2)^4+2*ln((1/4)*(-1+x)^2)^2+ln((1/4)*(-1+x)^2)

 

Download targeted.mw

The procedure Mutate acts in-place on the particleposition Array, so it seems like you want that Array to be a running state of the updated values.

But inside your procedure Mutate there is a statement y :=x .Perhaps you intended y:=copy(x), and to have the last line of that procedure be return y ?

If L2 is very large then you might want to ascertain a true result as soon as any element of L2 is found to be in the union of the L1 sets.

In other words, you may find it too costly to compute a full set intersection (or minus) involving examining all of L2, or a full seq of tests over all of L2.

In such a case you could try ormap , which will return true as soon as it finds its first true result. Ie.

   ormap(member,L2,`union`(L1[]));

There may, however, be some function-call overhead for calling member many times. (There are some kinds of calculation where it matters whether you want to focus on worst possible vs best average behavior, etc, in which case deciding what's best can entail figuring out what's likely as well as what you want.)
 

That do is our of place. That keyword is not part of an if..then..end if.

You likely don't want a loop here.

Are you trying to get something like this?

Here I use to frontend to suppress/freeze the derivatives, while using eliminate on the variable m, and then consider the remaining conditions (implied equations, the second part of what eliminate returns).

restart;

eq1 := -T*sin(theta(t)) = m*(diff(X(t), t, t)
       +L*(diff(theta(t), t, t))*cos(theta(t))
       -L*(diff(theta(t), t))^2*sin(theta(t))):

eq2 := T*cos(theta(t))-m*g = m*(diff(Y(t), t, t)
       +L*(diff(theta(t), t, t))*sin(theta(t))
       +L*(diff(theta(t), t))^2*cos(theta(t))):

K := frontend(eliminate,[{eq1,eq2},{m}],[{`+`,`*`,`=`,set},{}]):

conds := simplify(map(`=`,K[2],0));

{T*(L*(diff(diff(theta(t), t), t))+(diff(diff(X(t), t), t))*cos(theta(t))+sin(theta(t))*(diff(diff(Y(t), t), t)+g)) = 0}

(1)

conds[1]/T;

L*(diff(diff(theta(t), t), t))+(diff(diff(X(t), t), t))*cos(theta(t))+sin(theta(t))*(diff(diff(Y(t), t), t)+g) = 0

(2)

 

Download eliminate_examp.mw

You can substitute for m+F(xi) using freeze and algsubs, and then collect, and then resubstitute using thaw.

You have a variety of ways to simplify, or not, the coefficients (of the m+F(xi) powers). Below I show two ways, one with some simplification.

restart;

T := K+F(xi)*F(xi):

U := alpha[0]+alpha[1]*(m+F(xi))+beta[1]/(m+F(xi))
    +alpha[2]*(m+F(xi))*(m+F(xi))+beta[2]/(m+F(xi))^2:

d := alpha[1]*T-beta[1]*T/(m+F(xi))^2+2*alpha[2]*(m+F(xi))*T
     -2*beta[2]*T/(m+F(xi))^3:

S := (2*alpha[1]*F(xi)-2*beta[1]*F(xi)/(m+F(xi))^2
     +2*beta[1]*(K+F(xi)^2)/(m+F(xi))^3
     +2*alpha[2]*(K+F(xi)^2)+4*alpha[2]*(m+F(xi))*F(xi)
     -4*beta[2]*F(xi)/(m+F(xi))^3
     +6*beta[2]*(K+F(xi)^2)/(m+F(xi))^4)*T:

expand((2*w*k*k)*beta*S-(2*A*k*k)*d-2*w*U+k*U*U):

value(%):

expr := simplify(%):

temp := algsubs(m+F(xi)=freeze(m+F(xi)),numer(expr)):

thaw(collect(temp, freeze(m+F(xi)))/denom(expr));

(k*alpha[2]^2*(m+F(xi))^8+2*k*alpha[1]*alpha[2]*(m+F(xi))^7+(m+F(xi))^6*(2*k*alpha[0]*alpha[2]+k*alpha[1]^2-2*w*alpha[2])+(8*F(xi)^3*beta*k^2*w*alpha[2]+8*K*F(xi)*beta*k^2*w*alpha[2]-4*A*F(xi)^2*k^2*alpha[2]-4*A*K*k^2*alpha[2]+2*k*alpha[0]*alpha[1]+2*k*alpha[2]*beta[1]-2*w*alpha[1])*(m+F(xi))^5+(-2*A*k^2*alpha[1]*K+4*w*k^2*beta*alpha[2]*F(xi)^4+4*w*k^2*beta*alpha[1]*F(xi)^3+(8*K*beta*k^2*w*alpha[2]-2*A*k^2*alpha[1])*F(xi)^2+4*w*k^2*beta*alpha[1]*F(xi)*K+k*alpha[0]^2-2*w*alpha[0]+4*w*k^2*beta*alpha[2]*K^2+2*k*alpha[1]*beta[1]+2*k*alpha[2]*beta[2])*(m+F(xi))^4+(2*k*alpha[0]*beta[1]+2*k*alpha[1]*beta[2]-2*w*beta[1])*(m+F(xi))^3+(-4*w*k^2*beta*beta[1]*F(xi)^3-4*w*k^2*beta*beta[1]*F(xi)*K+2*A*k^2*beta[1]*F(xi)^2+2*A*k^2*beta[1]*K+2*k*alpha[0]*beta[2]+k*beta[1]^2-2*w*beta[2])*(m+F(xi))^2+(4*w*k^2*beta*beta[1]*F(xi)^4-8*w*k^2*beta*beta[2]*F(xi)^3+(8*K*beta*k^2*w*beta[1]+4*A*k^2*beta[2])*F(xi)^2-8*w*k^2*beta*beta[2]*F(xi)*K+4*w*k^2*beta*beta[1]*K^2+2*k*beta[1]*beta[2]+4*A*k^2*beta[2]*K)*(m+F(xi))+12*w*k^2*beta*beta[2]*F(xi)^4+24*w*k^2*beta*beta[2]*K*F(xi)^2+12*w*k^2*beta*beta[2]*K^2+k*beta[2]^2)/(m+F(xi))^4

simplify(% - expr);

0

Numer:=collect(temp, freeze(m+F(xi)),
               uu->collect(uu,[beta,beta[1],beta[2],k,A,w],
                           uuu->factor(uuu))):

new := thaw(Numer/denom(expr));

(k*alpha[2]^2*(m+F(xi))^8+2*k*alpha[1]*alpha[2]*(m+F(xi))^7+((2*alpha[0]*alpha[2]+alpha[1]^2)*k-2*alpha[2]*w)*(m+F(xi))^6+(8*F(xi)*alpha[2]*(K+F(xi)^2)*w*k^2*beta+2*k*alpha[2]*beta[1]-4*alpha[2]*(K+F(xi)^2)*A*k^2+2*k*alpha[0]*alpha[1]-2*w*alpha[1])*(m+F(xi))^5+(4*(K+F(xi)^2)*(F(xi)^2*alpha[2]+K*alpha[2]+alpha[1]*F(xi))*w*k^2*beta+2*k*alpha[1]*beta[1]+2*k*alpha[2]*beta[2]-2*alpha[1]*(K+F(xi)^2)*A*k^2+k*alpha[0]^2-2*w*alpha[0])*(m+F(xi))^4+((2*k*alpha[0]-2*w)*beta[1]+2*k*alpha[1]*beta[2])*(m+F(xi))^3+(-4*F(xi)*(K+F(xi)^2)*w*k^2*beta[1]*beta+k*beta[1]^2+(2*F(xi)^2+2*K)*A*k^2*beta[1]+(2*k*alpha[0]-2*w)*beta[2])*(m+F(xi))^2+((4*(K+F(xi)^2)^2*w*k^2*beta[1]-8*F(xi)*(K+F(xi)^2)*w*k^2*beta[2])*beta+2*k*beta[1]*beta[2]+(4*F(xi)^2+4*K)*A*k^2*beta[2])*(m+F(xi))+12*(K+F(xi)^2)^2*w*k^2*beta[2]*beta+k*beta[2]^2)/(m+F(xi))^4

simplify(expr - new);

0

 

Download collect_freeze.mw

I don't know of a way to accomplish what you want using a legend per se, especially if the font size and dimensions have to be as you have them.

But what about a combination of shorter line segments alongside textplot, inlined into the plot? It's more effort to set up just right, but gives more flexibility to correct for the linestyles. legendwidth.mw

If the expression (dependinng on a, b, and c) has been assigned to the name `expr` then you can create an operator from that with,

f := unapply(expr, [a,b,c]);

 

The assumptions that modify your Int calls -- made using assuming -- don't carry over to the value calls.

Various simplifications can be made on the result of the value or int calls, using the same assumptions, say.

Another possibility is to convert the integrand to expln form prior to using value.

restart

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

(1)

U1 := `assuming`([Int(ln(r)*sin(k1*Pi*ln(r/Rs)/ln(r4/Rs))/r, r = Rs .. r4)], [Rs > 0, r4 > 0, r4 > Rs, k1::posint])

Int(ln(r)*sin(k1*Pi*ln(r/Rs)/ln(r4/Rs))/r, r = Rs .. r4)

(2)

ans1 := `assuming`([combine(simplify(simplify(combine(evalc(value(U1)))), size))], [Rs > 0, r4 > 0, r4 > Rs, k1::posint])

ln(Rs/r4)*((-1)^k1*ln(r4)+ln(1/Rs))/(k1*Pi)

(3)

`assuming`([value(convert(U1, expln))], [Rs > 0, r4 > 0, r4 > Rs, k1::posint]);

(1/2)*(2*(-1)^(1+k1)*ln(r4)^2*Pi*k1+2*ln(Rs)*ln(r4)*(-1)^k1*Pi*k1+2*ln(Rs)*ln(r4)*Pi*k1-2*ln(Rs)^2*Pi*k1)/(Pi^2*k1^2)

(4)

pars := [Rs = 2, r4 = 1, k1 = 3];

[Rs = 2, r4 = 1, k1 = 3]

 

Int(-ln(r)*sin(3*Pi*ln((1/2)*r)/ln(2))/r, r = 2 .. 1)

 

-0.5097764806e-1

 

-(1/3)*ln(2)^2/Pi

 

-0.5097764806e-1

(5)

U3 := `assuming`([Int(sin(k1*Pi*ln(r/Rs)/ln(r4/Rs))*(r/r4)^(m1*Pi*`&tau;ds`/d)/r, r = Rs .. r4)], [Rs > 0, r4 > 0, r4 > Rs, k1::posint, m1::posint, d > 0, `&tau;ds` > 0])

Int(sin(k1*Pi*ln(r/Rs)/ln(r4/Rs))*(r/r4)^(m1*Pi*`&tau;ds`/d)/r, r = Rs .. r4)

(6)

ans3 := `assuming`([combine(simplify(simplify(combine(evalc(value(U3)))), size))], [Rs > 0, r4 > 0, r4 > Rs, k1::posint, m1::posint, d > 0, `&tau;ds` > 0])

d^2*k1*(r4^(m1*Pi*`&tau;ds`*ln(Rs^2)/(d*ln(r4/Rs)))*exp(Pi*m1*`&tau;ds`*(ln(Rs)^2+ln(r4)^2)/(d*ln(Rs/r4)))-(-1)^k1)*ln(r4/Rs)/(Pi*(ln(Rs)^2*m1^2*`&tau;ds`^2+m1^2*`&tau;ds`^2*ln(r4)*ln(1/Rs^2)+ln(r4)^2*m1^2*`&tau;ds`^2+k1^2*d^2))

(7)

ans3b := `assuming`([numer(ans3)/collect(denom(ans3), m1, proc (u) options operator, arrow; combine(simplify(u, size)) end proc)], [Rs > 0, r4 > 0, r4 > Rs, k1::posint, m1::posint, d > 0, `&tau;ds` > 0])

d^2*k1*(r4^(2*m1*Pi*`&tau;ds`*ln(Rs)/(d*ln(r4/Rs)))*exp(Pi*m1*`&tau;ds`*(ln(Rs)^2+ln(r4)^2)/(d*ln(Rs/r4)))-(-1)^k1)*ln(r4/Rs)/(Pi*`&tau;ds`^2*ln(Rs/r4)^2*m1^2+Pi*k1^2*d^2)

(8)

`assuming`([simplify(ans3-ans3b)], [Rs > 0, r4 > 0, r4 > Rs, k1::posint, m1::posint, d > 0, `&tau;ds` > 0])

0

(9)

ans3c := `assuming`([simplify(combine(value(simplify(combine(convert(U3, expln))))), size)], [Rs > 0, r4 > 0, r4 > Rs, k1::posint, m1::posint, d > 0, `&tau;ds` > 0]):

k1*d^2*ln(Rs/r4)*((-1)^k1-r4^(-m1*Pi*`&tau;ds`/d)*Rs^(m1*Pi*`&tau;ds`/d))/(Pi*`&tau;ds`^2*ln(Rs/r4)^2*m1^2+Pi*k1^2*d^2)

(10)

parsmore := [Rs = 2, r4 = 1, k1 = 3, m1 = 2, d = 1/3, `&tau;ds` = 1/4];

-1.786983542

(11)

``

Download integrals_acc.mw

Try this in your Maple 2016, using the name `#msub(mi("n"),mi("r"))` wrapped in a typeset call.

mprime_ac.mw

First 163 164 165 166 167 168 169 Last Page 165 of 336