acer

32722 Reputation

29 Badges

20 years, 89 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

The availability and visibility of its interpreted Library code is an aspect of Maple of which I make use almost every day. I can almost always make good sense of the code even without comments. And its transparency gets utilized here on mapleprimes quite regularly too. But your points above almost never make the difference for me, and are pretty irrelevant both for me and to most of the discussions in these forums. Maple's Library visibility seems relevant to its coolness, to me, much more than these other things you mention.

Of course, maybe nobody else cares what I, or you, think is cool.

acer

The availability and visibility of its interpreted Library code is an aspect of Maple of which I make use almost every day. I can almost always make good sense of the code even without comments. And its transparency gets utilized here on mapleprimes quite regularly too. But your points above almost never make the difference for me, and are pretty irrelevant both for me and to most of the discussions in these forums. Maple's Library visibility seems relevant to its coolness, to me, much more than these other things you mention.

Of course, maybe nobody else cares what I, or you, think is cool.

acer

I'm not saying that those are not functional. I'm just pointing out that the (necessary, by definition) domain part of the mathematical notion of a function is missing in Maple procedures and expressions. And, with such a basic concept missing, it seems like a  funny semantic dance to get bogged down in such particularities of the evaluation behaviour as were mentioned.

acer

Alec, you mentioned evaluation of "functions" in this forum post. How do you feel about Maple's having expressions, and procedures, but not mathematical functions with an associated domain?

The help-page ?function just describes a function call. Where in the product's internal help-system (not manuals) does it fully describe domains for mathematical functions, let alone restrictions of domains?

With such a given set up as that, does it really then matter which particular dance steps have to happen, to get evaluation at a point to behave?

acer

Some aspects of Mathematica are the opposite of cool.

acer

Some aspects of Mathematica are the opposite of cool.

acer

Using addressof, once again, one can see that there is an instance of clean in the lexical table which is not the global :-clean. It must be a local.

> d:=[disassemble(addressof(eval(RealDomain:-limit)))]:

> pointto(d[9]);
               r2c_handler, r2c_handler, p, limit, clean, clean

> disassemble(d[9]);
           30, 6522504, 6522344, 6655128, 6539768, 6559816, 6654840

> addressof(:-clean);
                                    6559816

You can also see this using op() to get at the lexical table,

> select(t->type(convert(t,`global`),identical(clean)),
>        [op(7,eval(RealDomain:-limit))]);
                                [clean, clean]
 
> map(addressof,%);
                              [6559816, 6654840]
 
> addressof(:-clean);
                                    6559816

And, mixing and matching the fun and games,

> ToInert(pointto(6654840));
_Inert_ASSIGNEDLOCALNAME("clean", "PROC", 6654840, _Inert_ATTRIBUTE(
 
    _Inert_EXPSEQ(_Inert_EQUATION(_Inert_NAME("modulename"),
 
    _Inert_ASSIGNEDNAME("RealDomain", "MODULE", _Inert_ATTRIBUTE(_Inert_EXPSEQ(
 
    _Inert_NAME("protected", _Inert_ATTRIBUTE(_Inert_NAME("protected"))),
 
    _Inert_NAME("_syslib"))))))))

acer

Are you operating in a Document or a Worksheet? All I can imagine, offhand, is that sometimes there is a muddle in how you are entering the command within a Document.

If you are relatively new to Maple then I suggest using a Worksheet with 1D Maple input (rather than 2D Math input) for your programming experimentation. It makes programming more clear -- what you see is what is there. Perhaps leave Document mode for final presentations (if you need it).

You can open either type of sheet from the top-bar's File menu, and you can even change the default for entry from 2D to 1D under the options menus.

acer

Are you operating in a Document or a Worksheet? All I can imagine, offhand, is that sometimes there is a muddle in how you are entering the command within a Document.

If you are relatively new to Maple then I suggest using a Worksheet with 1D Maple input (rather than 2D Math input) for your programming experimentation. It makes programming more clear -- what you see is what is there. Perhaps leave Document mode for final presentations (if you need it).

You can open either type of sheet from the top-bar's File menu, and you can even change the default for entry from 2D to 1D under the options menus.

acer

Doesn't the procedure use_a() that I posted above produce P(a)?

And it does it quickly too, without having to solve once again for all other discrete solution points X[i].

acer

Doesn't the procedure use_a() that I posted above produce P(a)?

And it does it quickly too, without having to solve once again for all other discrete solution points X[i].

acer

Right you are.

For a 2D Math typeset caption in a plot I got the popup error "TITLE must be a NAME", when trying to export from the maplet plot window under Maple's commandline interface.

The maplet plotter displayed it OK, but its Export function failed.

acer

I didn't make many stylistic adjustments to Taylor5. But I changed a few things about how it works. It is quite a bit faster now, for your example. And hopefully I fixed the second loop, which you had mentioned broke when you removed assignment of the S[k] to outside the loops.

At the end, I give a short procedure which computes p(a), given listlist P of previous data. All it does it search P for the greatest X[i] that is less that 'a'. It relies on the fact that listlist output P from Taylor5 is ordered with respect to P's individual list elements first operands, X[i]. The procedure calls Taylor5 to do just one single step, starting from that located X[i] and ending at 'a'.

restart:

Taylor5 := proc (eqcond::set, fonc::function, A::`=`, n::integer)
local f, h, X, T, k1, k2, k3, k4, i, F1, F2, F3, F4, F5, fct, cond, t, N, bd, bg, S, k;
  if nargs = 4 then N := n else N := 1000 end if;
  cond := op(1, args[1]);
  T[0] := op(1, lhs(cond));
  X[0] := rhs(cond); fct := rhs(op(2, eqcond));
  t := op(1, fonc); bd := op(2, rhs(args[3]));
  bg := op(1, rhs(args[3])); h := (bd-T[0])/N;
  Digits := 24;
  F1 := unapply(fct, [t]);
  f := unapply(fonc, t);
  F2 := D[1](F1); F3 := D[1](F2); F4 := D[1](F3); F5 := D[1](F4);
  k1 := (D[1](f))(t); k2 := diff(k1, t); k3 := diff(k2, t); k4 := diff(k3, t);
  S[1] := simplify(subs(t = T[i], f(T[i]) = X[i], F1(t)));
  S[2] := simplify(subs(k1 = F1(t), t = T[i], f(T[i]) = X[i], F2(t)));
  S[3] := simplify(subs(k1 = F1(t), k2 = S[2], t = T[i], f(T[i]) = X[i], F3(t)));
  S[4] := simplify(subs(k1 = F1(t), k2 = S[2], k3 = S[3], t = T[i], f(T[i]) = X[i], F4(t)));
  S[5] := simplify(subs(k1 = F1(t), k2 = S[2], k3 = S[3], k4 = S[4], t = T[i], f(T[i]) = X[i], F5(t)));
  for i from 0 to N while T[i] <= bd do
    X[i+1] := X[i]+add(evalf(eval(S[k])*h^k/factorial(k)), k = 1 .. 5);
    T[i+1] := evalf(T[i]+h);
  end do;
  h := (T[0]-bg)/N;
  for i from 0 by -1 to -N while bg <= T[i] do
    X[i-1] := X[i]+add(evalf(eval(S[k])*(-h)^k/factorial(k)), k = 1 .. 5);
    T[i-1] := evalf(T[i]-h);
  end do;
  [seq([T[i], X[i]], i = -N .. N)];
end proc:

deq := diff(x(t), t) = 3*x(t)/t+(9/2)*t-13;

ci := x(3) = 6;

st:=time(): P := Taylor5({ci, deq}, x(t), t = -1 .. 4, 1000): time()-st;

plots[pointplot](P);

use_a := proc(a, P, tay)
local jj, res;
  for jj from 1 to nops(P)-1 do
    if P[jj+1][1] > a then
      break;
    end if;
  end do;
  res := tay({x(P[jj][1])=P[jj][2],deq},x(t),t=P[jj][1]..a,1);
  res[-1];
end proc:

st:=time(): use_a(2, P, Taylor5); time()-st;

acer

I didn't make many stylistic adjustments to Taylor5. But I changed a few things about how it works. It is quite a bit faster now, for your example. And hopefully I fixed the second loop, which you had mentioned broke when you removed assignment of the S[k] to outside the loops.

At the end, I give a short procedure which computes p(a), given listlist P of previous data. All it does it search P for the greatest X[i] that is less that 'a'. It relies on the fact that listlist output P from Taylor5 is ordered with respect to P's individual list elements first operands, X[i]. The procedure calls Taylor5 to do just one single step, starting from that located X[i] and ending at 'a'.

restart:

Taylor5 := proc (eqcond::set, fonc::function, A::`=`, n::integer)
local f, h, X, T, k1, k2, k3, k4, i, F1, F2, F3, F4, F5, fct, cond, t, N, bd, bg, S, k;
  if nargs = 4 then N := n else N := 1000 end if;
  cond := op(1, args[1]);
  T[0] := op(1, lhs(cond));
  X[0] := rhs(cond); fct := rhs(op(2, eqcond));
  t := op(1, fonc); bd := op(2, rhs(args[3]));
  bg := op(1, rhs(args[3])); h := (bd-T[0])/N;
  Digits := 24;
  F1 := unapply(fct, [t]);
  f := unapply(fonc, t);
  F2 := D[1](F1); F3 := D[1](F2); F4 := D[1](F3); F5 := D[1](F4);
  k1 := (D[1](f))(t); k2 := diff(k1, t); k3 := diff(k2, t); k4 := diff(k3, t);
  S[1] := simplify(subs(t = T[i], f(T[i]) = X[i], F1(t)));
  S[2] := simplify(subs(k1 = F1(t), t = T[i], f(T[i]) = X[i], F2(t)));
  S[3] := simplify(subs(k1 = F1(t), k2 = S[2], t = T[i], f(T[i]) = X[i], F3(t)));
  S[4] := simplify(subs(k1 = F1(t), k2 = S[2], k3 = S[3], t = T[i], f(T[i]) = X[i], F4(t)));
  S[5] := simplify(subs(k1 = F1(t), k2 = S[2], k3 = S[3], k4 = S[4], t = T[i], f(T[i]) = X[i], F5(t)));
  for i from 0 to N while T[i] <= bd do
    X[i+1] := X[i]+add(evalf(eval(S[k])*h^k/factorial(k)), k = 1 .. 5);
    T[i+1] := evalf(T[i]+h);
  end do;
  h := (T[0]-bg)/N;
  for i from 0 by -1 to -N while bg <= T[i] do
    X[i-1] := X[i]+add(evalf(eval(S[k])*(-h)^k/factorial(k)), k = 1 .. 5);
    T[i-1] := evalf(T[i]-h);
  end do;
  [seq([T[i], X[i]], i = -N .. N)];
end proc:

deq := diff(x(t), t) = 3*x(t)/t+(9/2)*t-13;

ci := x(3) = 6;

st:=time(): P := Taylor5({ci, deq}, x(t), t = -1 .. 4, 1000): time()-st;

plots[pointplot](P);

use_a := proc(a, P, tay)
local jj, res;
  for jj from 1 to nops(P)-1 do
    if P[jj+1][1] > a then
      break;
    end if;
  end do;
  res := tay({x(P[jj][1])=P[jj][2],deq},x(t),t=P[jj][1]..a,1);
  res[-1];
end proc:

st:=time(): use_a(2, P, Taylor5); time()-st;

acer

Hi Mario,

I would like to experiment a little more. Would it be possible for you to upload your later revision of the code?

ps. In an earlier post in this thread, you wrote that you wanted to do something like,

p:=Taylor4(......)
p(a)
plots[odeplot](p)

It was from that that I misunderstood, and got the idea that you would know point 'a' before viewing the plot. I now see that it is the other way around: you first view the plot, and only then (due to some qualitative aspect of the plot, perhaps) know the point 'a' at which you then also want the computation p(a).

There may still be hope. Having computed all the [t[i],X[t[i]]] pairs in the data set, it should be possible to find the largest t[i] smaller than 'a' (or second largest, if the largest is too close to 'a'.) Maybe one could then use that X[t[i]] as a new "initial" point and 'a' as new final point.

acer

First 535 536 537 538 539 540 541 Last Page 537 of 599