acer

32405 Reputation

29 Badges

19 years, 349 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

@Earl I missed this before:

You have the assignment,

   libname := "C:\\Users\\earls\\OneDrive\\Documents\\Earl's documents":

which is not OK (unless you've made a full copy of the stock .mla Library archive in that location, eg maple.mla).

What you likely intended was something like,

  libname := "C:\\Users\\earls\\OneDrive\\Documents\\Earl's documents",libname:

which prepends your location to the stock location. That's what I mean by "augment libname" earlier.

As you had it originally, Maple is not able to find its own stock .mla Library files (unless you made the very usual move of actually copying them to that personal folder).

Try `ODEtools/odeadv`, for showstat or stopat.

The ConditionNumber command in the LinearAlgebra package computes or estimates the conditioning w.r.t. solving a linear system Ax=b where A is a Matrix.

You wrote,
    alias(eparm=CirclePramUHG);
but the submodule's export is named CircleParmUHG.

2024-06-29_use_alias_in_a_Sub_Package_ac.mw


nb. You don't have to load the package for your aliases to work.
2024-06-29_use_alias_in_a_Sub_Package_acc.mw


 (alias: love it, or leave it...)

Whether some expression merely contains 1 is not equivalent to whether it equals 1. You shouldn't be using something like that as your check.

You could utilize,
    ormap(`=`, [op(S[1])], 1)
or,
    ormap(is, [op(S[1])], 1)
depending on whether you want to recognize (as 1!) things which are mathemetically equal (a.e.) to 1 but not literally in the form of 1.  Eg, (x^2-1)/((x-1)*(x+1)).

Here I use ormap rather than `or`, so that it efficiently bails out as soon as any first instance is detected.

restart;

foo:=proc(a,{S::list:=[]})
local i,perp::boolean;
if S<>[] then
  if (S[1])=1
    or S[1]::specfunc(typeset) and ormap(is, [op(S[1])], 1) then
     perp:=true;print(perp);
    else
     perp:=false;print(perp);
  end if;
end if;
end proc:

foo(6,S=["cat"]);

false

foo(6,S=[1]);

true

foo(6,S=[typeset("cat=",H/H),align={above,left},color=green]);

true

foo(6,S=[typeset("cat=",H),align={above,left}])

false

foo(6,S=[typeset("cat=",1+H)],align={above,left},color=green);

false

foo(6,S=[typeset("cat=",B/(H+1))]);

false

foo(6,S=[typeset("cat=",B/(H+1),"  height =",1)]); #correct

true

foo(6,S=[typeset("cat=",H^2/((2*H-H)*H),"  height =",B/(H+1))]);

true


Download 2024-06-27_Q_check_inside_typeset_ac.mw


ps. You had a comment about an alternative you'd tried yet which didn't work ok. In principal that was actually much more sound, ie. a test for actual equivalence to 1. Your instinct to try it was good. The problem there was just that your op syntax was faulty. Instead of the faulty,
   op(S[1][i])
you could have had,
   op(i,S[1])
Then it would have worked as you intended.
   2024-06-27_Q_check_inside_typeset_acc.mw
Note however that it is wrapped in a check that is less efficient as well as slightly over-verbose.

[edit] That code would treat a FAIL (from ormap) as if it were a false. If you're ok with that (and I'd guess that is so) then you don't need a special guard against FAIL in that block. The if would handle a FAIL from ormap like a false. I would guess that you'd prefer not to accept a FAIL like a true here. Also, these don't throw an error.

if ormap(is,[false,false,FAIL,true]) then boo; else blech end if;
             boo

if ormap(is,[false,false,FAIL,false]) then boo; else blech end if;
            blech

Here are a few ways to get a list (of lists) instead of your
set (of lists).
 

points1 := { seq([x,evalf[5](sin(x))], x=0..1,0.1) };

{[0, 0.], [.1, 0.99833e-1], [.2, .19867], [.3, .29552], [.4, .38942], [.5, .47943], [.6, .56464], [.7, .64422], [.8, .71736], [.9, .78333], [1.0, .84147]}


First way. Notice that it does convert(...) and not convert~(...)
with a tilde ~ which would make it act elementwise.

convert(points1, list);

[[0, 0.], [.1, 0.99833e-1], [.2, .19867], [.3, .29552], [.4, .38942], [.5, .47943], [.6, .56464], [.7, .64422], [.8, .71736], [.9, .78333], [1.0, .84147]]


Second way

[points1[]];

[[0, 0.], [.1, 0.99833e-1], [.2, .19867], [.3, .29552], [.4, .38942], [.5, .47943], [.6, .56464], [.7, .64422], [.8, .71736], [.9, .78333], [1.0, .84147]]


Third way

[op(points1)];

[[0, 0.], [.1, 0.99833e-1], [.2, .19867], [.3, .29552], [.4, .38942], [.5, .47943], [.6, .56464], [.7, .64422], [.8, .71736], [.9, .78333], [1.0, .84147]]


Alternatively, just create it as a list in the first place,
instead of creating it as a set.

points1 := [ seq([x,evalf[5](sin(x))], x=0..1,0.1) ];

[[0, 0.], [.1, 0.99833e-1], [.2, .19867], [.3, .29552], [.4, .38942], [.5, .47943], [.6, .56464], [.7, .64422], [.8, .71736], [.9, .78333], [1.0, .84147]]

 

Download convert_set_list.mw

Do you mean like this?

tagsCornersPlot :=textplot3d([seq([seq(cornerPoints[1..dim,i]),cornerPoints[1..dim,i]],i=1..4)],
                                               align = {above, right}, font = [Courier, bold, 20]);

You wrote, "Also I was not able to suppress the display of the odesteps on the terminal even though they do not display in worksheet, they still print in the terminal. But this is a side issue.

Why does Latex gives error in command line?"

It's not a side-issue; those two aspects are related. Your ODESteps call is returning NULL in the commandline interface case, and displaying the plaintext as a printing side-effect.

Try this instead, in the commandline.

   the_output:=Student:-ODEs:-ODESteps(ode,y(x),output=typeset):

That should force the same output as you get in the GUI, ie. a blob of typesetting stuff, which latex can deal with. You might also try output=print.

Not all these optional parameters to ODESteps are currently documented, but several of them can be figured out:

showstat(Student:-ODEs:-ODESteps,1);

Student:-ODEs:-ODESteps := proc(ODE0, yx0, {animated::truefalse := false, displaystyle::identical(columns,compact,linear,default) := default, output::identical(print,printf,typeset,canvas,script,list,record,`module`,
  nomodule,default,solution,maple,link) := default})

In the commandline interface the default for output seems to behave just like output=printf, while in the GUI the default seems more like output=print or output=typeset. (I'd guess that canvas might be for MapleLearn...)

You can't assign to the name AngleA inside the procedure triangle of which its a parameter (and has been passed a value).

You could use a local to take on the new value.

You could re-use an existing local, and change,

    AngleA := rad(AngleA_calc);

to,

   AngleA_calc := rad(AngleA_calc);

(and correct the subsequent references to the assigned name) since the procedure doesn't use the pre-rad value any more. Or you could use another local.

And similarly for AngleB,AngleC.

ps. It's inefficient to have procedure triangle redefine procedures rad and deg each time triangle is called. If you want to improve that situation without assigning that pair at the top-level then you could make triangle be an appliable module and have deg and rad be locals of that module. Another approach would be to give such a (global) pair option inline, and keep you code tidier but without the extra overhead.

Let me know if you'd like to all this done, and I'll try and find a moment to edit this Reply (inplace). Do you have an example input you'd like to use?

This is just to address your a) and b).

Your phrasing in a) isn't clear about whether you're interested in any 3rd element being zero (including multiple instances of that), versus exactly one 3rd element being zero. I supposed the former, since you didn't state how the followup indices would be formed in the latter case.

pt := [<1, 1, 1>, <2, 1, 1>, <3, 1, 0>, <4, 1, 1>]:

for i to nops(pt) do if pt[i][3]=0 then break; end; end;
[$i..nops(pt), $1..i-1];

     [3, 4, 1, 2]

You could start by issuing

    kernelopts(numcpus=1):

at the start of your session. (See ?kernelopts)

ps. Being thread-safe is not the same as being deterministic. Neither causes the other in general. (Of course a particular program can easily have one depend on the other -- either way -- but that's certainly not the same as general causation. It's just happenstance and can link any two qualities.)

It's not clear whether you want an animation of a static plot. It's not clear to me whether you want a surface or 3d point-plot, as result.

So I guessed.

restart

with(plottools); with(plots)

points1 := {[0, 1], [0.4e-1, .99920], [0.8e-1, .99680], [.12, .99280], [.16, .98722], [.20, .98006], [.24, .97133], [.28, .96104], [.32, .94922], [.36, .93588], [.40, .92104], [.44, .90472], [.48, .88696], [.52, .86779], [.56, .84723], [.60, .82531], [.64, .80207], [.68, .77755], [.72, .75179], [.76, .72482], [.80, .69669], [.84, .66744], [.88, .63713], [.92, .60580], [.96, .57350], [1.00, .54028], [1.04, .50620], [1.08, .47130], [1.12, .43565], [1.16, .39930], [1.20, .36231], [1.24, .32474], [1.28, .28665], [1.32, .24811], [1.36, .20917], [1.40, .16989], [1.44, .13034], [1.48, 0.90585e-1], [1.52, 0.50685e-1], [1.56, 0.10703e-1], [1.60, -0.29295e-1], [1.64, -0.69245e-1], [1.68, -.10908], [1.72, -.14874], [1.76, -.18817], [1.80, -.22730], [1.84, -.26606], [1.88, -.30440], [1.92, -.34225], [1.96, -.37955], [2.00, -.41625], [2.04, -.45228], [2.08, -.48758], [2.12, -.52210], [2.16, -.55578], [2.20, -.58858], [2.24, -.62043], [2.28, -.65129], [2.32, -.68111], [2.36, -.70983], [2.40, -.73742], [2.44, -.76383], [2.48, -.78902], [2.52, -.81294], [2.56, -.83556], [2.60, -.85684], [2.64, -.87674], [2.68, -.89525], [2.72, -.91233], [2.76, -.92795], [2.80, -.94208], [2.84, -.95471], [2.88, -.96581], [2.92, -.97536], [2.96, -.98334], [3.00, -.98975], [3.04, -.99458], [3.08, -.99781], [3.12, -.99940], [3.16, -.99940], [3.20, -.99783], [3.24, -.99466], [3.28, -.98989], [3.32, -.98354], [3.36, -.97561], [3.40, -.96612], [3.44, -.95509], [3.48, -.94252], [3.52, -.92844], [3.56, -.91288], [3.60, -.89585], [3.64, -.87738], [3.68, -.85752], [3.72, -.83628], [3.76, -.81370], [3.80, -.78982], [3.84, -.76468], [3.88, -.73831], [3.92, -.71076], [3.96, -.68206], [4.00, -.65227], [4.04, -.62144], [4.08, -.58961], [4.12, -.55684], [4.16, -.52317], [4.20, -.48866], [4.24, -.45337], [4.28, -.41736], [4.32, -.38068], [4.36, -.34338], [4.40, -.30553], [4.44, -.26720], [4.48, -.22844], [4.52, -.18931], [4.56, -.14988], [4.60, -.11020], [4.64, -0.70347e-1], [4.68, -0.30381e-1], [4.72, 0.96326e-2], [4.76, 0.49630e-1], [4.80, 0.89547e-1], [4.84, .12932], [4.88, .16889], [4.92, .20818], [4.96, .24714], [5.00, .28571]}

p := pointplot(points1)

f := transform(proc (x, z) options operator, arrow; [x, aa, z] end proc); display(seq((subs(aa = i, eval(f)))(p), i = 1 .. 25), insequence, labels = [x, y, z])

animate(proc (i) options operator, arrow; (transform(unapply([x, i, z], [x, z])))(p) end proc, [i], i = 1 .. 25, frames = 25, paraminfo = false, trace = 25)

display(extrude(p, 1 .. 25, proc (x, y, z) options operator, arrow; [x, z, y] end proc, numsegments = 25, style = point), labels = [x, y, z])

NULL

NULL

Download 2d_to_3d_try_ac.mw

The do-loop to solve and compute the Matrices M[k] (for the k values of Gr) takes 3 seconds on my Maple 2018.2. I also used spacestep=1e-2.

restart;

interface(displayprecision=4):

(inf,Pr,g,Ec):=20,.71,.3,.4: GrVals:=[.1,.5,1.0,1.5]:

OdeSys:={(diff(Theta(xi,eta),eta,eta))/Pr-(diff(Theta(xi,eta),xi))
         -g*(diff(Theta(xi,eta),eta))+Ec*(diff(u(xi,eta),eta))
         *(diff(u(xi,eta),eta))=0,diff(u(xi,eta),eta,eta)-g*(diff(u(xi,eta),eta))
         -(diff(u(xi,eta),xi))+Gr*Theta(xi,eta)=0}:

Cond:={Theta(0,eta)=0,Theta(xi,0)=1,Theta(xi,inf)=0,
       u(0,eta)=0,u(xi,0)=1,u(xi,inf)=0}:

Veta:=<1e-5,seq(0.02..20-0.02,0.02),20-1e-5>:

for k to nops(GrVals) do
  Ans[k]:=pdsolve((eval([OdeSys,Cond],Gr= GrVals[k]))[],
                  numeric,time=xi,spacestep=1e-2,timestep=1);
  All[k]:=subsop(3=remember,Ans[k]:-value(xi=1));
  Ff:=(eta,k)->eval(u(xi,:-eta),All[k](eta));
  Thetaf:=(eta,k)->eval(Theta(xi,:-eta),All[k](eta));
  M[k]:=<<Cf[GrVals[k]]|Nux[GrVals[k]]>,
         <(evalf@D[1](Ff))~(Veta,k)|(evalf@D[1](Thetaf))~(Veta,k)>>;
end do:

final:=<<eta,Veta>|`<|>`(seq(M[k],k=1..nops(GrVals)))>:

final(..10,..);

Matrix(10, 9, {(1, 1) = eta, (1, 2) = Cf[.1000], (1, 3) = Nux[.1000], (1, 4) = Cf[.5000], (1, 5) = Nux[.5000], (1, 6) = Cf[1.0000], (1, 7) = Nux[1.0000], (1, 8) = Cf[1.5000], (1, 9) = Nux[1.5000], (2, 1) = 0., (2, 2) = -1.2340, (2, 3) = -1.0326, (2, 4) = -1.0819, (2, 5) = -1.0420, (2, 6) = -.8922, (2, 7) = -1.0522, (2, 8) = -.7029, (2, 9) = -1.0608, (3, 1) = 0.200e-1, (3, 2) = -1.2038, (3, 3) = -1.0131, (3, 4) = -1.0587, (3, 5) = -1.0215, (3, 6) = -.8777, (3, 7) = -1.0308, (3, 8) = -.6971, (3, 9) = -1.0386, (4, 1) = 0.400e-1, (4, 2) = -1.1743, (4, 3) = -.9939, (4, 4) = -1.0359, (4, 5) = -1.0014, (4, 6) = -.8633, (4, 7) = -1.0097, (4, 8) = -.6912, (4, 9) = -1.0168, (5, 1) = 0.600e-1, (5, 2) = -1.1456, (5, 3) = -.9749, (5, 4) = -1.0137, (5, 5) = -.9817, (5, 6) = -.8492, (5, 7) = -.9891, (5, 8) = -.6851, (5, 9) = -.9955, (6, 1) = 0.800e-1, (6, 2) = -1.1176, (6, 3) = -.9563, (6, 4) = -.9919, (6, 5) = -.9623, (6, 6) = -.8353, (6, 7) = -.9689, (6, 8) = -.6790, (6, 9) = -.9747, (7, 1) = .1000, (7, 2) = -1.0902, (7, 3) = -.9379, (7, 4) = -.9706, (7, 5) = -.9432, (7, 6) = -.8215, (7, 7) = -.9491, (7, 8) = -.6728, (7, 9) = -.9543, (8, 1) = .1200, (8, 2) = -1.0635, (8, 3) = -.9198, (8, 4) = -.9497, (8, 5) = -.9245, (8, 6) = -.8080, (8, 7) = -.9297, (8, 8) = -.6666, (8, 9) = -.9343, (9, 1) = .1400, (9, 2) = -1.0375, (9, 3) = -.9020, (9, 4) = -.9294, (9, 5) = -.9061, (9, 6) = -.7946, (9, 7) = -.9107, (9, 8) = -.6602, (9, 9) = -.9147, (10, 1) = .1600, (10, 2) = -1.0121, (10, 3) = -.8845, (10, 4) = -.9094, (10, 5) = -.8881, (10, 6) = -.7814, (10, 7) = -.8921, (10, 8) = -.6538, (10, 9) = -.8956})


Download Demo_paper_work_1_accc.mw

The first one can be done because simplify can handle the rhs-lhs if n is assumed posint.

restart;

F := subs(__d=rsolve({F(1) = 1, F(2) = 1,
                      F(n + 1) = F(n) + F(n - 1)}, F(n)),
          proc(n) if is(n,posint) then __d;
                  else 'procname'(args); end if; end proc):

cand := F(n + 1)^2 = F(n)*F(n + 2) + (-1)^n;

F(n+1)^2 = F(n)*F(n+2)+(-1)^n

is( simplify( (rhs-lhs)( cand )=0 ) ) assuming n::posint;

true


Download fibo_JAMET_1.mw

I haven't found a way to get zero from rhs-lhs of your G formula.

The answer seems to be due to the difference between applying eval versus limit for the IC.

This is apparently the same behaviour from odetest -- and certainly the same kind of example -- as in this older Question of yours from April 2024. And IIRC you posted another duplicate of that just the other week (though perhaps since deleted).

restart;

e1:=2/x+1/3*sqrt(3);

2/x+(1/3)*3^(1/2)

e2:=simplify(e1);

(1/3)*(3^(1/2)*x+6)/x

eval([e1,e2], x=infinity);

[(1/3)*3^(1/2), 0]

limit~([e1,e2], x=infinity);

[(1/3)*3^(1/2), (1/3)*3^(1/2)]

Download lim_eval.mw

First 19 20 21 22 23 24 25 Last Page 21 of 336