acer

32303 Reputation

29 Badges

19 years, 308 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You can add,

   axis[2]=[location=high]

to you plot options, to get the effect of the tickmarks and label on the other/right/upper side of the vertical axis position on the right.


Or you could add,

   axis[2] = [location=low]

if you'd prefer the label/tickmarks to the left/lower of the vertical axis positioned on the left. (This combination happens to render similar to axes=frame.)

For the images above I also altered your size, just to make it all a bit smaller. In the following attachment the same effect is attained using your original size setting (so you can examine that, to see the automatic tickmark values actually generated).

axis_label_on_wrong_side_of_axis_ac.mw

Here is your original axis effect, that you did not want,

@Ronan In light of a few followup comments it seems that you already had a decent mechanism for adding spacing above or below the symbol, including multiple depths.

And it seems you also want to deal with another problem: that the name you wanted to show/render was already assigned a value.

Note. lowercase `typeset` does nothing to avoid an assigned name evaluating to its assigned value. Rather, that lowercase `typeset` serves mainly to allow you to mix math & text nicely, in plotting contexts.

But Typesetting:-Typeset can indeed turn a name (even if assigned) into a form that will not subsequently evaluate to a value assigned to that name.

So it seems to me that all you need is that Typeset along with "\n" newline characters. eg,

     typeset(Typeset(thename),"\n")

though naturally you can also have the newlines before/above, or multples.

Obscure stuff like that `mover` seem like quite unnecessary over-complication. And it needs more effort to shoehorn in a general expression. And it gets quite awkward (nested) for adding multiple vertical spacing above and below.

ps. single right click uneval quotes alone (to prevent evaluation of an assigned name, eg. 'gamma2') is not generally adequate here, since accidental full evaluation of the plot structure ruins it.

There are many errors in your "chelishkov_comparison" worksheet. Here are some adjutments,

chelishkov_comparison_ac.mw

I don't understand what you intend with your Matrix arithmetic in the other worksheet. It doesn't make sense to me.

@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

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