acer

32470 Reputation

29 Badges

20 years, 6 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

It works (for me) if re-executed, presumably because of some fortuitous memoization.

It also works (for me) if all methods are tried. That can then be sieved for successful results.

It also works in my Maple 2022.1 if only method=risch is forced. Naturally that approach may not be as generally useful for you.

The error seems to go back to Maple 2019, before which the integral may have returned unevaluated.

(I have submitted a bug report.)

restart;
int(x^5*(a+b*arctan(c*x^2))^2,x);
int(x^5*(a+b*arctan(c*x^2))^2,x);
 

Error, (in gcdex) invalid arguments

(1/6)*b*a*ln(c^2*x^4+1)/c^3-((1/6)*I)*b^2*dilog(1/2-((1/2)*I)*c*x^2)/c^3-((1/12)*I)*b^2*ln(1+I*c*x^2)*ln(1-I*c*x^2)/c^3-((1/24)*I)*b^2*ln(1+I*c*x^2)^2/c^3-((1/12)*I)*b^2*x^4*ln(1-I*c*x^2)/c+(1/12)*b^2*ln(1+I*c*x^2)*ln(1-I*c*x^2)*x^6-(1/6)*b*a*x^4/c-((17/108)*I)*b^2/c^3+((1/6)*I)*b*a*x^6*ln(1-I*c*x^2)-((1/6)*I)*b^2*ln(1/2+((1/2)*I)*c*x^2)*ln(1/2-((1/2)*I)*c*x^2)/c^3+((1/6)*I)*b^2*ln(1/2+((1/2)*I)*c*x^2)*ln(1-I*c*x^2)/c^3-((1/6)*I)*b*a*x^6*ln(1+I*c*x^2)+(1/6)*x^6*a^2-(1/24)*b^2*x^6*ln(1+I*c*x^2)^2+((1/24)*I)*b^2*ln(1-I*c*x^2)^2/c^3+((1/12)*I)*b^2*x^4*ln(1+I*c*x^2)/c-(1/24)*b^2*x^6*ln(1-I*c*x^2)^2+(1/6)*b^2*x^2/c^2-(1/6)*b^2*arctan(c*x^2)/c^3

restart;
rhs~(select(type,int(x^5*(a+b*arctan(c*x^2))^2,x,
                     'method'=':-_RETURNVERBOSE'),
            string=algebraic));

[(1/6)*b*a*ln(c^2*x^4+1)/c^3+(1/12)*b^2*ln(1+I*c*x^2)*ln(1-I*c*x^2)*x^6-(1/6)*b*a*x^4/c+((1/24)*I)*b^2*ln(1-I*c*x^2)^2/c^3-((17/108)*I)*b^2/c^3-((1/6)*I)*b^2*dilog(1/2-((1/2)*I)*c*x^2)/c^3-((1/12)*I)*b^2*x^4*ln(1-I*c*x^2)/c+((1/6)*I)*b*a*x^6*ln(1-I*c*x^2)-((1/6)*I)*b^2*ln(1/2+((1/2)*I)*c*x^2)*ln(1/2-((1/2)*I)*c*x^2)/c^3+((1/6)*I)*b^2*ln(1/2+((1/2)*I)*c*x^2)*ln(1-I*c*x^2)/c^3-((1/12)*I)*b^2*ln(1+I*c*x^2)*ln(1-I*c*x^2)/c^3+((1/12)*I)*b^2*x^4*ln(1+I*c*x^2)/c-(1/24)*b^2*x^6*ln(1+I*c*x^2)^2-((1/6)*I)*b*a*x^6*ln(1+I*c*x^2)-(1/24)*b^2*x^6*ln(1-I*c*x^2)^2+(1/6)*b^2*x^2/c^2-(1/6)*b^2*arctan(c*x^2)/c^3-((1/24)*I)*b^2*ln(1+I*c*x^2)^2/c^3+(1/6)*x^6*a^2]

Download int_gcdex_wk.mw

This is not suggested as better than vv's approach.

But you may be interested in a couple of nudges that can help fix up your result (using some missing bits and pieces...).

restart;

RaiseIndex := proc(S::specfunc({sum,Sum}),k::integer)
  local svar:=lhs(op(2,S));
  op(0,S)(eval(op(1,S),svar=svar-k),
          svar=map(`+`,rhs(op(2,S)),k));
end proc:

 

U := rsolve({u(1) = x[1], u(n + 1) = u(n) + (x[n + 1] - u(n))/(n + 1)}, u(n));

(Sum(x[n1+1], n1 = 1 .. n-1)+x[1])/n

U2 := subsindets(U, specfunc(Sum), S->RaiseIndex(S,1));

(Sum(x[n1], n1 = 2 .. n)+x[1])/n

extra := x[1] = Sum(x[n1], n1=1..1);

x[1] = Sum(x[n1], n1 = 1 .. 1)

simplify(simplify(U2, {extra}));

(Sum(x[n1], n1 = 1 .. n))/n

Download sumbitsandpieces.mw

[note: I had this worksheet completed before I saw vv's Answer. I'm not really surprised how similar they are, taking natural approaches.]

The eq4 below (for c[2]) is not strictly necessary. It's just a rewriting of the eq1, by substituting the obtained solution for Z. I figured you might want two equations that did not have any c[2] or Z on their RHSs.

restart

kernelopts(version);

`Maple 17.02, X86 64 LINUX, Sep 5 2013, Build ID 872941`

(1)

eq1 := c[2] = Z^2/(2*(m+2));

c[2] = Z^2/(2*m+4)

(2)

eq2 := int((m*(c[2]-x^2/(2*(m+2))))^(1/m), x = 0 .. Z) = alpha

int((m*(c[2]-x^2/(2*m+4)))^(1/m), x = 0 .. Z) = alpha

(3)

assume(m >= 1);

temp := IntegrationTools:-Change(eval(eq2, eq1), s = x/Z, s);

(1/2)*m^(1/m)*(m+2)^(-1/m)*Z*((1/2)*Z^2)^(1/m)*GAMMA(1/m+1)*Pi^(1/2)/GAMMA(1/m+3/2) = alpha

(4)

eq3 := `assuming`([isolate(combine(temp), Z)], [Z > 0]);

Z = (alpha*GAMMA((1/2)*(2+3*m)/m)/(2^(-(1+m)/m)*m^(1/m)*(m+2)^(-1/m)*Pi^(1/2)*GAMMA((1+m)/m)))^(m/(m+2))

 

c[2] = ((alpha*GAMMA((1/2)*(2+3*m)/m)/(2^(-(1+m)/m)*m^(1/m)*(m+2)^(-1/m)*Pi^(1/2)*GAMMA((1+m)/m)))^(m/(m+2)))^2/(2*m+4)

(5)

 

 

Now a simple sanity check (numeric, and exact).

evalf(eval(eval(subs(int = Int, eq2), [eq3, eq4]), [m = 2, alpha = 6]));

6.000000000 = 6.

(6)

simplify(eval([eq3, eq4], [m = 2, alpha = 6]));

[Z = 4*3^(1/2)/Pi^(1/2), c[2] = 6/Pi]

 

true

(7)

eval(eval(eq2, [eq3, eq4]), [m = 2, alpha = 6]);

6 = 6

(8)

``

Download system_eqs_ac.mw

PDEtools:-Solve tries to simplify the RootOf that solve returns (when passed the numerator of the trig-expanded form of result), and generates RootOf(0).

Unfortunatelty,

result:=1/2*(Dirac(1,-t+4+k)+Dirac(1,t-4+k)-Dirac(1,-t+4+k)*cos(-t+4+k)
             +2*Dirac(-t+4+k)*sin(-t+4+k)+2*sin(t-4+k)*Dirac(t-4+k)
             -Dirac(1,t-4+k)*cos(t-4+k))/k:

result:=simplify(result):

denom(result);

             2 k

lprint(numer(result));
Dirac(1,-t+4+k)+Dirac(1,t-4+k)-Dirac(1,-t+4+k)*cos(-t+4+k)+2*Dirac(-t+4+k)*sin
(-t+4+k)+2*sin(t-4+k)*Dirac(t-4+k)-Dirac(1,t-4+k)*cos(t-4+k)

simplify(numer(result));

              0

Avoiding a clash with the default value of statevariable,

restart;

kernelopts(version);

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

DynamicSystems:-SystemOptions('statevariable'=sv,
                              'continuoustimevar'=x):

ode:=diff(y(x),x$2)+y(x) = 0;

diff(diff(y(x), x), x)+y(x) = 0

DynamicSystems:-DiffEquation(ode,'outputvariable'=[y(x)]);

"module() ... end module"

Download DS_problem_ac.mw

Otherwise, this error message attains,

  restart;
  DynamicSystems:-SystemOptions('continuoustimevar'=x):
  Error, (in DynamicSystems:-SystemOptions) cannot assign x to
  continuoustimevar, already assigned to statevariable

It's not difficult to make a prodecure that will color and join arbitrary v and k.

The results of printf are usually left-justified. Do you really need left-justified output? Left-justification is also possible. But I won't be around for the next 5 days.

restart;

F := proc(v,k,C) uses Typesetting;
      mrow(mn(sprintf("%s]",v),mathcolor=C),
           mn(sprintf(" is %g",k),mathcolor="Blue"));
end proc:

F("1:1", 4, "Green");

"1:1] is 4"

F("2:2", 1/3., "Red");

"2:2] is 0.333333"

Download color_string.mw

If you use the command plots:-surfdata then you can easily add other (usual) plotting options.

For example, adding an option for orientation so that the X and Y values appear at the forefront.

restart

with(plots):

X := `<,>`(1740, 2200, 2710, 3200, 3700, 4033):

Y := `<,>`(0, 5, 10, 15, 20, 25, 30, 35, 40):

F(X, 0), F(X, 5), F(X, 10), F(X, 15), F(X, 20), F(X, 25), F(X, 30), F(X, 35), F(X, 40) := Vector(6, {(1) = 1.342, (2) = 1.427, (3) = 1.397, (4) = 1.329, (5) = 1.329, (6) = 1.518}), Vector(6, {(1) = 1.449, (2) = 1.382, (3) = 1.303, (4) = 1.362, (5) = 1.379, (6) = 1.397}), Vector(6, {(1) = 1.341, (2) = 1.348, (3) = 1.339, (4) = 1.456, (5) = 1.388, (6) = 1.555}), Vector(6, {(1) = 1.419, (2) = 1.413, (3) = 1.325, (4) = 1.32, (5) = 1.362, (6) = 1.42}), Vector(6, {(1) = 1.486, (2) = 1.336, (3) = 1.449, (4) = 1.382, (5) = 1.534, (6) = 1.665}), Vector(6, {(1) = 1.395, (2) = 1.37, (3) = 1.38, (4) = 1.365, (5) = 1.345, (6) = 1.507}), Vector(6, {(1) = 1.399, (2) = 1.333, (3) = 1.365, (4) = 1.429, (5) = 1.418, (6) = 1.613}), Vector(6, {(1) = 1.343, (2) = 1.331, (3) = 1.306, (4) = 1.375, (5) = 1.63, (6) = 1.692}), Vector(6, {(1) = 1.422, (2) = 1.421, (3) = 1.323, (4) = 1.31, (5) = 1.508, (6) = 1.57})

A := Array(1 .. numelems(X), 1 .. numelems(Y), 1 .. 3, proc (i, j, k) options operator, arrow; `if`(k = 1, X[i], `if`(k = 2, Y[j], F(X, Y[j])[i])) end proc, datatype = hfloat):

surfdata(A, orientation = [-142, 72, 0]);

 

Download curve_three_d_ac.mw

If you use Carl's PLOT3D(MESH(...)) suggestion then you might wrap that result in a call to plots:-display, to add such other options. Eg,

    plot:-display(PLOT3D(MESH(A)), orientation = [-142, 72, 0])

You are not succeeding in constructing the two sets (of scalars or scalar equations) because your indexing into Matrices EQ and V is faulty.

You wrote, "I have a set of equations gathered in a vector." But that is not true. Your EQ is a 4x1 Matrix, and your V is a 1x4 Matrix.

restart

EQ := Matrix(4, 1, {(1, 1) = 32.1640740637930*Tau[1]-0.172224519601111e-4*Tau[2]-0.270626540730518e-3*Tau[3]+0.1570620334e-9*P[1]+0.3715450960e-14*sin(t), (2, 1) = -0.172224519601111e-4*Tau[1]+32.1667045885952*Tau[2]+0.587369829416537e-4*Tau[3]-0.1589565489e-8*P[1]+0.1004220091e-12*sin(t), (3, 1) = -0.270626540730518e-3*Tau[1]+0.587369829416537e-4*Tau[2]+32.1816411689934*Tau[3]-0.7419658527e-8*P[1]+0.5201228088e-12*sin(t), (4, 1) = 0.1570620334e-9*Tau[1]-0.1589565489e-8*Tau[2]-0.7419658527e-8*Tau[3]+601.876235436204*P[1]})

V := Matrix(1, 4, {(1, 1) = Tau[1], (1, 2) = Tau[2], (1, 3) = Tau[3], (1, 4) = P[1]})

q := 0:

X := Matrix(4, 1, {(1, 1) = -0.1156532164e-15*sin(t), (2, 1) = -0.3121894613e-14*sin(t), (3, 1) = -0.1616209235e-13*sin(t), (4, 1) = -0.2074537757e-24*sin(t)})

t := 1:

Xf := fsolve({seq(EQ[r, 1], r = 1 .. 4)}, {seq(V[1, r] = q, r = 1 .. 4)});

{P[1] = -0.1745663328e-24, Tau[1] = -0.9731882592e-16, Tau[2] = -0.2626983734e-14, Tau[3] = -0.1359993176e-13}

{seq(EQ[r, 1], r = 1 .. 4)}

{0.1570620334e-9*Tau[1]-0.1589565489e-8*Tau[2]-0.7419658527e-8*Tau[3]+601.876235436204*P[1], -0.270626540730518e-3*Tau[1]+0.587369829416537e-4*Tau[2]+32.1816411689934*Tau[3]-0.7419658527e-8*P[1]+0.5201228088e-12*sin(1), -0.172224519601111e-4*Tau[1]+32.1667045885952*Tau[2]+0.587369829416537e-4*Tau[3]-0.1589565489e-8*P[1]+0.1004220091e-12*sin(1), 32.1640740637930*Tau[1]-0.172224519601111e-4*Tau[2]-0.270626540730518e-3*Tau[3]+0.1570620334e-9*P[1]+0.3715450960e-14*sin(1)}

{seq(V[1, r] = q, r = 1 .. 4)}

{P[1] = 0, Tau[1] = 0, Tau[2] = 0, Tau[3] = 0}

NULL

Download SoalNewton_ac.mw

restart;

Frac_C:=proc(expr,a,x,alpha)
  local ig,m,tau;
  m:=ceil(alpha);
  ig := (x-tau)^(m-alpha-1)*diff(eval(expr,x=tau),tau$m);
  `assuming`([1/GAMMA(m-alpha)*int(ig,tau=a..x)],[x>a]);
end proc:

Frac_C(x^(3.4),0,x,3/4);
evalf(%);

1.486084413*2^(1/2)*GAMMA(3/4)*x^(53/20)

2.575385653*x^(53/20)

fracdiff((x)^(3.4),x,3/4);

2.575385654*x^(53/20)

Frac_C(cos(x),0,x,1/2);

(cos(x)*FresnelS(x^(1/2)*2^(1/2)/Pi^(1/2))-sin(x)*FresnelC(x^(1/2)*2^(1/2)/Pi^(1/2)))*2^(1/2)

fracdiff(cos(x),x,1/2);

(cos(x)*FresnelS(x^(1/2)*2^(1/2)/Pi^(1/2))-sin(x)*FresnelC(x^(1/2)*2^(1/2)/Pi^(1/2)))*2^(1/2)

Download Frac_C.mw

You could declare gamma as local at the top-level, to avoid conflict with the predefined constant.

You could issue this command at the top of the worksheet.

_local(gamma)

sqrt(1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)

(1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)^(1/2)

simplify((1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)^(1/2))

(cos(alpha(t))^2*cos(gamma(t))^2-cos(gamma(t))^2+1)^(1/2)

NULL

Download arg_removed_ac.mw

One objection that you might have to using normal here is that it will cause expansion of terms like (x+y)^3, etc, which can be unnecessarily expensive or even tricky to undo after the fact. (See first two examples below.) Using numer/denom has a similar issue.

It can be tricky to prevent this by using frontend. Instead, below I temporarily freeze the bases of exponentiated sums.

I do not claim that this will handle all kinds of example that you intend, since we have not been told the full class and the hardest kind of example you want handled.

restart;

F := e->thaw(normal(subsindets(e,'`^`'(`+`,anything),
                               u->`^`(freeze(op(1,u)),op(2,u))))):

 

expr := (x+y)^5/(B*C^3)+C^2;

(x+y)^5/(B*C^3)+C^2

normal(expr);

(B*C^5+x^5+5*x^4*y+10*x^3*y^2+10*x^2*y^3+5*x*y^4+y^5)/(B*C^3)

F(expr);
simplify(%-expr);

((x+y)^5+C^5*B)/(B*C^3)

0

expr2 := (x+y)^5/(B*(C+E)^3)+(C+E)^2;

(x+y)^5/(B*(C+E)^3)+(C+E)^2

normal(expr2);

(B*C^5+5*B*C^4*E+10*B*C^3*E^2+10*B*C^2*E^3+5*B*C*E^4+B*E^5+x^5+5*x^4*y+10*x^3*y^2+10*x^2*y^3+5*x*y^4+y^5)/(B*(C+E)^3)

F(expr2);
simplify(%-expr2);

((x+y)^5+(C+E)^5*B)/(B*(C+E)^3)

0

F(A/B+C);

(B*C+A)/B

Download normal_ex.mw

So, you want to compute antiderivatives, by integrating?

restart;

with(InertForm):

A := ee -> subsindets(int(convert(ee(__t),diff),__t),
                      anyfunc(identical(__t)), u->op(0,u)):

examp := D(y/x);
A(examp);
Display(%D(A(examp)), 'inert'=false);

D(y)/x-y*D(x)/x^2

y/x

0, "%1 is not a command in the %2 package", _Hold, Typesetting

examp := D(x*y);
A(examp);
Display(%D(A(examp)), 'inert'=false);

D(x)*y+x*D(y)

x*y

0, "%1 is not a command in the %2 package", _Hold, Typesetting

examp := D(x^2+y^2);
A(examp);
Display(%D(A(examp)), 'inert'=false);

2*D(x)*x+2*D(y)*y

x^2+y^2

0, "%1 is not a command in the %2 package", _Hold, Typesetting

Download umm.mw

The above applies the input expression to a dummy name, __t. (For some other, as yet unprovided examples it might serve better to initially substitute for application on that dummy.)

For some strange reason pointplot accepts a list of lists, or a list of column Vectors, but not a list of row Vectors.

I changed it below, to use column Vectors.

I used Maple 2021.2 for this.

restart;
with(LinearAlgebra):
with(plots):

EqBIS := proc(P, U, V) local a, eq1, M1, t, PU, PV, bissec1; a := (P - U)/LinearAlgebra:-Norm(P - U, 2) + (P - V)/LinearAlgebra:-Norm(P - V, 2); M1 := P + a*t; eq1 := op(eliminate({x = M1[1], y = M1[2]}, t)); return op(eq1[2]); end proc:

A := <4, 8>;
B := <4, 2>;
C := <1, 4>;
EqBIS(A, B, C);

A := Vector(2, {(1) = 4, (2) = 8})

B := Vector(2, {(1) = 4, (2) = 2})

C := Vector(2, {(1) = 1, (2) = 4})

-5*y-20+15*x

Cen := proc(M, N, R) local eq1, eq2, sol; eq1 := EqBIS(M, N, R) = 0; eq2 := EqBIS(N, M, R) = 0; sol := simplify(solve({eq1, eq2}, {x, y})); return [subs(sol, x), subs(sol, y)]; end proc:
Cen(A,B,C):

CircleParm := t -> [(-t^2 + 1)/(t^2 + 1), 2*t/(t^2 + 1)];

proc (t) options operator, arrow; [(-t^2+1)/(t^2+1), 2*t/(t^2+1)] end proc

P1 := Vector(CircleParm(1/4));

P2 := Vector(CircleParm(5));
P3 := Vector(CircleParm(-1/10));
P4 := Vector(CircleParm(-3/2));

P1 := Vector(2, {(1) = 15/17, (2) = 8/17})

P2 := Vector(2, {(1) = -12/13, (2) = 5/13})

P3 := Vector(2, {(1) = 99/101, (2) = -20/101})

P4 := Vector(2, {(1) = -5/13, (2) = -12/13})

C1 := Vector(Cen(P1, P2, P3));

C1 := Vector(2, {(1) = (1/44642)*(1066*17^(1/2)-255*26^(1/2))*101^(1/2)-(1/442)*26^(1/2)*17^(1/2), (2) = (1/44642)*(156*17^(1/2)-833*26^(1/2))*101^(1/2)+(21/442)*26^(1/2)*17^(1/2)})

Pts := [P1, P2, P3, P4, C1];

Pts := [Vector(2, {(1) = 15/17, (2) = 8/17}), Vector(2, {(1) = -12/13, (2) = 5/13}), Vector(2, {(1) = 99/101, (2) = -20/101}), Vector(2, {(1) = -5/13, (2) = -12/13}), Vector(2, {(1) = (1/44642)*(1066*17^(1/2)-255*26^(1/2))*101^(1/2)-(1/442)*26^(1/2)*17^(1/2), (2) = (1/44642)*(156*17^(1/2)-833*26^(1/2))*101^(1/2)+(21/442)*26^(1/2)*17^(1/2)})]

display(implicitplot([x^2 + y^2 - 1], x = -2 .. 2, y = -4 .. 2, colour = [blue], scaling = constrained), pointplot(Pts, symbolsize = 16));

 

Download jamet_ac.mw

restart;

Relabel := proc(g,s,k) uses GT=GraphTheory;
  GT:-RelabelVertices(g,subs(Equate(s,k),GT:-Vertices(g)));
end proc:

 

with(GraphTheory):

 

G := Graph({{1,2},{1,3},{1,4},{1,5},{3,4},{2,5}}):

 

S := [1,3,5];

[1, 3, 5]

K := [a,1,"[1,2,3,4]"];

[a, 1, "[1,2,3,4]"]

H := Relabel(G,S,K):

 

Vertices(G);

[1, 2, 3, 4, 5]

Vertices(H);

[a, 2, 1, 4, "[1,2,3,4]"]

Download relabel.mw

restart;

convert(U(xi)^2, list, `*`);

[U(xi)^2]

convert(U(xi), list, `*`);

[U(xi)]

convert(U(xi)^2*y(xi)^5, list, `*`);

[U(xi)^2, y(xi)^5]

convert(U(xi)^2*y(xi)^5*p(xi), list, `*`);

[U(xi)^2, y(xi)^5, p(xi)]

convert(U(xi)^2+y(xi)^5, list, `*`);

[U(xi)^2+y(xi)^5]

convert(U(xi)^2+y(xi)^5, list, `+`);

[U(xi)^2, y(xi)^5]

Download convert_list.mw

First 65 66 67 68 69 70 71 Last Page 67 of 337