acer

32747 Reputation

29 Badges

20 years, 113 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Did you intend a multiplication sign between the first instance of `lambda` and the opening bracket that follows it?

acer

The command that does what you've described (in your followup note to Carl) is `coeff`.

X:=X_FS2(s)=xp0*s+x0:

XP:=diff(X_FS2(s),s)=xp0:

coeff(op(2,X),x0);
                               1

coeff(op(2,XP),x0);
                               0

acer

My 64bit Maple 17.02 Standard GUI on Windows 7 Pro prints only the empty character box as output when I enter the Maple 1D Notation code,

`♕`;

Can this be reduced to a Maple font issue then?

N:=sscanf(`2655`,"%x")[];
                              9813

convert(N,hex);;
                              2655

Hence I actually tried it as,

cat(`&#`,N,`;`);

and of course that could be sprintf'd instead, to get a string rather than a name.

I see that I can get a text plot involving the square-root symbol if I instead do, say,

plots:-display(plots:-textplot([1,1,"√"]));

acer

You have assigned an expression to the name `w`, not a procedure. So it's not appropropriate to then use `w` in a function call such as `w(x)`.

Like `plot` and `evalf(Int(...))` and several other commands, `fsolve` can work with either operator form (procedures, say) or expressions. Mixing these up is a common mistake (so don't feel bad about it).

Hence you could be calling fsolve like,

   fsolve(w = 0, x = kk .. kk+1);

instead of as your original,

   fsolve(w(x) = 0, x = kk .. kk+1);

You might get better performance here by using RootFinding:-NextZero instead of fsolve for this problem. For that you would need to produce an operator (procedure) by unapplying expression `w` with respect to name `x`. And then you could apply `NextZero` repeatedly, such as,

wf:=unapply(w,x):
RootFinding:-NextZero(wf,5);
                          6.584620042

RootFinding:-NextZero(wf,%);
                          12.72324078

RootFinding:-NextZero(wf,%);
                          18.95497141

Or you could use it in a fancier way, such as in my answer here.

Note also that your code using `fsolve` may be doing inadvertant duplication of attempts (when it fails to find a root), due to your particular check of whether `zz` is of type `float`. If you are running this code at the top level then your type check call type(zz,float) is going to repeat each failed attempt where `zz` is the unevaluated function call (to itself) that `fsolve` returns. This code would run faster if the check were like type(eval(zz,1), float) or if the computation were run within a procedure having local variable `zz` instead. The point is that full evaluation of the argument `zz` as the argument of the call to `type` will reevaluate those returned calls to fsolve and so also repeat the failing computations. See here for some notes on this.

acer

Change the instance of Textfield[TFxv] to TextField[TFxv] to correct the typo.

acer

Try it as,

int(diff(w(s),s,s),s=0..L,continuous);

You may wish to convert a result involving both `diff` and `D` to just one or the other.

acer

restart:

assume(x>0,1>x):

L:=[x^3,x^4,x^2,x,1,0];

                            [  3    4    2          ]
                       L := [x~ , x~ , x~ , x~, 1, 0]

sort( L ); # the usual, and not what is wanted

                          [            2    3    4]
                          [0, 1, x~, x~ , x~ , x~ ]

sort( L, (a,b)->is(a<b) );

                          [     4    3    2       ]
                          [0, x~ , x~ , x~ , x~, 1]

sort( L, (a,b)->is(a>b) );

                          [         2    3    4   ]
                          [1, x~, x~ , x~ , x~ , 0]

acer

That should be sin(x) not sinx.

acer

Those should be single left quotes in that call to lprint, but you appear to have them as single right quotes.

You could also do the printing by using printf instead of lprint, ie, replace

lprint(r1, `=`, q, `*`, r2, `+`, r3);

by, say,

printf("%a = %a * %a + %a\n", r1,q,r2,r3);

acer

restart:

MyHandler := proc(operator,operands,default_value)
   NumericStatus( division_by_zero = false );
   return infinity;
end proc:

NumericEventHandler(division_by_zero=MyHandler):

for i in {1, 2/0, -3, 1/4, 5} do
if i::posint then print(i)  fi;
od;

                               1
                               5

select(x->is(x::posint), {1, 2/0, -3, 1/4, 5});

                             {1, 5}

acer

So, something like this?

restart:

lambda0:=PL-R3*x:
Psi0:=PL+R3*S0*(R1-1)-R1*R3*x:
S0:=(Q-1)/Q:

P:=piecewise(x<S0,lambda0,x>S0,Psi0):

plot3d(eval(P,[R3=-5,k=4,R1=0.0006,Q=1.2]),x=0..1,PL=0..1,labels=[x,PL,'P']);

acer

You could try simplification with side relations, ie, see ?simplify,siderels

restart:

ee:=-1/4*m*omega*sin(1/2*omega*T)*(2*cos(1/2*omega*T)^2*xa^2      
    +2*cos(1/2*omega*T)^2*xb^2-xa^2-2*xa*xb-xb^2)/                
    (cos(1/2*omega*T)^2-1)/cos(1/2*omega*T):                      

EE:=simplify(combine(simplify(simplify(ee,                        
             {cos(omega*T/2)^2-1=-sin(omega*T/2)^2}),size)),size);

                                  2     2
                      omega m ((xa  + xb ) cos(omega T) - 2 xa xb)
            EE := 1/2 --------------------------------------------
                                      sin(omega T)

length(ee), length(EE);

                                   247, 113

acer

It's not clear to me whether you also want to keep the collection of scalar products by assigning that to some variable name, or whether you are just interested in the final sum. Below, I presume the latter, but let us know if that's not the case.

If you are asking how to sum all the entries of the elementwise product of Matrices A and B then there are several ways, including,

add(x, x in A*~B);

add(x, x in zip(`*`,A,B));

add( add( A[i,j]*B[i,j], i=1..N), j=1..N );

convert(A,Vector) . convert(B,Vector);

That last way above is slower for default datatype=anything Matrices but faster for datatype=float[8] Matrices.

acer

See the help-page for the interface command, and in particular the setting for warnlevel on thay page.

By invoking interface(warnlevel=1) or interface(warnlevel=0) the warnings about implicitly declared locals should be suppressed.

It's a better idea to declare your locals explicitly, rather than to suppress such warnings. If you leave them only implicitly declared then future readers of your code (a course instructor, colleague, or even you) may be left wondering whether you intended them as locals or as globals and whether your code functions as intended.

acer

You can comstruct an assembly of Embedded Components (Sliders, etc) which does this.

A worksheet with such components can also be run in the free MaplePlayer. Perhaps you can convince your administrator to allow the free player to be installed on the computer connected to the classroom's overhead projector.

One convenient way to construct such Embedded Components in Maple 17, as in your simple case, is to use the Explore command with the invocation shown below.

The attached worksheet looks better in Maple (than it does with its picture inlined into this Answer). It has three Sliders in its bottom half.

 

Explore( plots:-display(plottools:-circle([cx,cy],radius,color=red),
                        view=[-10..10,-10..10]),
         parameters=[cx=-10.0..10.0,cy=-10.0..10.0,radius=0.0..10.0],
         initialvalues=[cx=0.0,cy=0.0,radius=5.0] );

cx:

cy:

radius:

 

 

``

 

Download simplecircle.mw

 

The worksheet that uses Explore for Maple 17 is at the link above.

You could also build such a simple assembly by hand. It's very similar to some introductory examples on Embedded Components in the Help system. Here is one version as another attachment, in the link below. It's assembly of components was constructed by hand. This should run, as is, in Maple 17, 16,.. ,13, 12.

manualcircle.mw

acer

First 251 252 253 254 255 256 257 Last Page 253 of 341