Carl Love

Carl Love

28095 Reputation

25 Badges

13 years, 101 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Well, two commands that will be useful for that are plots:-animate and sum. The first argument to animate is another plot command. In this case, that should be plot. The second argument is a list that contains the arguments to that plot command, except that there's an animation parameter somewhere. In this case, the animation parameter will be your N. The third argument specifies the range of the animation parameter. In this case, that'll be N= 1..10. The next argument, in this case, must be frames= 10 (because this can't be a continuous animation; only integer values of the parameter make sense).

I'm assuming that the author did not supply the source code with the package, or you wouldn't be asking.

Not all of the following steps are necessarily needed. Let's say you want procedure P1 in package P:

interface(verboseproc= 2);
kernelopts(opaquemodules= false);
lprint(eval(P:-P1));

Now select and copy the output. Paste it to an input prompt, a Code Edit Region, or your own text editor. Your first editting step should be to add the line breaks and indenting.

Here are four things that you can do to get more information. I have listed them in order by how structured the information is, with the most structured first.

1. Set

infolevel[all]:= 5;

That will cause programs to print out additional information of the programmers' choosing. You can use higher or lower numbers for more or less information. Most programs don't use levels higher than 5.

2. Print the code of procedures with showstat:

showstat(int);
showstat(sin);
showstat(cos);

3. Trace the execution of particular procedures with trace:

trace(int);
trace(sin);

4. Trace the execution of everything with printlevel:

printlevel:= 10000:

You can use higher or lower numbers for more or less information.

 

 

For RSA to work, d and e must be multiplicative inverses mod ((p-1)*(q-1)). That is, we must have

e = 1/d mod ((p-1)*(q-1)).

That does not hold for your d and e.

(N,R):= selectremove(has, [a], I);

After executing the above, N will contain the nonreals and R will contain the reals.

The commands codegen:-cost, exprofile, excallgraph, and CodeTools:-Profiling:- may be useful to you.

Since you have provided increments for each variable, each variable takes on only a finite number of values. Hence there are only a finite number of possible evaluations for the profit expressions. Maple can process these quickly. Using the values of the "constants" that you provided, I was able to verify that ProfitB is greater than ProfitC at every evaluation. That is done like this:

restart:
c:= 1/10:  w:= 1/2:  p:= 1:
ProfitB:= (Pb*(p-w)/(1-Pb)-c)*Hb+w*(Pb*(1-Pa)*Hb+Pa*Pb*Hb)+wu*Pa*(1-Pb)*Ha;
ProfitC:= (Pa*(wu-w+Pb*(p-wu))/(1-Pa)-c)*(Ha+Hb)+w*(Pa*(1-Pb)*Ha+Pb*(1-Pa)*Hb+Pa*Pb*(Ha+Hb));

greater:= simplify(ProfitB - ProfitC);

for PB from 0 to 1/4 by 1/40 do
     for PA from 0 to 1/4 by 1/40 while PA < PB do
          for HB from 0 to 50 by 5 do
               for HA from 0 to HB by 5 while HA < HB do
                    for WU from 1/2 to 1 by 1/10 do
                         if eval(greater, [Pb,Pa,Hb,Ha,wu]=~ [PB,PA,HB,HA,WU]) <= 0 then
                              print(PB,PA,HB,HA,WU)
                         end if
                    end do
               end do
          end do
     end do
end do;  

Since there is no output printed, that verifies the result. If you want to supply ranges and increments for the "constants", a similar verification could be coded.

If you plot(v3, y= -1..1), you will see that v3 approaches two different limiting values as y approaches 0 from the left or right. So, Maple's answer of undefined is correct. But, I suppose that you are interested in the limit as y approaches 0 from the right. If you ask Maple directly for this limit, it will return unevaluated. You can also ask for a numeric evaluation of the limit like this:

Digits:= 4:
evalf(Limit(v3, y= 0, right));

That will take a few minutes to compute. The answer I got was 0.9996. You can get a faster result by using Digits:= 3:

Further advice: Change all occurences of int in your worksheet to Int. This will prevent Maple from repeatedly wasting time trying to evaluate integrals that it can't do anyway.

Yes, in Maple any expression whatsoever can be made into an assignable name by enclosing it in single back quotes ` `. However, names created thus won't necessarily display the same way as their mathematical counterparts. If you want it to display the same way, the Answer by Edgardo shows how to do that. However, the names created by that method may be too long to be of practical value.

In the example that you gave with subs, the command whose syntax you're emulating is applyrule, not subs.

applyrule(sin(c::anything)= c, sin(x)+f);

So, applying this to your integrals yields

ex:= Int(x*f(x), x= 0..1) + Int(x, x= 0.. 1/3) + 3*Int(x*f(x), x= 0..2/3):
applyrule(Int(c::anything, d::anything)= c, ex);

Since the value of n is necessarily integer, you won't hit 1 exactly, but you can use a loop to find the nearest integer.

a:= 0.2:  b:= 0.09:  c:= 0.57:  p:= 0.3:  q:= 0.7:
A_n:= ((1+c*p)*a/q+(2+c*p)*b)*product((1+c*q^k)*p, k= 1..n-1)+
     sum((a+b+k*b*q)*product((1+c*q^j)*p, j= k..n-1), k= 2..n):
for N from 2 while eval(A_n, n= N) < 1 do end do;
N;

     7

eval(A_n, n=6);

     0.9567704620

eval(A_n, n= 7);

     1.037279427

Please post your code as plaintext, not as images. That way I won't have to retype your code.

Note that I used sum rather than add above.

 

The line that begins with subimage:=  needs to end with a semicolon (or a colon).

I see that you've chosen to ignore our advice that you switch to 1D input.

Do this:

y:= 2*x^2+7:
plot(eval(y, x= sqrt(x1)), x1= -5..5);

I don't know enough about events to answer whether you're doing it wrong. But you can do what you want by trapping the error in a try ... catch block (see ?try). Something like this:

try
     TOVr(very_big_r)
catch "cannot evaluate the solution further right":
     return TOVr('last')
end try;
error "No dsolve error, use a bigger r";

If you provide your actual code in plaintext or 1D input form, I'll code it for you.

It doesn't come prepackaged, but here's a one-liner procedure to do it. I generalized it so that the base doesn't have to be 10, but defaults to 10.

logspace:= proc(a,b,n,{base:= 10})  evalf(base^~<seq(a..b, (b-a)/(n-1))>)  end proc;

First 271 272 273 274 275 276 277 Last Page 273 of 395