acer

32313 Reputation

29 Badges

19 years, 312 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@FDS Do you mean this kind of result?

add(`if`(u::numeric, 1, 0), u = DS);

        418

nops(select(type, convert(DS, list), numeric));

        418

@Carl Love I think you intended eval(phi1, S2[2]) instead of eval(S2[2], phi1) 

I did some extra fiddling there, because I suspect that neither dataplot or plot (for Matrices/Vectors) understand units yet.

But this seems to work, in your Maple 2022.2.

  plots:-pointplot(res, lact, useunits = [Unit(h), 1], style = line)

If you upload and attach your .cvs file then we can reproduce, fix, and demonstrate the whole thing.

You could upload/attach a .zip file, if the Mapleprimes uploader baulks at the .cvs filename extension.

Are you entering it as capitalized Pi, or pi?

Maple interprets Pi as the well-known constant, but pi is just a name with no special meaning to Maple.

If you have some other problem, please explain it more clearly, or upload and attach your worksheet with the green up-arrow in the Mapleprimes editor.

@minhthien2016 Your last example can be handled by,

mylist := [(x - 7)*(x^2 + (-2*m - 30)*x + m), (x - 8)*(x^2 + (-m + 8)*x + 2*m)]

[(x-7)*(x^2+(-2*m-30)*x+m), (x-8)*(x^2+(-m+8)*x+2*m)]

subsindets(mylist,
           And(polynom(anything,x),`+`),
           u->sort(map(normal,u),x));

[(x-7)*(x^2-2*(m+15)*x+m), (x-8)*(x^2-(m-8)*x+2*m)]

Download sgn_ex6.mw

It could save time if you provided your more complicated examples now, rather than staggering them.

@gabbbooooo Please put your followups here, instead of spawning wholly separate new Question threads for them.

@lemelinm There are two different light-gray shades of grid line possible, with one being even lighter than the other. So, when you write, "What I need is to have the light-gray gridline on the x-axis to be only on the values of 3, 6 and 9." I don't know which shade you want.

You could compare these (including zooming, if you want),

plot(0, x = 0 .. 10, y = 0 .. 4, gridlines = true,
     axis[1] = [ tickmarks=spacing(3,0),
                 gridlines=[spacing(30,0),subticks=9] ],
     labels = [x*InertForm:-Display(10)^8*``(Unit(m)), `t `(Unit(s))]);

plot(0, x = 0 .. 10, y = 0 .. 4, gridlines = true,
     axis[1] = [ tickmarks=spacing(3,0) ],
     labels = [x*InertForm:-Display(10)^8*``(Unit(m)), `t `(Unit(s))]);

It's also not clear to me what grid lines you want on the vertical axis.

@FDS Previously you did not mention how you wanted to use the results, so I showed only the simplest way to access the parsed results (as Records whose fields can be access individually).

For comparing them, you could turn each into a Date object.

If you only want to use the Dates for other tasks, then you could sort the new Vector of Dates directly. If you'd also like to sort the earlier parsed results then you could construct the permutation key, which may then be used to reorder either Vector.

restartNULL

dates := Vector(3, {(1) = "9/7/2023", (2) = "12/8/2020", (3) = "10/10/2021"})

times := Vector(3, {(1) = "14:08", (2) = "09:12", (3) = "22:45"})

str := `~`[cat](dates, times)

Vector[column](%id = 36893628358824725308)

G := `~`[StringTools:-ParseTime]("%m/%d/%Y%H:%M", str)

Dts := map(proc (g) options operator, arrow; Date(g:-year, g:-month, g:-monthDay, g:-hour, g:-minute) end proc, G)

Vector[column](%id = 36893628358824709644)


The Date objects can be compared using `<`, so they can be sorted directly.

evalb(Dts[2] < Dts[1])

true


If we no longer need G, we could simply sort Dts
and use these dates from here on.

sort(Dts)

Vector[column](%id = 36893628358824698932)


The following permutation can be used to sort G or Dts.

K := sort(Dts, 'output' = ':-permutation')

[2, 3, 1]

Dts[K]

Vector[column](%id = 36893628358824696756)

G[K]

Vector[column](%id = 36893628358824690380)

NULL

Download StringToDateTime_ac2.mw


ps. The is also a Time command, though I did not need it above. There are Help pages for the Date and Time commands, as well as the Calendar package which has some additional commands for handling Date objects.

@lemelinm Thank you for your kind words.

Sorry, I don't understand your objection to the code from my previous reponse. Aren't the "principal" (major) tickmarks on the x-axis at 0,3,6, and 9?

You might have to upload your worksheet that uses it, and then write more clearly what aspect is wrong.

Isn't the result the same as the image shown in your original Question? Or, was that original actually somehow wrong too?

note. You appear to also want gridlines, and possibly also to zoom in/out? It's not always possible to control how the gridlines appear in the GUI, under zoom, etc. But maybe this is not on-topic. I don't yet understand your objections, and whether it's with the axis-ticks or the gridlines.

ps. If t represents time then wouldn't you also want the s to be Unit(s), so as to be rendered in upright Roman for consistency?

@lemelinm It's not clear what you want done with the x and 10^8, if the Unit(m) is inside brackets.

You can force any specific tickmarks you'd like. Eg,

plot(0, x = 0 .. 10, y = 0 .. 4, gridlines = true,
     axis[1] = [tickmarks=[0,3,6,9], gridlines=[subticks=1]],
     labels = [x*InertForm:-Display(10)^8*``(Unit(m)), `t `(s)])

Or you could specify a spacing between them (with anchoring at, say, zero), so that you get additional multiples shown if you zoom out.

plot(0, x = 0 .. 10, y = 0 .. 4, gridlines = true,
     axis[1] = [tickmarks=spacing(3,0), gridlines=[subticks=1]],
     labels = [x*InertForm:-Display(10)^8*``(Unit(m)), `t `(s)])

See the Help page ?plot,tickmarks

@FDS You now seem to be using the 24-hour convention, so the hour format is %H rather than %l. (See the Help-page for the ParseTime command.) I could not tell which you wanted from your original example.

You can apply the ParseTime command across the Vector using either elementwise syntax or the map command.

StringToDateTime_ac.mw

@Rana47 You yourself provided a formula for u[1], and indeed you assigned that formula to that very name. So that assigned u[1]=0 gives your first cited BC.

By evaluating that assigned name u[1] (which was assigned the formula) at sigma=-sigma and equating to 0, we can produce the formula for your other BC.

When you see something like A=A inside one of the solutions it means that A can take any arbitrary value. For example, in the following solution all the parameters except k and B can take any arbitrary value (except possibly sigma=0). Using this for k and B is all that's needed to satisfy the given BCs.

simplify(eval([u[1], eval(u[1], sigma = -sigma)],
         [B = -1/4*p^3*y^4 - 1/2*y^2*q - A*y, k=-1]));

      [0, 0]

I didn't use your own syntax, u[1](-sigma) = 0, u[1](sigma) = 0 since you assigned an expression rather than an operator to u[1]. Here's the same kind of thing, but with u[1] an operator instead of an expression.  help_c_solve_o.mw

ps. Why do you seem to think that your two BCs might allow all the other parameters to specify both some fixed A and B (with neither arbitrary)?

Note that you could also get something like this formula for A, with B arbitrary.

u[1] := -(-2*p^3*sigma^3*y^4+4*k*p^2*sigma^2*y^3+4*p^2*sigma^2*y^3-3*k^2*p*sigma*y^2-4*q*sigma^3*y^2-6*k*p*sigma*y^2+k^3*y-3*p*sigma*y^2+3*k^2*y+3*k*y+y)/(8*sigma^3)+A*y+B

simplify(solve({u[1] = 0, eval(u[1], sigma = -sigma) = 0}, [A, k], explicit, real, parametric))

[[y <> 0, sigma <> 0, A = (1/4)*(-p^3*y^4-2*q*y^2-4*B)/y, k = -1]]

Download help_c_solve_p.mw

@minhthien2016 Using your list L, you can get the same result using,

   sort~(map~(normal,L),order=plex(x))

as you can using,

   subs('y' = 1, collect(`*`~('y', L), x, normal))

 

You didn't previously provide examples which went from unsorted to sorted (wrt x), so I didn't know it was a requirement.

I have a question. The first entry in your list L appears to be,
     -3*(m - 10)*x^2 + (9*m - 6)*x + x^3
where the coefficient of x^2 is factored and the coefficient of x is not factored. The two methods above will each factor both coefficients. Does that matter to you?

@minhthien2016 Ok, so you already have the expressions in the list assigned to L.

Did you see my previous response,

   map~(normal, L)

First 62 63 64 65 66 67 68 Last Page 64 of 591