acer

32333 Reputation

29 Badges

19 years, 319 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The following was done using Maple 2023.0.

Where you see R subscripted by x it was entered as the keystrokes R__x with two underscores, and similarly for y and z subscripts.

restart;

`print/sin` := proc(t) ':-s'(t); end proc:
`print/cos` := proc(t) ':-c'(t); end proc:
(s,c) := sin,cos:

Typesetting:-Suppress(x(t));

Typesetting:-Settings(prime=t):
Typesetting:-Settings(typesetprime=true):
Typesetting:-Settings(useprime=true):

 

R__z := proc (A) options operator, arrow; `<,>`(`<|>`(c(A), s(A), 0), `<|>`(-s(A), c(A), 0), `<|>`(0, 0, 1)) end proc

R__x := proc (A) options operator, arrow; `<,>`(`<|>`(1, 0, 0), `<|>`(0, c(A), -s(A)), `<|>`(0, s(A), c(A))) end proc

R__y := proc (A) options operator, arrow; `<,>`(`<|>`(c(A), 0, s(A)), `<|>`(0, 1, 0), `<|>`(-s(A), 0, c(A))) end proc

 

R__z(psi)

Matrix(%id = 36893628812889702516)

 

simplify(R__x(phi).R__y(theta).R__z(psi))

Matrix(%id = 36893628812889688652)

diff(c(x)*s(x), t)

-(diff(x(t), t))*sin(x(t))^2+cos(x(t))^2*(diff(x(t), t))

diff(c(x)*s(x), t)

-(diff(x(t), t))*sin(x(t))^2+cos(x(t))^2*(diff(x(t), t))

diff(c(x)*s(x), x)

-(diff(x(t), t))*sin(x(t))^2+cos(x(t))^2*(diff(x(t), t))


In case it's not clear from the above, the outputs below do indeed
contain references to sin and cos proper. For instance,

c(x)*s(x)

cos(x(t))*sin(x(t))

`~`[has](%, [sin, cos])

[true, true]

combine(`%%`)

(1/2)*sin(2*x(t))

simplify(s(x)^2+c(x)^2)

1

Download sincos_ts.mw

The code in red above could be tucked away out of sight in a worksheet's Startup Code, accessible via the main menubar's Edit menu.

ps. I could mention that the first three lines of red code, which assigns to (s,c) and the print-extensions, could be replaced by alias, as Edgardo mentioned. My longstanding preference is not to use alias, which is why I didn't mention it earlier. The rest of the red code, the Typesetting calls, accomplish the rest of the aspects you mentioned or showed.

That lengthy result you obtained appears to have a "hidden" division-by-zero in it. I suspect that you might not be able to just simplify that away, given that form.

But the option method=trager to the int command seems to help here.

restart;

kernelopts(version);

`Maple 2023.0, X86 64 LINUX, Mar 06 2023, Build ID 1689885`

ig[1] := 1/(z^2+sqrt(z^4+4*a*z^2)+4*a);

1/(z^2+(z^4+4*a*z^2)^(1/2)+4*a)

ans[1]:=int(ig[1],z,method=trager);

(1/4)*(z-1-(z^4+4*a*z^2)^(1/2)/z)/a

normal( diff(ans[1],z) - ig[1] );

0

ig[2] := -1/(z^2-sqrt(z^4+4*a*z^2)+4*a);

-1/(z^2-(z^4+4*a*z^2)^(1/2)+4*a)

ans[2]:=int(ig[2],z,method=trager);

(1/4)*(1-z-(z^4+4*a*z^2)^(1/2)/z)/a

normal( diff(ans[2],z) - ig[2] );

0

Download int_tr_ex.mw

I don't know all the details of the control flow by which available methods are attempted by default for indefinite integration. I'll submit this example as a bug report.

Consider this counterexample, where x=-1.

ee := (x^(3))^(1/3)

(x^3)^(1/3)

simplify(ee);

(x^3)^(1/3)

simplify(ee) assuming x>=0;

x

r := evala( eval(ee, x=-1) );

1/2+(1/2)*(-3)^(1/2)

simplify(r^3);

-1

simplify( ( -1 )^3 );

-1

simplify( ( 1/2+sqrt(-3)/2 )^3 );

-1

simplify( ( 1/2-sqrt(-3)/2 )^3 );

-1

S := [solve( x^3 = -1, x)];

[-1, 1/2-((1/2)*I)*3^(1/2), 1/2+((1/2)*I)*3^(1/2)]

plots:-display(
  plottools:-circle([0,0],1,color=blue),
  plots:-pointplot([Re,Im]~(S),
                   symbol=solidcircle, symbolsize=20,
                   color=red, size=[300,300]));

Download cbrt.mw

Perhaps a suitable time to review the documentation for the root (esp. 4th and 5th bullet points) and surd commands.

This particular example can be handled in one call to fsolve.

restart;

kernelopts(version);

`Maple 2023.0, X86 64 LINUX, Mar 06 2023, Build ID 1689885`

R := RootOf(_Z*cos(_Z) - sqrt(sin(_Z)^2));

RootOf(_Z*cos(_Z)-(sin(_Z)^2)^(1/2))

arg := eval(op(1,R), _Z=x);

x*cos(x)-(sin(x)^2)^(1/2)

fsolve(arg, x=-6..6, maxsols=infinity);

-4.493409458, -2.028757838, 0., 4.913180439

fsolve(arg, x=-6..6, maxsols=infinity, method=NextZero);

-4.493409458, -2.028757839, 0., 4.913180439

Download rf_ex.mw

note: Given a numeric rootfinder, some example can be found that defeats it.

The contents of the Favorites palette are stored in a location on one's Operating System, somewhat similarly to how one's Maple GUI preferences are saved.

They are not saved inside an individual .mw file.

Also, Maple preferences are stored on the local computer, say, not in the cloud.

The contents of the palettes is part of the GUI itself, not the document.

Once you've created the plot using geometry:-draw, you could merge it with other kinds of plots in the usual way, ie. using plots:-display.

restart; with(geometry)

point(B, 2, 0)

B

form(B)

point2d

coordinates(B)

[2, 0]

The following uses geometry:-draw

draw(B)draw(B)

draw(B, color = blue, symbol = solidcircle)

NULL

Download plotpoint_ac.mw

You can replace those function calls (of t). You could do it using evalindets, and also with eval and a set/list of replacements.

This targets those particular names, but it'd also work if you had terms like sin(t), etc, leaving those alone.

problem_ach_ac.mw

restart;

with(LinearAlgebra):

n := Vector[row]([cos(theta(x, y, t)), sin(theta(x, y, t))]);

Vector[row](2, {(1) = cos(theta(x, y, t)), (2) = sin(theta(x, y, t))})

add(n[i]^2, i = 1 .. 2);

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

 

The next automatically simplifies to the previous...

 

add(n[i]*n[i], i = 1 .. 2);

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

 

If your Vector has just two entries, then isn't the next
simplest as well efficient?

 

n[1]^2+n[2]^2;

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

 

The next two work, but are unnecessarily complicated
because there's no great reason here to use Multiply(n[i],n[i]),
where Multiply is a LinearAlgebra command, since each n[i]
is just a scalar.

 

add(Multiply(n[i], n[i]), i = 1 .. 2);

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

sum('Multiply(n[i], n[i])', i = 1 .. 2)

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

 

Alternatives...

 

DotProduct(n,n,conjugate=false);

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

 

The next each unnecessarily produce a temporary
Vector as garbage for memory management.

 

n.n^%T;

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

add(n*~n);

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

add(n^~2);

cos(theta(x, y, t))^2+sin(theta(x, y, t))^2

Download vec_dot_add.mw

Is this the kind of thing you meant?

eq := diff(w(x), x, x) = F*(6*(-a^2/(2*L^2) + a^3/(3*L^3))*x + 2*a^2/L - a^3/L^2)/EI;

diff(diff(w(x), x), x) = F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI

(lhs=simplify@value@rhs)(map(Eval,eq,x=L));

Eval(diff(diff(w(x), x), x), x = L) = -F*a^2*(L-a)/(L^2*EI)

Download comp_map.mw

Do you mean something like this, to get that data into the columns of B?

  M0:=Edges~(graphs);
  M1:=Girth~(graphs);
  M2:=Diameter~(graphs);
  B := <<M0>|<M1>|<M2>>:

And then, as you had it,

  Export(..., B);

or, say,

  Export(..., B, format="delimited"):

or some flavour of call to ExportMatrix, etc.

Here are three straightforward ways to map that operation across your ptlist,

   (u->TransMatrix.u)~(ptlist);

   map(u->TransMatrix.u, ptlist);

   map[2](`.`, TransMatrix, ptlist);

Are you trying to accomplish something like this, using the command Physics:-diff to differentiate wrt the function call u(t)?

note: what you showed in plaintext is not valid 1D Maple Notation code, so I've guessed at what you might have intended. Adjust as needed.

restart;
H:=(y,u,t)->y(t)^2+u(t)^2+1/(2)(x(t))^(4) +(`&PartialD;/&PartialD; x`)(V(t))*u(t):

Physics:-diff(H(y,u,t), u(t));

   2*u(t)+(`&PartialD;/&PartialD; x`)(V(t))

H:=(y,u,t)->y(t)^2+u(t)^2+1/(2)(x(t))^(4) + Diff(V(t),x)*u(t):

Physics:-diff(H(y,u,t), u(t));

        2*u(t)+Diff(V(t),x)

You haven't shown us your actual expression. But you might be able to temporarily substitute for x-x0, then collect, then resubstitute.

Btw, your attempt using abs(x-x0) works as a specialized case of collecting wrt just abs.

restart;

expr := c*abs(x-x0) + d*abs(x-x0) + a*(x-x0) + b*x -b*x0 + abs(u) + e*abs(u);

c*abs(x-x0)+d*abs(x-x0)+a*(x-x0)+b*x-b*x0+abs(u)+e*abs(u)

collect(expr, abs(x-x0));

(c+d)*abs(x-x0)+a*(x-x0)+b*x-b*x0+abs(u)+e*abs(u)

collect(expr, abs);

(1+e)*abs(u)+(c+d)*abs(x-x0)+a*(x-x0)+b*x-b*x0

collect(exp, x-x0);

Error, (in collect) cannot collect x-x0

rev := v=x-x0;
temp := algsubs(x-x0=v, expr);

v = x-x0

c*abs(v)+d*abs(v)+e*abs(u)+a*v+b*v+abs(u)

eval( collect(temp, v), rev );

(a+b)*(x-x0)+c*abs(x-x0)+d*abs(x-x0)+e*abs(u)+abs(u)

# now also target abs(x-x0)
eval( collect(temp, [v,abs(v)]), rev );

(a+b)*(x-x0)+(c+d)*abs(x-x0)+e*abs(u)+abs(u)

# now also target all abs calls
eval( collect(temp, [v,abs]), rev );

(a+b)*(x-x0)+(1+e)*abs(u)+(c+d)*abs(x-x0)

Download collect_algsubs.mw

The results from implicitplot3d often look clunky, and sometimes edges inaccurately appear rounded, unless the sampling grid option is set so high that the GUI becomes sluggish when they are manually rotated, etc. It is an inefficient mechanism. It is a poor choice for handling this example.

I prefer to use plot3d when possible. Or, in this case, the tetrahedron plotting command can be used and produce an even more lightweight result.

Both of those can produce a much better rendition here than does implicitplot3d

restart;

with(plots): with(plottools):

display(tetrahedron([[0,0,0],[0,1,1],[1,1,1],[0,0,1]]), labels=[x,y,z]);

G := plot3d(y-1, x=0..1, y=x..1, filled, style=surface):
R := transform((x,y,z)->[x,y,z+1])(G):
display(R, labels=[x,y,z], glossiness=0);

Download tetra.mw

Unfortunately shadebetween cannot handle a variable range end-point. Hence my alternative was to fill a plot3d of y-1 and then raise by 1.

Using seq is not the most efficient and convenient way to do this.

But you asked about it, so I'll answer the question as given.

In later versions you could do it in 1D Input as,

  seq(seq( if a[i,j]<0.2 then a[i,j]:=0 end if,i=1..20),j=1..20):
  a;

Otherwise you could do it as,

   seq(seq(`if`(b[i,j]<0.2,assign('b[i,j]',0),NULL),i=1..20),j=1..20);
   a;

There are other variants.

First 45 46 47 48 49 50 51 Last Page 47 of 336