acer

32333 Reputation

29 Badges

19 years, 318 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@tim_finks It was unclear, because your Question here had it as the opposite:

   solve(f=ma,a)

with neither a space nor a multiplication symbol.

Did you enter it as a multiplication, ie. either explicitly as m*a, or implicitly as m space a?

If you entered it as just ma then that's a two-letter name, not a product of two names.

@minhthien2016 You can show the first such equation by,

   Display(temp[1], inert=false) =~ value(temp[1]);

and similarly for the 2nd and 3rd.

You can get all three such equations more directly, in a list, by,

   Display~(temp, inert=false) =~ value(temp);

 

nb. I made a slight ajustment to the original, to utilize Display~ in that elementwise manner, so that its result is still a list.

@Carl Love That multithreaded variant acts in-place on separate portions of the input Array E, which I believe is why there's little-to-no addtional memory usage overhead.

I added option threadsafe to EasterC_Mpl, so that its compiled result EasterC could run in parallel tasks, ie. so its external call was non-blocking. (See ?Compiler) That'd be needed for other kinds of Threads approaches.

I like splitting the tasks with my own routine, so that I can try and tweak the split. Sometimes using numcpus itself seems not quite optimal. Maybe there are also cache effects...

I only mentioned the bookkeeping because I made a slight adjustment to EasterC_Mpl's loop (k from BEGIN to END), and I'd had just the one coffee. That seemed simpler than fiddling with the Array indexing. It seemed reasonably straightforward because EasterC_Mpl already had the useful BEGIN & END parameters.

Your code assigns a procedure to F, so your attempt like invlaplace(F, p, t) doesn't make too much sense.

Did you perhaps intend invlaplace(F(X, Y, p), p, t) instead?

(I mean, after fixing the weird 2D Input issues with the arguments. Try it in 1D Input.)

@Carl Love upvoted.

Did I get the bookkeeping right?

restart;

EasterC_Mpl:= proc(
    BEGIN::integer[4], END::integer[4], R::Array(datatype= integer[4])
) option threadsafe;
local
    Year::integer[4], a::integer[4], b::integer[4], c::integer[4], g::integer[4],
    j::integer[4], gjk::integer[4], Month::integer[4], k::integer[4]
;
    #printf("%ld %ld\n",BEGIN, END);
    for k from BEGIN to END do
        Year:= k;
        a:= irem(Year, 19);
        b:= iquo(Year, 100); c:= irem(Year, 100);   
        g:= irem(19*a + b - iquo(b,4) - iquo(8*b+13, 25) + 15, 30);
        j:= iquo(a + 11*g, 319);
        gjk:= g - j + irem(2*irem(b,4) + 2*iquo(c,4) - irem(c,4) - g + j + 32, 7);
        Month:= iquo(gjk + 90, 25);
        R[k, 1]:= Month;
        R[k, 2]:= irem(gjk + Month + 19, 32)
    od;
    return
end proc:

EasterC:= Compiler:-Compile(EasterC_Mpl):

PartitionTask:=proc(taskname::{name, procedure}, r_low, r_high, partitionsize)
  local r_mid;
  if partitionsize < r_high - r_low then
    r_mid := floor(1/2*r_high - 1/2*r_low) + r_low;
    Threads:-Task:-Continue(':-null', ':-Task' = [PartitionTask, taskname, r_low, r_mid,
                                                  partitionsize, _rest],
                            ':-Task' = [PartitionTask, taskname, r_mid + 1, r_high,
                                        partitionsize, _rest]);
   else taskname(r_low, r_high, _rest); end if;
end proc:

Easter:= proc(BEGIN::integer, END::integer)
local N:= END-BEGIN+1, E:= Array(1..N, 1..2, datatype= integer[4]);
    EasterC(BEGIN, END, E);
    ArrayTools:-Alias(E, [BEGIN..END, 1..2]);
end proc:

EasterTask:= proc(BEGIN::integer, END::integer)
local N:= END-BEGIN+1, E:= Array(1..N, 1..2, datatype= integer[4]);
    #EasterC(BEGIN, END, E);
    Threads:-Task:-Start(PartitionTask,'EasterC',BEGIN,END,
                         floor((END-BEGIN)/(kernelopts(':-numcpus')+2)),E);
    ArrayTools:-Alias(E, [BEGIN..END, 1..2]);
end proc:

E := CodeTools:-Usage(Easter(1, 57*10^5)):

memory used=43.49MiB, alloc change=42.48MiB, cpu time=1.21s, real time=1.21s, gc time=17.62ms

EasterTask(1, 2): # first time overhead
F := CodeTools:-Usage(EasterTask(1, 57*10^5)):

memory used=43.58MiB, alloc change=43.49MiB, cpu time=1.32s, real time=366.00ms, gc time=0ns

LinearAlgebra:-Norm(Matrix(E,datatype=float[8])-Matrix(F,datatype=float[8]));

0.

MD:= md-> local r; [iquo(trunc(lhs(md)),100,r), r] = rhs(md):
T:= (MD~@sort)(Statistics:-Tally(E[..,1]*100+~E[..,2]), key= lhs);

[[3, 22] = 27550, [3, 23] = 54150, [3, 24] = 81225, [3, 25] = 110200, [3, 26] = 133000, [3, 27] = 165300, [3, 28] = 186200, [3, 29] = 192850, [3, 30] = 189525, [3, 31] = 189525, [4, 1] = 192850, [4, 2] = 186200, [4, 3] = 192850, [4, 4] = 186200, [4, 5] = 192850, [4, 6] = 189525, [4, 7] = 189525, [4, 8] = 192850, [4, 9] = 186200, [4, 10] = 192850, [4, 11] = 186200, [4, 12] = 192850, [4, 13] = 189525, [4, 14] = 189525, [4, 15] = 192850, [4, 16] = 186200, [4, 17] = 192850, [4, 18] = 197400, [4, 19] = 220400, [4, 20] = 189525, [4, 21] = 162450, [4, 22] = 137750, [4, 23] = 106400, [4, 24] = 82650, [4, 25] = 42000]

 

Download th_ex.mw

On my Intel i5-7400 Linux machine there seemed to be a sweet spot of about kernelopts(':-numcpus')+2 tasks. YMMV.

Are you still looking to make more progress with this?

@Carl Love It may be possible to programmatically convert a LaTeX export to PDF, using some 3rd party tool on the OS.

@Chico Why is there apparently a multiplication between print and (val) in your second example?

@sursumCorda I see the problem in my Maple 2021.2, but not in my Maple 2020.2.

@delvin Your expression assigned the name fin contains the subexpression Psi(xi[n]) as well as instances in the name Psi.

Therefore it is not a polynomial in Psi. The command degree(fin,Psi) returns FAIL.

Perhaps your intention is to use something like one of these?
  degree(eval(fin, Psi(xi[n]) = Psi), Psi);    # returns 8
  degree(eval(fin, Psi(xi[n]) = _foo), Psi);  # returns 4

I don't see how we are supposed to be able to guess what it is your trying to do there.

Merely trying to get that to be polynomial in Psi by calling series on it seems like it could be a logical mistake to me.

Why don't you explain why you think that expression has a degree in name Psi?

Note that you had somewhat similar difficulties with calling degree in this and that previous, duplicate Question threads.

@sursumCorda We can generate that very terse solution by setting to zero any addends in a (arithmetically expanded) mixed GAMMA & Ei result which are constant w.r.t. x. And we can confirm that result.

f := exp(-beta*x)*x^(5-alpha):

temp := simplify(convert(eval(int(eval(f,alpha=5-a),x),
                               a=5-alpha),Ei));

x^(-alpha)*GAMMA(6-alpha)*(beta*x)^alpha/beta^6-x^(6-alpha)*Ei(-5+alpha, beta*x)

 

That is is sum of terms. Now remove any addend that is constant wrt x.

 

ans := remove(u->diff(u,x)=0,temp);

-x^(6-alpha)*Ei(-5+alpha, beta*x)

 

Check the answer.

 

simplify(expand(diff(ans,x)-f));

0

Download Wh_ex1.mw

For fun, we can also get a GAMMA form, and obtain the previous result from it, and also get form almost as nice without going through and WhittakerM intermediate result, by a change of variables.

And we can check them all, including your tersest form, by expanding the difference of the differentiated result with the original, as an initial step in simplifying.

restart;

f := exp(-beta*x)*x^(5-alpha);

exp(-beta*x)*x^(5-alpha)

H := Int(f,x);

Int(exp(-beta*x)*x^(5-alpha), x)

temp := value(eval(H,alpha=5-a)):

sol1 := simplify(convert(eval(temp,a=5-alpha),GAMMA));
simplify(expand(diff(sol1,x)-f));
 

x^(-alpha)*(beta*x)^alpha*(GAMMA(6-alpha)-GAMMA(6-alpha, beta*x))/beta^6

0

collect(frontend(expand,[sol1]),GAMMA,simplify):
sol2 := map(u->`if`(diff(u,x)=0,0,simplify(u)),%);
simplify(expand(diff(sol2,x)-f));

-x^(-alpha)*(beta*x)^alpha*GAMMA(6-alpha, beta*x)/beta^6

0

sol3 := simplify(convert(sol2,Ei));
simplify(expand(diff(sol3,x)-f));

-x^(6-alpha)*Ei(-5+alpha, beta*x)

0

Q := IntegrationTools:-Change(eval(H,alpha=5-a),(-beta*x)=s,s);

Int(-exp(s)*(-s/beta)^a/beta, s)

sol4 := eval(simplify(value(Q)),[a=5-alpha,s=-beta*x]);
simplify(expand(diff(sol4,x)-f));

-x^(5-alpha)*((GAMMA(5-alpha, beta*x)*(5-alpha)-GAMMA(6-alpha))*(beta*x)^(-5+alpha)+exp(-beta*x))/beta

0

simplify(combine(convert(sol4,Ei))):
collect(frontend(expand,[%]),GAMMA,simplify):
sol5 := map(u->`if`(diff(u,x)=0,0,u),%);
simplify(expand(diff(sol5,x)-f));

x^(5-alpha)*((-5+alpha)*Ei(-4+alpha, beta*x)-exp(-beta*x))/beta

0

Download Wh_ex2.mw

More fun than a barrel of monkeys.

I will submit several bug resports, eg. the original weakness in int, and also that simplify needs the expand to get zero in the checks.

@delvin Please stop spawning wholly separate new duplicate Question threads for this problem. Duplicates get flagged as such and may be deleted.

If you have followup queries, then you could add them here instead.

For example, your latest worksheet DNLS.mw has runtime errors because you've mistakenly used square brackets as if they were expression delimiters. That's a syntax mistake. In Maple, wrapping with square brackets creates a list. Use round brackets as delimiters.  DNLS_ac.mw

You made the same kind of syntax user-error, by using square-brackets incorrectly as demimiters, in this previous, duplicate Question thread.

@delvin I know how to force it into the form you've given.

But the form you've shown is only a partial conversion to hyperbolic-trig form, and it seems a somewhat ad hoc choice, to me. I don't know what is your complete characterization of a class of such problems, from which this choice would follow.

expr := (`&varepsilon;__1`*exp(`&zeta;__1`*phi)+`&varepsilon;__2`*exp(zeta__2*phi))/(`&varepsilon;__3`*exp(`&zeta;__3`*phi)+`&varepsilon;__4`*exp(`&zeta;__4`*phi))

G := eval(expr, [`&varepsilon;__1` = 1, `&varepsilon;__2` = -1, `&varepsilon;__3` = 2, `&varepsilon;__4` = 0, `&zeta;__1` = 1, `&zeta;__2` = -1, `&zeta;__3` = -1, `&zeta;__4` = 0])

(1/2)*(exp(phi)-exp(-phi))/exp(-phi)

subsindets(G, `+`, convert, trigh)

sinh(phi)/exp(-phi)

convert(numer(G), trigh)/denom(G)

sinh(phi)/exp(-phi)

convert(G, trigh)

sinh(phi)/(cosh(phi)-sinh(phi))

simplify(convert(G, trigh))

sinh(phi)*(cosh(phi)+sinh(phi))

convert(expand(G), trig)

(1/2)*(cosh(phi)+sinh(phi))^2-1/2

Download eval_exp_2.mw

First 65 66 67 68 69 70 71 Last Page 67 of 591