acer

32333 Reputation

29 Badges

19 years, 322 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

In Maple 17.02 I see the addition working that way (without evaluation) as for the multipication. I am not sure why the two now differ in behavior.

So, you want the running value of x in v to be used at each iteration?

restart;

kernelopts(version);

`Maple 2019.1, X86 64 LINUX, May 21 2019, Build ID 1399874`

proc(n::nonnegint)
local x, q, v:= <<x>>, s:= <<0>>, p:= <<1>>;
   for x to n do p:= p.eval(v); s:= s+v od;
   p, s
end proc(6);

Matrix(1, 1, {(1, 1) = 720}), Matrix(1, 1, {(1, 1) = 21})

restart;

proc(n::nonnegint)
local x, q, v:= <<x>>, s:= <<0>>, p:= <<1>>;
   for x to n do p:= p.rtable_eval(eval(v)); s:= s+v od;
   p, s
end proc(6);

Matrix(1, 1, {(1, 1) = 720}), Matrix(1, 1, {(1, 1) = 21})

 

Download matrixevalexample.mw

Here's an outline of the general idea. Adjust to taste.

for i from blah to blech do
    try
        dodgy_thing;
    catch:
        print("error encountered; skipped...");
    end try;
end do;

The name `&Delta;` (which line-prints similar to an HTML entity) gets pretty-printed like a Greek Delta in 2D Output.

You can concatenate that with another symbol of your choice, to get the effect you describe.

restart;

nprintf("&Delta;%a", a);

`&Delta;a`

lprint(%);

`&Delta;a`

cat(':-`&Delta;`', a);

`&Delta;a`

lprint(%);

`&Delta;a`

PutDelta := nm -> nprintf("&Delta;%a", nm):

PutDelta(a);

`&Delta;a`

lprint(%);

`&Delta;a`

 

Download PutDelta.mw

In Maple 2018 and Maple 2019 something similar attains without having to specify method=ftocms for the int command.

Below I use Maple 2017.2,

restart;

kernelopts(version);

   Maple 2017.2, X86 64 LINUX, Jul 19 2017, Build ID 1247392

ig := R^2/(cosh(2*R)+cosh(rho))^2:

res := int(ig, R=-infinity..infinity, method=ftocms) assuming rho::real:

lprint(res);

(1/6)*exp(2*rho)*(-2*exp(2*rho)*Pi^2*rho-2*Pi^2*rho-2*exp(2*rho)*rho^3+2*exp(2*rho)*Pi^2+6*exp(2*rho)*rho^2-2*rho^3-2*Pi^2-6*rho^2)/((exp(2*rho)-1)*(-exp(4*rho)+2*exp(2*rho)-1))

eval(res, rho=1.2);

                         0.07643822467

evalf(Int(eval(ig, rho=1.2), R=-infinity..infinity));

                         0.07643822459

You asked why it goes wrong. It looks like the undesirable infinite result is coming out of the ftoc method (using regular series and limit).

Let's just take a rough look at the indefinite integration result, and compare :-limit vs Multiseries:-limit .

foo := int(ig, R):

limit(foo, R=infinity) assuming rho>0:
op(0,eval(%,1));

                 limit

MultiSeries:-limit(foo, R=infinity) assuming rho>0:
lprint(simplify(%)) assuming rho>0;

-(1/3)*exp(2*rho)*((Pi^2*rho+rho^3-Pi^2-3*rho^2)*exp(2*rho)+Pi^2*rho+rho^3+Pi^2+3*rho^2)/((exp(2*rho)-1)*(-exp(4*rho)+2*exp(2*rho)-1))

alt := MultiSeries:-limit(foo, R=infinity)
       - MultiSeries:-limit(foo, R=-infinity) assuming rho>0:

altres := simplify(alt) assuming rho>0:

lprint(%);

-(1/3)*exp(2*rho)*((Pi^2*rho+rho^3-Pi^2-3*rho^2)*exp(2*rho)+Pi^2*rho+rho^3+Pi^2+3*rho^2)/((exp(2*rho)-1)*(-exp(4*rho)+2*exp(2*rho)-1))

eval(altres, rho=1.2);

                         0.07643822463

[edit] In Maple 2019.1 the result attains for int even with method=ftoc, and :-limit also handles the latter computation.

Why the need to post this in a whole new Question thread? It simply duplicates this earlier topic, and senselessly splits the responses. (And you were provided a few robust and fast ways to compute a floating-point result in Answers in that thread.)

In your definition of operator L you have just speed and not speed(t). But you subsequently redefined speed as an operator. So you have confused expressions and operators.

You may have intended something like,
   L := proc(b) local t; int(speed(t), t = 0 .. b); end proc;

Do you think that symbolic int will be able to handle all your examples or r, for symbolic upper bound b? Why not stick with floating-point approximation as in your previous example?

What are you planning to do when the symbolic integration takes a very long time? Or when the equation involving the symbolic integration result cannot be solved explicitly for name b? Or when -- for nonnumeric upper bound b - the symbolic integration with method=ftoc runs amok while method=elliptic produces a result with special function calls that evaluates more slowly?

What are you really trying to accomplish with this entirely symbolic approach?

In the following attachment I illustrate some of the issues with your approach, and once again demonstrate a fast root-finding approach.

more_sc.mw

For some reason Mapleprimes is not inlining my attachments today.

I am guessing that you are using Maple 2019.

You'll need interface(typesetting) to be set to extended, and Typesetting:-Settings(useprime) to return true.

You can set those as follows,
    interface(typesetting=extended):
    Typesetting:-Settings(useprime=true):

The attachment illustrates your example. It also shows how 2D Output can get the same effect of derivatives using prime notation, and how the dependency can be visibly suppressed in the 2D Output.

typesetprime.mw

Here are some worksheets, with it laid out for you.

limitexample1D.mw

limitexample2D.mw

Here are some ideas, including some various kinds of automatic application.

Note that calling a blanket expand on expressions containing ``() function calls may expand more than you wish. Similarly calling blanket value on expressions containing inert % calls may make more than you wish active.

restart;

kernelopts(version);

`Maple 2018.2, X86 64 LINUX, Nov 16 2018, Build ID 1362973`

ee := (x^3-2*x^2+5*x-7) * x%^(-1);

(x^3-2*x^2+5*x-7)*`%^`(x, -1)

ff := (1/x) %* (x^3-2*x^2+5*x-7);

`%*`(1/x, x^3-2*x^2+5*x-7)

with(InertForm):

Display(ee, inert=false);

(x^3-2*x^2+5*x-7)*`%^`(x, -1)

Display(ff, inert=false);

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

value(ee), value(ff);;

(x^3-2*x^2+5*x-7)/x, (x^3-2*x^2+5*x-7)/x

eval(ee, `%^`=`^`), eval(ff, `%*`=`*`);

(x^3-2*x^2+5*x-7)/x, (x^3-2*x^2+5*x-7)/x

Value(ee), Value(ff);

(x^3-2*x^2+5*x-7)/x, (x^3-2*x^2+5*x-7)/x

restart;

gg := (x^3-2*x^2+5*x-7) * x^``((-1));

(x^3-2*x^2+5*x-7)*x^``(-1)

hh := ``(1/x) * (x^3-2*x^2+5*x-7);

``(1/x)*(x^3-2*x^2+5*x-7)

evalindets(gg,specfunc(anything,``),expand);

(x^3-2*x^2+5*x-7)/x

evalindets(hh,specfunc(anything,``),expand);

(x^3-2*x^2+5*x-7)/x

restart;

`print/%*` := proc()
  InertForm:-Display(`%*`(args), ':-inert'=false);
end proc:

`print/%^` := proc()
  InertForm:-Display(`%^`(args), ':-inert'=false);
end proc:

 

kk := (x^3-2*x^2+5*x-7) * x%^(-1);

(x^3-2*x^2+5*x-7)*`%^`(x, -1)

mm := (1/x) %* (x^3-2*x^2+5*x-7);

`%*`(1/x, x^3-2*x^2+5*x-7)

InertForm:-Value(kk), InertForm:-Value(mm);

(x^3-2*x^2+5*x-7)/x, (x^3-2*x^2+5*x-7)/x

eval([kk, mm], [`%^`=`^`, `%*`=`*`]);

[(x^3-2*x^2+5*x-7)/x, (x^3-2*x^2+5*x-7)/x]

value(kk), value(mm);

(x^3-2*x^2+5*x-7)/x, (x^3-2*x^2+5*x-7)/x

expr := A(x)/(x*y*K^(b));

A(x)/(x*y*K^b)

foo := numer(expr) * denom(expr)%^(-1);

A(x)*`%^`(x*y*K^b, -1)

InertForm:-Value(foo), value(foo);

A(x)/(x*y*K^b), A(x)/(x*y*K^b)

restart;

`print/%/` := proc()
  local num, den, S;
  uses Typesetting;
  if nargs<>2 then return `%/`(args); end if;
  S := {`+`,`*`,specfunc(anything,{Int,int})};
  (num,den) := Typeset(EV(args[1])), Typeset(EV(args[2]));
  if args[1]::S and nops(args[1])>1 then
    num := mfenced(num);
  end if;
  if args[2]::S and nops(args[2])>1 then
    den := mfenced(den);
  end if;
  mrow(num,mo("/"),den);
end proc:

bar := (x^3-2*x^2+5*x-7) %/ (x*y*K^(b));

`%/`(x^3-2*x^2+5*x-7, x*y*K^b)

InertForm:-Value(bar), value(bar);

(x^3-2*x^2+5*x-7)/(x*y*K^b), (x^3-2*x^2+5*x-7)/(x*y*K^b)

blah :=  (x^3-2*x^2+5*x-7) %/ (x);

`%/`(x^3-2*x^2+5*x-7, x)

InertForm:-Value(blah), value(blah);

(x^3-2*x^2+5*x-7)/x, (x^3-2*x^2+5*x-7)/x

boo := Int(f(x),x) %/ (a+b);

`%/`(Int(f(x), x), a+b)

eval(boo, `%/`=`/`)

(Int(f(x), x))/(a+b)

 

Download inert_mult.mw

How about scaling the problem by exp (eg, taken at the largest argument of the present calls to sinh for B>0)? Or something similar.

restart;

kernelopts(version);

`Maple 2019.1, X86 64 LINUX, May 21 2019, Build ID 1399874`

detA:= -(-((-16*cosh(beta*`&ell;`*xi[2])*sinh(beta*`&ell;`)+16*sinh(beta*`&ell;`*xi[2])
*cosh(beta*`&ell;`))*sinh(beta*xi[1]*`&ell;`)+(-16*sin(beta*`&ell;`*xi[2])*cos(beta*`&ell;`)
+16*cos(beta*`&ell;`*xi[2])*sin(beta*`&ell;`))*sin(beta*xi[1]*`&ell;`)-(16*(-sin(beta*`&ell;`
*xi[2])*sin(beta*`&ell;`)+cosh(beta*`&ell;`*xi[2])*cosh(beta*`&ell;`)-sinh(beta*`&ell;`*xi[2])
*sinh(beta*`&ell;`)-cos(beta*`&ell;`*xi[2])*cos(beta*`&ell;`)))*(cos(beta*xi[1]*`&ell;`)
-cosh(beta*xi[1]*`&ell;`)))*sin(beta*`&ell;`*xi[2])+16*cos(beta*`&ell;`*xi[2])*
((sin(beta*`&ell;`*xi[2])*sin(beta*`&ell;`)-cosh(beta*`&ell;`*xi[2])*cosh(beta*`&ell;`)
+sinh(beta*`&ell;`*xi[2])*sinh(beta*`&ell;`)+cos(beta*`&ell;`*xi[2])*cos(beta*`&ell;`))
*sin(beta*xi[1]*`&ell;`)+(sin(beta*`&ell;`*xi[2])*cos(beta*`&ell;`)-cos(beta*`&ell;`*xi[2])
*sin(beta*`&ell;`))*(cos(beta*xi[1]*`&ell;`)-cosh(beta*xi[1]*`&ell;`))))*sinh(beta*`&ell;`*xi[2])
+16*cosh(beta*`&ell;`*xi[2])*((sin(beta*`&ell;`*xi[2])*sin(beta*`&ell;`)-cosh(beta*`&ell;`*xi[2])
*cosh(beta*`&ell;`)+sinh(beta*`&ell;`*xi[2])*sinh(beta*`&ell;`)+cos(beta*`&ell;`*xi[2])
*cos(beta*`&ell;`))*sinh(beta*xi[1]*`&ell;`)+(sinh(beta*`&ell;`*xi[2])*cosh(beta*`&ell;`)
-cosh(beta*`&ell;`*xi[2])*sinh(beta*`&ell;`))*(cos(beta*xi[1]*`&ell;`)-cosh(beta*xi[1]*`&ell;`)))
*sin(beta*`&ell;`*xi[2])-(16*(cos(beta*`&ell;`*xi[2])*cosh(beta*`&ell;`*xi[2])-1))
*((sin(beta*`&ell;`*xi[2])*cos(beta*`&ell;`)-cos(beta*`&ell;`*xi[2])*sin(beta*`&ell;`))
*sinh(beta*xi[1]*`&ell;`)+sin(beta*xi[1]*`&ell;`)*(sinh(beta*`&ell;`*xi[2])*cosh(beta*`&ell;`)
-cosh(beta*`&ell;`*xi[2])*sinh(beta*`&ell;`))):

xi1_val:= 0.05: xi2_val:= 0.10: ell_val:= 12:

H := subs([xi[1] = xi1_val, xi[2] = xi2_val, `&ell;` = ell_val], detA):

HH := combine(subsindets(combine(H),specfunc(anything,{sinh,cosh}),u->convert(u,exp)));

-8*sin(12.00*beta)*exp(.60*beta)-8*sin(10.80*beta)*exp(.60*beta)+8*sin(12.00*beta)*exp(-.60*beta)+8*sin(10.80*beta)*exp(-.60*beta)-8*sin(.60*beta)*exp(12.00*beta)+8*sin(.60*beta)*exp(-12.00*beta)+8*sin(1.20*beta)*exp(11.40*beta)-8*sin(1.20*beta)*exp(-11.40*beta)+8*sin(11.40*beta)*exp(1.20*beta)-8*sin(11.40*beta)*exp(-1.20*beta)-8*sin(.60*beta)*exp(10.80*beta)+8*sin(.60*beta)*exp(-10.80*beta)

map(op,indets(HH,specfunc(anything,exp)));
fact := max(%) assuming beta>0;

{-12.00*beta, -11.40*beta, -10.80*beta, -1.20*beta, -.60*beta, .60*beta, 1.20*beta, 10.80*beta, 11.40*beta, 12.00*beta}

12.00*beta

new := collect(combine(HH/exp(fact)),exp,simplify);

8.*sin(.6*beta)*exp(-24.00*beta)-8.*sin(1.2*beta)*exp(-23.40*beta)+8.*sin(.6*beta)*exp(-22.80*beta)-8.*sin(11.4*beta)*exp(-13.20*beta)+(8.*sin(12.*beta)+8.*sin(10.8*beta))*exp(-12.60*beta)+(-8.*sin(12.*beta)-8.*sin(10.8*beta))*exp(-11.40*beta)+8.*sin(11.4*beta)*exp(-10.80*beta)-8.*sin(.6*beta)*exp(-1.20*beta)+8.*sin(1.2*beta)*exp(-.60*beta)-8.*sin(.6*beta)

Student[Calculus1][Roots](new, 1 .. 15, numeric);

[5.235987756, 10.47197551]

 

Download rootsexp2.mw

You haven't said just how the values of those other parameters may vary, so it's not so easy to be general about handling that.

Alternatively, you could raise the working precision (Digits), but that is slower.

[edit] If you notice that all the terms in new are products involving sin of multiples of 0.6*beta then it's not difficult to see that the roots you've mentioned are at 5*Pi/3 and 10*Pi/3, which concurs with what Axel showed. In Maple 2019.1 the solve command can find those too, if given the expanded form of the expression.

solve({expand(H), beta>0, beta<15});
Warning, solutions may have been lost
           {beta = 5.235987758}, {beta = 10.47197551}

solve({expand(convert(H,rational,exact)), beta>0, beta<15});
Warning, solutions may have been lost
                /       5   \    /       10   \ 
               { beta = - Pi }, { beta = -- Pi }
                \       3   /    \       3    / 

What precisely do you mean by your use of the term define here?

How are you planning on using this Matrix or its entries, such that this effect is seen?

Is it enough to place assumptions on the names that are the values of the entries?

restart;

k:=1: M:=1:

assume(seq(seq(u[i,j]>1,i=1..2*k*M),j=1..2^k*M));

U:=Matrix((2^(k))*M,(2^(k))*M,symbol=u);

Matrix(2, 2, {(1, 1) = u[1, 1], (1, 2) = u[1, 2], (2, 1) = u[2, 1], (2, 2) = u[2, 2]})

map(p->is(p>1), U);

Matrix(2, 2, {(1, 1) = true, (1, 2) = true, (2, 1) = true, (2, 2) = true})

type(U, 'Matrix'(satisfies(p->is(p>1))));

true

andmap(p->is(p>1), U);

true

map(p->sqrt((p-1)^2), U);

Matrix(2, 2, {(1, 1) = u[1, 1]-1, (1, 2) = u[1, 2]-1, (2, 1) = u[2, 1]-1, (2, 2) = u[2, 2]-1})

 

Download symb_mat.mw

I manually inserted the page-breaks using the GUI. Then I exported as PDF.

graphs2.mw

graphs1.mw

The graphs1.mw file uses DocumentTools:-Tabulate. You could optionally call that command so that the interior and/or exterior borders of the Tables were suppressed.

And of course you can play with the number of graphs per row, etc. And you could also adjust the font size for the vertex labels (changing the value that I forced).

The 2D Input for your worksheet's last computation is corrupted and missing in the .mw file.

Here is what I was able to recover. It has only the output for that last computation.

Calculation1_ac.mw

@Jayaprakash J If you are using a version as old as Maple 17 then you should mark that as the product and version when you first submit your Question.  (You have a habit of marking them as Product=Mapleprimes, which is incorrect. I have adjusted this Question.)

In Maple 17 you could execute the following call to Explore.

restart;

f:=1+B*x-(1/12)*B*x^3+0.1666666667e-4*B^3*x^3-4.166666667*10^(-8)*B^4*x^4
+(1/160)*B*x^5+8.333333333*10^(-11)*B^5*x^5-0.5000000000e-2*B^2*x^2
+0.1666666667e-4*B*x^3*C^2-4.166666667*10^(-8)*B*x^4*C^3+8.333333333*10^(-11)*B*x^5*C^4
-0.5000000000e-2*B*C*x^2+0.3333333333e-4*B^2*x^3*C-1.250000000*10^(-7)*B^3*x^4*C
-1.250000000*10^(-7)*B^2*x^4*C^2+3.333333333*10^(-10)*B^4*x^5*C
+5.000000000*10^(-10)*B^3*x^5*C^2+3.333333333*10^(-10)*B^2*x^5*C^3
+0.7291666667e-3*B*x^4*C-0.3333333333e-5*B*x^5*C^2+0.6250000000e-3*B^2*x^4
-0.2083333333e-5*B^3*x^5-0.5416666667e-5*B^2*x^5*C:

F:=(B,C)->plot(eval(f,[:-B=B,:-C=C]),x=-4..4,view=-10..10):

Explore(F(B,C),parameters=[B=-5...5., C=-5...5.]);

Explore won't produce an animation even when called with options, in Maple 17. It produces an interactive interface with sliders which you have to move yourself. If you want an actual animation that can be played then you should answer my query about how you want B and C to change as it plays.

In order to have your package be automatically available by virtue of utilizing a path in libname you need to store the module in a Maple Library Archive file. That means storing it in a .mla file and not a .mpl file.

Try this, in a session in which your package module MyModule is defined,

LibraryTools:-Create("/Users/eduardo/maple/toolbox/personal/lib/MyPackage.mla");
LibraryTools:-Save(MyModule, "/Users/eduardo/maple/toolbox/personal/lib/MyPackage.mla");

And then,

restart;
libname:="/Users/eduardo/maple/toolbox/personal/lib",libname:
with(MyModule);

That leaves the matter of automatically augmenting libname. You wrote of using a .mapleinit file. What Operating System are you using? Is it OS X? Where did you put that file?

If we cannot get an initialization file to work for you then there are alternatives. If your home directory is in fact "/Users/eduardo" then the above LibraryTools calls may make it all work already, without your even having to augment libname as a I did above. That's because toolbox lib directories in the appropriate location get automatically appended to libname by Maple.

 

There seemed to be some unclosed XML elements in line 957 of the .mw file itself. (In the worksheet that seems to be section titled "Øvelse 2.2".

If I add the closing XML tags in manually (in an external editor) then the resulting .mw file loads in the Maple 2019.1 GUI without warning messages. The Sections that follow that now appear, although that particular Section may or may not be what you had originally.

Here is the resulting file:

resmus1.mw

It may be prudent for you to make backups at judicious times as you progress in your ongoing work with this file (with various different filenames).

First 143 144 145 146 147 148 149 Last Page 145 of 336