## 17575 Reputation

14 years, 184 days

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

On stackoverflow.

On math.stackexchange.com.

## idea...

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

 > restart;
 > 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)): lprint(func);

-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),   proc(n::posint)     option remember, system;     local i;     if n=1 then return 1; end if;     __dummy;   end proc):
 > showstat(G);

G := proc(n::posint)
local i;
1   if n = 1 then
2       return 1
end if;
end proc

 > G(100);

 >

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

 > restart;
 > sol:=rsolve({(S(n)-S(n-1))*(2*S(n)-1)=2*S(n)^2,S(1)=1},S(n));

 > A:=unapply(eval(sol-eval(sol,n=n-1)),n);

 > A(100);

 >

## Compiled external library...

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.

## rtable_eval...

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();
[1]
```

## one way...

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

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

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

 >

## try..catch...

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;

## name concatenation...

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("Δ%a", a);

 > lprint(%);

`&Delta;a`

 > cat(':-`Δ`', a);

 > lprint(%);

`&Delta;a`

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

 > lprint(%);

`&Delta;a`

 >

## method=ftocms...

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

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

## speed...

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

## typesetprime=true, typesetting=extended...

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

## assumptions, various ways...

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

limitexample1D.mw

limitexample2D.mw

## some ideas...

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

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

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

 > with(InertForm):
 > Display(ee, inert=false);

 > Display(ff, inert=false);

 > value(ee), value(ff);;

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

 > Value(ee), Value(ff);

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

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

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

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

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

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

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

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

 > value(kk), value(mm);

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

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

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

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

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

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

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

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

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

 >

## scaled...

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

 > detA:= -(-((-16*cosh(beta*`ℓ`*xi[2])*sinh(beta*`ℓ`)+16*sinh(beta*`ℓ`*xi[2]) *cosh(beta*`ℓ`))*sinh(beta*xi[1]*`ℓ`)+(-16*sin(beta*`ℓ`*xi[2])*cos(beta*`ℓ`) +16*cos(beta*`ℓ`*xi[2])*sin(beta*`ℓ`))*sin(beta*xi[1]*`ℓ`)-(16*(-sin(beta*`ℓ` *xi[2])*sin(beta*`ℓ`)+cosh(beta*`ℓ`*xi[2])*cosh(beta*`ℓ`)-sinh(beta*`ℓ`*xi[2]) *sinh(beta*`ℓ`)-cos(beta*`ℓ`*xi[2])*cos(beta*`ℓ`)))*(cos(beta*xi[1]*`ℓ`) -cosh(beta*xi[1]*`ℓ`)))*sin(beta*`ℓ`*xi[2])+16*cos(beta*`ℓ`*xi[2])* ((sin(beta*`ℓ`*xi[2])*sin(beta*`ℓ`)-cosh(beta*`ℓ`*xi[2])*cosh(beta*`ℓ`) +sinh(beta*`ℓ`*xi[2])*sinh(beta*`ℓ`)+cos(beta*`ℓ`*xi[2])*cos(beta*`ℓ`)) *sin(beta*xi[1]*`ℓ`)+(sin(beta*`ℓ`*xi[2])*cos(beta*`ℓ`)-cos(beta*`ℓ`*xi[2]) *sin(beta*`ℓ`))*(cos(beta*xi[1]*`ℓ`)-cosh(beta*xi[1]*`ℓ`))))*sinh(beta*`ℓ`*xi[2]) +16*cosh(beta*`ℓ`*xi[2])*((sin(beta*`ℓ`*xi[2])*sin(beta*`ℓ`)-cosh(beta*`ℓ`*xi[2]) *cosh(beta*`ℓ`)+sinh(beta*`ℓ`*xi[2])*sinh(beta*`ℓ`)+cos(beta*`ℓ`*xi[2]) *cos(beta*`ℓ`))*sinh(beta*xi[1]*`ℓ`)+(sinh(beta*`ℓ`*xi[2])*cosh(beta*`ℓ`) -cosh(beta*`ℓ`*xi[2])*sinh(beta*`ℓ`))*(cos(beta*xi[1]*`ℓ`)-cosh(beta*xi[1]*`ℓ`))) *sin(beta*`ℓ`*xi[2])-(16*(cos(beta*`ℓ`*xi[2])*cosh(beta*`ℓ`*xi[2])-1)) *((sin(beta*`ℓ`*xi[2])*cos(beta*`ℓ`)-cos(beta*`ℓ`*xi[2])*sin(beta*`ℓ`)) *sinh(beta*xi[1]*`ℓ`)+sin(beta*xi[1]*`ℓ`)*(sinh(beta*`ℓ`*xi[2])*cosh(beta*`ℓ`) -cosh(beta*`ℓ`*xi[2])*sinh(beta*`ℓ`))):
 > xi1_val:= 0.05: xi2_val:= 0.10: ell_val:= 12:
 > H := subs([xi[1] = xi1_val, xi[2] = xi2_val, `ℓ` = ell_val], detA):
 > HH := combine(subsindets(combine(H),specfunc(anything,{sinh,cosh}),u->convert(u,exp)));

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

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

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

 >

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.

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

## define?...

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

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

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

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

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

 >

## two possible ways...

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

## something...

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

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