acer

32313 Reputation

29 Badges

19 years, 311 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@nm A short variant on your suggestion,

   sort(X,key=(u->parse(String(u)[2..])));

@sand15 The OP has asked a similar question, before. 

The OP's attempt to interpolate this meagre 11x20 grid of data may be ill-judged, with data values that vary so much. The attempt at cubic interpolation may be a poor idea here, introducing large (in magnitude) negative swings that don't characterize the actual data supplied.

@nm Ronan's line,
    use RealDomain in (maple_sol:=solve(eqx,[x]))[] end use;
appears to have misled you.

All that does is this,
    maple_sol:=RealDomain:-solve(eqx,[x])[]

The use...end use mechanism is not a universal way to change the bindings or values of things not present in the input. That's not what it's for or how it works. It's not going to change the value of "solve" or anything else that's already explicitly part of the body of a Library procedure (like PDEtools:-Solve or its internals).

Your "update" portion's example involving,
    use RealDomain in (PDEtools:-Solve(eqx,x)) end use;
does not exhibit a bug.

restart;

pack := module() option package;
  export f := x -> sin(x);
end module:

 

f := x -> x^2:

g := proc(s) f(s); end proc:

 

pack:-f(4);

sin(4)

 

# There's no way this could/should
# produce pack:-f(4) = sin(4)

use pack in g(4) end use;

16

with(pack):

f(4);

sin(4)

# There's still no way this could/should
# produce pack:-f(4) = sin(4)

g(4);

16

Download use_misuse.mw

A bug report has been logged.

This looks to me like it might be an oversight, and I don't think that I prefer it. I've submitted a message of inquiry.

Also, I'm not sure I like this related new variant (even though simplify will turn (x^2)^(1/2) into abs(x) under the real assumption, and has done for ages, and that's fine).

kernelopts(version)

`Maple 2024.0, X86 64 LINUX, Mar 01 2024, Build ID 1794891`

`assuming`([simplify(sqrt(1+sin(x)))], [real])

2^(1/2)*abs(sin((1/4)*Pi+(1/2)*x))

Download simp_2024_ex0.mw

@Ronan I terminated the statement (that contained the procedure call) with a full colon.

That suppresses printing of the return value, as output.

The flavors of visual side-effect (here, tabulated display) is however unaffected by the statement terminator of the proc call. 

For fun, a variety of visual side-effects made during a procedure call.

vis_sd_eff.mw

The print and Tabulate can both display plots and 2D Math, while lprint, printf, userinfo, and WARNING show plaintext.

@Ronan Since your procedure is returning those same values in either case, you could also reducing duplication in the code, by doing,

 ...
 if prnt then
   DocumentTools:-Tabulate([columns,[qqf,q13,q24]],'width'=55);
 end if;
 return qqf,q13,q24;
 end proc:

(I didn't realize, before, that you wanted prnt to toggle-on the Tabulation.)


I'm sorry, I don't understand what you mean about "...a double printing of qqf,q13,q24". I don't see what you think might induce that.

If you add another Reply to that previous thread then it'll get bumped to the top of the "recent" chain, which makes it more noticable.

Deleting the previous Question, to which Edgardo had responded, seems counter-productive (and not great etiquette, IMO).

@Carl Love Your claim is no longer true about the (now) default adaptive=geometric algorithm of the plot command.

And that is the case in both Maple 2023 and Maple 2024.

We can see that this is true because in the OP's Question the attached first plot looks good.

In fact we can run this example (in Maple 2024 with the gridline-coloring option, or in Maple 2023 without it), and demonstrate that the plot command's default/geometric adaptive scheme does in fact sample more at the lower end here, purely because the mode=log option was supplied for the axis.

restart

with(plots)

k := .9787011+(-10.88627-.9787011)/(1+(x/(0.4490702e-3))^1.792529)^.3004597

.9787011-11.8649711/(1+1001898.702*x^1.792529)^.3004597

P := plot(k, x = 10 .. 0.1e7, view = [10 .. 0.1e7, .92 .. .99], color = "Blue", adaptive = true, background = "Ivory", filled = [color = "Cyan", transparency = .9], size = [600, 300])

plots:-display(P, axis[1] = [mode = log])

plot(k, x = 10 .. 0.1e7, view = [10 .. 0.1e7, .92 .. .99], color = "Blue", background = "Ivory", filled = [color = "Cyan", transparency = .9], axis = [mode = log], size = [600, 300])

 

Download plot_geom_log_mode.mw

Yes, plots:-semilogplot is a perfectly fine workaround. But your claim is no longer true that axis= [mode= log] doesn't trigger the regular plot command to sample up front with logarithmic spacing. It does, here.

What happened in Maple2023 for the OP's example is that passing the additional gridline-coloring option broke the code that figured this out.

Your claim is true of the older non-default adaptive=true scheme.

@Ronan You may to have missed this key Reply by Joe Riel in that thread you cited.

Using piecewise is a poor choice here, in terms of performance, given that add's special-evaluation rules let you easily use `if` or ifelse instead.

@Scot Gould  list_making_expression[]  acts like  op(list_making_expression) for something that evaluates to a list, and produces the expression sequence of entries.

restart

kernelopts(version)

`Maple 2024.0, X86 64 LINUX, Mar 01 2024, Build ID 1794891`

M := LinearAlgebra:-RandomMatrix(3)

Matrix(%id = 36893628144023405500)

L := `~`[proc (i) options operator, arrow; M[() .. (), i] end proc]([`$`(1 .. 3)])[]

Vector[column](%id = 36893628144023403084), Vector[column](%id = 36893628144023403204), Vector[column](%id = 36893628144023403324)

N := 3

L := `~`[proc (i) options operator, arrow; M[() .. (), i] end proc]([`$`(1 .. N)])[]

Vector[column](%id = 36893628144023394412), Vector[column](%id = 36893628144023394532), Vector[column](%id = 36893628144023394652)

L := `~`[proc (i) options operator, arrow; M[() .. (), i] end proc]([`$`(1 .. N)])

[Vector[column](%id = 36893628144023384300), Vector[column](%id = 36893628144023384420), Vector[column](%id = 36893628144023384540)]

 

notes on list-to-sequence:

 

T := [a, b, c]

[a, b, c]

T[]

a, b, c

op(T)

a, b, c

 

In a comment you wrote of this, but it only produces the first column.
So it's not what you'd want to use & test.

 

`~`[proc (i) options operator, arrow; M[() .. (), i] end proc](`$`(1 .. N))

Vector[column](%id = 36893628144023372492)

`~`[proc (i) options operator, arrow; M[() .. (), i] end proc](1, 2, 3)

Vector[column](%id = 36893628144023368156)

 

It's a shame that this doesn't work in 2D Input.

 

$5

1, 2, 3, 4, 5

"$5"

Error, invalid `$` operator

"$5"


Download SG_notes.mw

comment: In my Maple 2024.0 the following works for me in 2D Input,

  (i->M[.., i])~([$1..5])[]

though the form with [$5] works for me only in 1D input.

Btw, I'm not sure how you tested but if the square brackets are omitted then don't you get just the first column?

I only mentioned these because elementwise was specifically mentioned. I'd rather not introduce the extra overhead of calling even this simple user-defined anonymous operator N times.

@Scot Gould The following is done as an elementwise operation,

   (i->M[..,i])~([$5])[];

And you can remove the trailing [] if you'd accept a list of the column Vectors.

The following doesn't have a super short form (as an application of zip or `?[]` done elementwise) since M and the list of indexing specs are of different lengths.

   map[2](`?[]`,M,[[..,i]$i=1..5])[];

There are other less terse (and mostly less efficient) ways, some of which I might consider slick.

I don't know that you've going to get much shorter than what I showed in my Answer.

[edit] I had decided not to mention elementwise Vector construction over the listlist conversion of the transpose of the Matrix, since it's overly verbose as well as inefficient.

First 46 47 48 49 50 51 52 Last Page 48 of 591