acer

32343 Reputation

29 Badges

19 years, 328 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

See an Answer to a recent Question.

It would be better if you showed us explicitly what you tried.

You can use the green up-arrow in the Mapleprimes editor to upload and attach a worksheet.

restart;
kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jun 8 2020, Build ID 1474533`

solve({log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2,x>=-7*Pi/2,x<=-2*Pi}, explicit, allsolutions); # Example 1 - strange error message

{x = -(10/3)*Pi}, {x = -(7/3)*Pi}

solve({log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2,x>=-7*Pi/2,x<=-2*Pi}, real, explicit, allsolutions);

{x = -(10/3)*Pi}, {x = -(8/3)*Pi}, {x = -(7/3)*Pi}

solve({log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2,x>=-4*Pi,x<=-2*Pi}, explicit, allsolutions);  # Example 2 - two roots missing

{x = -(11/3)*Pi}, {x = -(10/3)*Pi}

solve({log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2,x>=-4*Pi,x<=-2*Pi}, real, explicit, allsolutions);

{x = -(11/3)*Pi}, {x = -(10/3)*Pi}, {x = -(8/3)*Pi}, {x = -(7/3)*Pi}

Student:-Calculus1:-Roots(log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2,x=-4*Pi..-2*Pi);

[-(11/3)*Pi, -(10/3)*Pi, -(8/3)*Pi, -(7/3)*Pi]

Download bsolve_2020.1.mw

The Calculus1:-Roots command tries several variant calls to solve. It also uses _EnvSolveOverReals=true which gives the same effect as passing the real option. I know that the real option is currently only properly documented under solve,parametric, but in fact it has some beneficial effects in some univariate cases without parameters.

[edit] Of course, supplying the real option alongside the allsolutions option should not be necessary in the presence of the inequalities which denote a real-range.

@Kitonum In my Maple 2020.1,

restart;
kernelopts(version);

  Maple 2020.1, X86 64 LINUX, Jun 8 2020, Build ID 1474533

assume(x, 'real'); assume(y, 'real');
verify(x^2 - x*y + y^2, 0, {'greater_equal'});

                 true

is(x^2 - x*y + y^2>=0);

                 true

restart;
verify(x^2 - x*y + y^2, 0, {'greater_equal'}) assuming x::real, y::real;

                 true

is(x^2 - x*y + y^2>=0) assuming x::real, y::real;

                 true

@KGaurav08 Something like this or this?

@Panas95 So that leaves the matter of why it worked for me but not for you. Do the commands I showed produce the same results in your Maple 2019? If not, were there any other assignments or assumptions on x or y in your problematic session?

@Carl Love Your commentary about precedence for unbracketed input may be true, but it is not directly relevant to the OP's example. Your comments about problems with precedence and parsing or inert operators input are not what went wrong in the OP's example.

The ife expression (containing inert operators) in the OP's example is properly nested, and comes from parsing (with precedence properly respected) of a string onvolving non-inert operators.

The problem in the OP's original example is in the typesetting of the properly nested inert operator expression, not in any parsing of an earlier input or representation.

The "more-important bug" that you describe is not what cause the OP's problematic typesetting here.

The "more-important bug" that you describe relates to parsing of 1D input. The OP's problem was in lack of bracketing in typesetting of 2D output.

@wswain You have misunderstood my subsindets calls, I'm afraid.

Let's look at this call:

   subsindets(convert(Array3[1, 2..], list), string, u -> u[5..])

The first argument is convert(Array3[1, 2 .. ()], list) , which produces a list.

The second argument, string, is not a transformer. It is a type, that subsindets uses to distinguish which subexpressions to transform.

The third argument, u -> u[5..] is the transformer.

There is no fourth argument there, ie. none like rest in the Calling Sequences on the subsindets Help page.

I could see that the only strings in the first row were the ones with the substring prefix "RPM " which I wanted to remove. I could also have used StringTools:-Drop, or a few other StringTools commands. It seemed to me that indexing was simpler. Eg,

ee := "RPM 101 - 200":
ee[5..];

             "101 - 200"

StringTools:-Drop(ee, 4);

             "101 - 200"

Contrary to your followup query's claim, I did not convert the entries of Array3[1, 2..] to strings. They already were strings.

I could also have used map directly on the entries of that particular sub-Array, instead of having subsindets target its subexpressions of type string (which happened to be all that sub-Array's entries, anyway). Eg, using that Array3, these last three lines accomplish the same thing.

L := convert(Array3[1,2..],list):
subsindets(L, string, u->u[5..]);
map(u->u[5..], L);
map(`?[]`, L, [5..]);

There are often several ways to accomplish manipulations. I didn't think much about which might be best here -- whatever "best" means.

Your example is small, and you might not need the code to scale up. At some point you may choose to balance between legibility, flexibility, and efficiency.

[edit] I am not a big fan of arcane and slick functional programming if the efficiency needs don't demand it. I don't think that it's highly legible for newcomers to Maple, and it can be difficult for them to debug.

@ceight1 Here is one way, which you adjust to other examples.

The embedded Table looks better in the actual Maple GUI than it does inlined in this forum.

Slope Fields

 

restart

interface(rtablesize = 50)

ode := diff(y(x), x) = -2*x*y(x)+1

diff(y(x), x) = -2*x*y(x)+1

ic := y(0) = 1

y(0) = 1

exactsol := dsolve({ic, ode})

y(x) = ((1/2)*Pi^(1/2)*erfi(x)+1)*exp(-x^2)

exactsolfunc := unapply(rhs(exactsol), x)

proc (x) options operator, arrow; ((1/2)*Pi^(1/2)*erfi(x)+1)*exp(-x^2) end proc

NULL 

f := proc (x, y) options operator, arrow; -2*x*y+1 end proc

proc (x, y) options operator, arrow; -2*y*x+1 end proc

x, y := 'x', 'y'; x[0] := 0; y[0] := 1; h := 0.5e-1; x_end := .65; N := ceil((x_end-x[0])/h)

13

for n to N do x[n] := n*h; y[n] := y[n-1]+h*f(x[n-1], y[n-1]) end do

UseHardwareFloats := false; xdat := `<,>`(convert(x, list)); ydat := `<,>`(convert(y, list)); exactdat := map(exactsolfunc, xdat); abserr := map(abs, exactdat-ydat); alldat := `<,>`(`<|>`(x__n, y__n, "Actual Value", "Absolute Error"), `<|>`(xdat, ydat, exactdat, abserr))

Matrix(%id = 18446884663419907238)

 

DocumentTools:-Tabulate(alldat, width = 500, widthmode = pixels, fillcolor = proc (M, i, j) `if`(i = 1, "LightGray", "White") end proc)
``

 

`#msub(mi("x"),mi("n"))`

`#msub(mi("y"),mi("n"))`

Actual Value

Absolute Error

0

1

1

0.

0.5e-1

1.05

1.047419872

0.2580128e-2

.10

1.094750

1.089385826

0.5364174e-2

.15

1.133802500

1.125521358

0.8281142e-2

.20

1.166795462

1.155540473

0.11254989e-1

.25

1.193459553

1.179252227

0.14207326e-1

.30

1.213623064

1.196562851

0.17060213e-1

.35

1.227214372

1.207475440

0.19738932e-1

.40

1.234261869

1.212087271

0.22174598e-1

.45

1.234891394

1.210584886

0.24306508e-1

.50

1.229321281

1.203237166

0.26084115e-1

.55

1.217855217

1.190386665

0.27468552e-1

.60

1.200873180

1.172439530

0.28433650e-1

.65

1.178820789

1.149854370

0.28966419e-1

 

HELP_CODE_ac_tab.mw

@wswain At the very least you should explain what you mean by,

     ...RPM range text =  "0-100, 101-200, 201-300", etc.  for each
     bin and rotated vertical to fit.

Keep in mind that you haven't even explained what the two axes of your plot are supposed to represent, if the above quote truly relates to axis labeling. If it instead relates to some kind of colorbar legend for the ranges of values of the data then please indicate as much.

Providing code that reproduces the output or plots in your Question is usually helpful, often useful to those answering, and polite.

Upload and attach a worksheet that contains code to reproduce.

Why the need to use typeset? Does it not render similarly without that?

@Carl Love When the OP started with his queries [1, 2], there was no mention of LaTeX in the Question bodies. And so my previous responses [1, 2] were only about printing in the Maple GUI, and not about LaTeX export.

I have previously had some small success in using an XML add-on package in LaTeX, to cope with some marked up "TypeMK" Maple names. But some entities were a pain. I don't think that I'd go there to make it easier.

@BrettKnoss The second example doesn't need the DataFrame, I just threw it in at the end. It only needs M, a Matrix which stores the data.

The Matrix M gets extended at each iteration by use of the round-bracket "programmer's indexing". The seems simpler than Append on a DataFrame.

@Carl Love From the OP's edited description it reads as if the bug was in his own code, which had a mismatched type declaration on the local variable to which the FetchAll result were assigned.

First 145 146 147 148 149 150 151 Last Page 147 of 592