Joe Riel

9660 Reputation

23 Badges

20 years, 0 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Try the following
i := diff(q(t),t);
KirchoffLaw:=E[R]+E[L]+E[C]-E[emf]=0;
E[R]:=R*i;
E[L]:=L*diff(i,t);
E[C]:=1/C*q(t);
KirchoffLaw;
et := convert(piecewise(t<1,0,t<3,100,0),Heaviside);
odeQ := eval( KirchoffLaw, {E[emf]=et,R=50,C=0.01,L=1});
ics:=q(0)=0, D(q)(0)=0;
dsolve({odeQ,ics},q(t));
Check out the VectorCalculus package (?VectorCalculus). The ?examples,VectorCalculus worksheet gives examples of line integrals.
In the Standard GUI you can create symbols with arrows over them. Open the Layout palette, insert the Symbol with the `b' over the `A', then open the Arrows palette and change the `b' to the desired arrow shape. If you use lprint to print the Maple output, you can see how to create this via typing. The code inserted by the palettes contains optional fields to set the colors. If you are happy with the defaults you can omit them and then do, for example:
xvec := `#mover(mi("x"),mo("&rarr;"))`;
That displays xvec as an x with a right pointing arrow on top. Now, if you actually want to assign a Vector to the fancy x, things get a little tricker. Messing with the palettes gets tedius, so, you could set an alias (see ?alias for details). Using worksheet mode in the Standard GUI you could do
restart:
alias(`#mover(mi("x"),mo("&→"))` = xvec):
If you then type
xvec := <1,2,3,4>;
an assignment is displayed with the left side being the x with the arrow over it, the right side being the Vector. This can also be done in Document mode, but because the left side of assignments are normally suppressed, the x with an → over it is not shown, so there isn't much point. To simplify the process you can assign a procedure
MakeVector := x ->  nprintf("#mover(mi(\"%A\"),mo(\"&rarr;\"))", x):
then use it as
alias(MakeVector(x) = xvec, MakeVector(y) = yvec):
xvec := <1,2,3>;
yvec := <4,5,6>;
I'll assume that you are looking for a numeric, rather than symbolic, solution (good luck with the latter). The following works: y := sin(x)/x: dy := diff(y,x): sol := fsolve(dy,{x},0..10); # the third parameter restricts the domain sol := {x = 4.493409458} eval(dy,sol); # check the result 1*10^(-11) eval(y,sol); # evaluate the expression -0.2172336282
Here's one way, probably not the best.
tmp := Int(D[3](F)(x,t,y(x,t),diff(y(x,t),x),diff(diff(y(x,t),t),x))(diff(yv(x,t),t,x)),t):
tmp2 := convert(tmp,D):
indets(tmp2, typefunc(anything, typefunc(identical(yv),specindex(posint,D)))):
convert(%,diff);
                  {diff(yv(x, t), x, t)}

Your observation is correct, collect works with power of integers, not symbolics. For the simple example you gave, factor will do nicely. However, consider

poly := a*x^b + x^b + a*x^(b+1) + c*x^(b+1);

The collect command can also handle unevaluated function calls, so one approach is to convert the monomial terms to function calls, collect, then convert back:

subsindets(poly, identical(x)^anything, () -> f(op(args)));

         a*f(x, b) + f(x, b) + a*f(x, b + 1) + c*f(x, b + 1)

collect(%,f);

                (a + 1)*f(x, b) + (a + c)*f(x, b + 1)

eval(%, f=`^`);

                 (a + 1)*x^b + (a + c)*x^(b+1)
An easy way to express the surface is in cylindrical coordinates. Thus,
plot3d(1/z, theta=0..2*Pi, z = 1..20, coords=cylindrical);
should do the trick.
It cannot. A 1x1 matrix (or Matrix) is not a scalar. Consider the product of three vectors/covectors: (mx1)(1xn)(nx1). You want to rearrange this as (1xn)(nx1)(mx1). However, if that were done, then associativity wouldn't hold, that is, (nx1)(mx1) is undefined.
Use LinearAlgebra:-Equal to test equality of Matrices (with expressions as elements). For more general testing, you can use verify (with appropriate verification argument).
with(LinearAlgebra):
A := <<1,2>>:
B := Copy(A):
Equal(A,B);
             true

A := <<1,2>>:
B := <<1.001, 1.99>>:
verify(A,B,'Matrix'(float(5,digits=3)));
                                     true

verify(A,B,'Matrix'(float(5,digits=4)));
                                     false
Use exp(x) for e^x
Yes. Explain what it is you want to do.
Your comments are basically correct. The statement (x -> x.x)(procname(x,n/2)) passes the argument procname(x,n/2) to the anonymous procedure x -> x.x. It is equivalent to doing tmp := procname(x,n/2); tmp.tmp but avoids the local variable tmp. The reason that . was used rather than * is to allow this to work with Matrices: Pow(<<1|2>,<3|4>>,-2); [11/2 -5/2] [ ] [-15/4 7/4 ]
Here's one approach:
> M := Matrix([[x,0],[0,y],[y,0],[0,x]]);
                                      [x    0]
                                      [      ]
                                      [0    y]
                                 M := [      ]
                                      [y    0]
                                      [      ]
                                      [0    x]

> DM := map(v -> `if`(v=0,0,rcurry(diff,v)),M);
                    [() -> diff(args, x)             0         ]
                    [                                          ]
                    [         0             () -> diff(args, y)]
              DM := [                                          ]
                    [() -> diff(args, y)             0         ]
                    [                                          ]
                    [         0             () -> diff(args, x)]

> map(apply,DM,x^2+y);
                                 [2 x     0 ]
                                 [          ]
                                 [ 0      1 ]
                                 [          ]
                                 [ 1      0 ]
                                 [          ]
                                 [ 0     2 x]
This doesn't solve the problem of applying it to a Matrix.
As Roman suggests, create a procedure rather than a polynomial. However, if you have already created the polynomial, you then need to convert it to a procedure. The procedure unapply is useful here.
P := a*x1^2 + 3*x2^2 + b:
f := unapply(P, [x1,x2]):
f(z1,z2);
            a*z1^2+3*z2^2+b
Note that your example use of eval is incorrect. Proper usage is eval(P, [x=1,y=2]).
> LengthU := norm(u,2);
                         2
First 110 111 112 113 114 Page 112 of 114