17575 Reputation

29 Badges

14 years, 184 days

On google groups. (comp.soft-sys.math.maple and sci.math.symbolic)

On stackoverflow.


MaplePrimes Activity

These are answers submitted by acer

Did I do this right? (Even if ok, I expect someone will do it more cleverly.)


eq := a(n) = 2*(a(n)+Sum(a(i),i=1..n-1))^2/(2*(a(n)+Sum(a(i),i=1..n-1))-1):

func := solve(eq, a(n)):

-2*Sum(a(i),i = 1 .. n-1)^2/(1+2*Sum(a(i),i = 1 .. n-1))

G := subs(__dummy=subs([Sum=add, a=G],func),
    option remember, system;
    local i;
    if n=1 then return 1; end if;
  end proc):


G := proc(n::posint)
local i;
   1   if n = 1 then
   2       return 1
       end if;
   3   -2*add(G(i),i = 1 .. n-1)^2/(1+2*add(G(i),i = 1 .. n-1))
end proc





[edited] Using rsolve, (for S(n), an idea which Carl conceived and posted before I did).





proc (n) options operator, arrow; 1/(-1+2*n)-1/(-3+2*n) end proc





The call_external is a Maple mechanism which calls a function in an external dynamic library of compiled functions. For example such dynamic libraries have filename extension .dll on MS-Windows and .so on Linux.

Like much of the Maple kernel itself such functions are compiled (and stored in external dynamic libraries) for execution speed, or because they come from 3rd party sources as code in a language other than Maple.

In general it is not possible to view the source of such functions, unless they were compiled with debugging information. (That's an OS thing, rather than a Maple thing.)

Few if any of the stock external libraries shipped with Maple were compiled with debugging information -- and if they were then you'd still need an external debugger that could run the whole process, not just Maple's user-facing debugger.

The Maple command showstat is for displaying source of procedures in the Maple language. That has nothing to do with compiled functions in dynamic libraries.

I was looking at the second paragraph of the first bullet point in the Description of the help page for Topic rtable_eval, which reads as,

    Evaluation is needed provided the following two conditions are met.
    Firstly, eval(A[i],1) <> eval(A[i]) for a given element  "A[i]". Secondly,
    full evaluation must have been applied to A prior to calling rtable_eval(A).

So, for you example, the eval(v) could be before (or within) the rtable_eval call. At the top-level the eval call would not be needed I suppose.

proc() local x, v:= <x>; x:= 1; rtable_eval(eval(v)) end proc(); 

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?



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

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})


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})



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

for i from blah to blech do
        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.


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




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




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







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,



   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:



eval(res, rho=1.2);


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


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:


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


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

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



eval(altres, rho=1.2);


[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.

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,

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.

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

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.



`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)


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


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


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







`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));


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)


`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;
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)



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.



`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])

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)));


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}


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


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

[5.235987756, 10.47197551]



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?


k:=1: M:=1:



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))));


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


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})



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

The 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.

First 11 12 13 14 15 16 17 Last Page 13 of 204