acer

32405 Reputation

29 Badges

19 years, 350 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Are you hoping for an effect that looks something like this?

plots:-polarplot(tan(theta)*sec(theta), theta = 0 .. 2*Pi,
                 style=point, adaptive=false, numpoints=10^4,
                 axiscoordinates=cartesian,
                 view=[-100..100, 0..10^4])

Download pl1.mw

 

plots:-polarplot(tan(theta)*sec(theta), theta = 0 .. Pi,
                 axiscoordinates=cartesian,
                 view=[-100..100, 0..10^4])

Download pl2.mw

By changing the difference of the pair of sin&cos calls into a product we can give solve a helping hand.

Solving the product is, naturally, quite easy.

ee := trigsubs('cos'(3*x - Pi/12) - cos(2*x + Pi/7))

[-2*sin((5/2)*x+(5/168)*Pi)*sin((1/2)*x-(19/168)*Pi)]

solve(ee, allsolutions);
 

{x = (19/84)*Pi+2*Pi*_Z4}, {x = -(1/84)*Pi+(2/5)*Pi*_Z3}

Download sc_solve_2023_2.mw

 

Here's a more programmatic variant of that, but without having to manually enter a cos call within uneval quotes,

restart;

ee := cos(3*x - Pi/12) = cos(2*x + Pi/7):

ff := trigsubs( convert( (lhs-rhs)(ee), sin ) );

[2*cos((5/2)*x+(89/168)*Pi)*sin((1/2)*x-(19/168)*Pi)]

solve(ff, allsolutions);

{x = (19/84)*Pi+2*Pi*_Z2}, {x = -(1/84)*Pi+(2/5)*Pi*_Z1}

Download sc_solve_2023_3.mw


And here's something with another kind of intermediate conversion, but also with a result more readily understandable than your straight solve attempt (which is large, with RootOf's).

restart;

kernelopts(version);

`Maple 2023.0, X86 64 LINUX, Mar 06 2023, Build ID 1689885`

ee := cos(3*x - Pi/12) = cos(2*x + Pi/7);

sin(3*x+(5/12)*Pi) = cos(2*x+(1/7)*Pi)

simplify([solve(convert(ee,exp),allsolutions)]);

[Pi*(2*_Z2+19/84), Pi*(2*_Z1-1/84), Pi*(2*_Z1+163/420), Pi*(2*_Z1+331/420), Pi*(2*_Z1-341/420), Pi*(2*_Z1-173/420)]

Download sc_solve_2023_1.mw

 

I will submit a couple of bug reports about various weaknesses discovered here in solve and trigsubs. That is: the original unwieldy result from solve, and trigsubs not knowing how to handle some variants on the sum/difference forms.

It seems that the (SSL) certificate for this site had expired, preventing https access. (http access was still possible I think.)

It may have been fixed.

In your second question you are missing the multiplication between 10 and Unit(m/s).

As you have it, in 1D plaintext input,
  10Unit(m/s)
it is not valid Maple syntax.

In pretty-printed 2D Output the multiplication is represented implicitly by a space.

with(Units:-Simple)

solve((24.5*Unit('kPa')*250)*Unit('mL')/((8.3145*Unit('J'/('K'*'mol'))*292.5)*Unit('K')) = n)

0.2518512351e-2*Units:-Unit(mol)

NULL

0.1e-2*(24.5*Unit('kPa')*10^3*Unit('Pa'/'kPa')*250)*Unit('mL')*Unit('L'/'mL')*10^(-3)*Unit('m'^3/'L')/((8.3145*Unit('J'/('K'*'mol'))*292.5)*Unit('K'))

0.2518512351e-2*Units:-Unit(mol)

Why is there a difference between the two results above?

 

Second question: I use a shortcut when I want to write units (on my Mac it is CMD+Shift+u). I just found out while writing this worksheet that for Maple input the shortcut does produce something but executing a line where this was used generates an error as can be seen below.

 

10*Unit('m'/'s')

10*Units:-Unit(m/s)

10*Unit(m/s)

10*Units:-Unit(m/s)

 

NULL

Download Units_ac.mw

Performing simplify-with-side-relations does a kind of normal form operation in a polynomial sense.

It doesn't perform every other kind of simplify action. This is documented on the Help page with Topic simplify,details.

In that page's Options section it says,
  "Invokes only the simplification procedures specified by the additional names."
followed by a list of names. The word "siderels" is one of those names listed (and which is a cross-reference I gave at top). Yes, "siderels" itself is not an actual option name proper, but it's listed there since its relevent option names are governed by that same principle.

For example,

simplify(exp(2)*exp(4)-exp(6));

0

simplify(exp(2)*exp(4)-exp(6), {});

exp(2)*exp(4)-exp(6)

simplify(sin(x)^2+cos(x)^2-1);

0

simplify(sin(x)^2+cos(x)^2-1,{});

sin(x)^2+cos(x)^2-1

simplify(exp(2)*exp(4)-exp(6), trig);

exp(2)*exp(4)-exp(6)

simplify(sin(x)^2+cos(x)^2-1, exp);

sin(x)^2+cos(x)^2-1

Download simp_siderels_1.mw

Apparently the two-argument variant of EllipticE gets covered under EnableTypesetRule with the token,
     "EllipticE2"

So, that case gets covered for me (M2023.0) if I instead do it as,

   Typesetting:-EnableTypesetRule({"EllipticE", "EllipticE2", "EllipticF", "EllipticK"})

You can also enable it for all the special functions about which it knows, with,

   Typesetting:-EnableTypesetRule(Typesetting:-SpecialFunctionRules)

I don't know why the 2-argument E and F are not rendered in bold.

I will submit a bug report against the lack of bold, and the lack of documentation on the Help page about the multi-argument variants.

ps. I also see that "EllipticF" is adequate to cover its (sole!) 2-argument case. The naming scheme thus seems a bit unhelpful. But there's enough documented detail to see that this aspect is key. (It's also seen in the Typesetting:-RuleAssistant's popup details...)

The problem appears to lie in the new (Maple 2022, default) adaptive=geometric algorithm.

If you force the (older default) adaptive=true then the whole region gets plotted.

restart;

T:=(x,beta)->(1+sin(sqrt(x-1)*beta)^2/(4*x*(x-1)))^(-1):

plot(T(x,4), x=0..5, adaptive=true,
     labels=[E/V[0],T], labelfont=[times,20],
     axesfont=[times,20],thickness=3,view=[0..5,0..1])

Download PlotIssue_ac.mw

I will submit a bug report against this example.

note: For this example it happens you might also use adaptive=false, though in general (other examples) that will not attempt to refine the curve near portions with high curvature or save space in portions that need fewer points.

See also the adaptive Help page.

Here's a kludge to make the datasetlabels=contents result look a bit better.

This is customized for this example, and won't handle many more elements without further adjustment/tweaks and/or reduction of font size. To be more general it would have to do more work, eg. also act according to where the "content" strings occurred, etc.

restart;

Q:=Statistics:-VennDiagram(isprime, issqr, x -> irem(x, 3) = 0, universe = {$ (1 .. 100)},
                           legend = ["Prime", "Square", "Multiple of 3"],
                           datasetlabels=contents,
                           font=[Times,12], size=[800,900], scaling=unconstrained):

R:=map(proc(s) local i,L;
        L := [ListTools:-LengthSplit([parse(s)[]],8)];
        s=`if`(nops(L)=0,s,
               cat("\n\n{",convert(L[1],string)[2..-2],
                       seq(["\n ",convert(L[i],string)[2..-2]][],
                           i=2..nops(L)),"}\n"));
       end proc,indets(indets(Q,specfunc(TEXT)),string)):

subs(R,Q);

Download DigVenn_ac.mw

Here are two simple alternatives, for your example. I'd generally favour the former over the latter.

restart;
decisions := "accept", "reject":
T := 2:

`if`(1 > T, decisions[1], decisions[2]);

               "reject"

eval('`if`'(1 > T, decisions));

               "reject"

You asked why your problematic situation occurs. The `if` command has special evaluation rules, in which its arguments are not fully evaluated up front in the usual way.

One common motivating example for this design is that NULL can be passed (including the case of NULL as a 2nd argument), with the separate arguments recognized. If the argument sequence were flattened in the usual way during up-front evaluation then the following example would not work as intended.

restart;

map(u->`if`(u>2, NULL, u), [-3,7,1,9]);

          [-3, 1]

Here is another example, in which the desired behaviour also relies on the non-flattening of the argument sequence (possible by virtue of the special evaluation rules). Under usual evaluation rules the following would behave like a function call with four arguments.

restart;
p1:= A,B:
p2:=C:

`if`(3>2, p1, p2);

             A, B

Note that a workaround construction like,
   eval('`if`'( ... ))
would break the functionality of the first two examples I've given, because the forced full evaluation flattens the argument sequence.

The behaviour is somewhat similar during the initial construction where you called piecewise, which also has special evaluation rules.

note. The ifelse command also has special evaluation rules, and ought to be mentioned on the cited ?spec_eval_rules Help page.

This OP's first example is documented. The assuming facility doesn't place (its temporary) assumptions on variables it doesn't see, ie. only hidden within a procedure. From the Example section of the Help page for Topic assuming,

   The variable a is inside the body of f; the assumption that a > 0 is
   not effectively used when computing f(1).
   f := x -> sqrt(a^2) + x;
     f := proc (x) options operator, arrow; sqrt(a^2)+x end proc

   f(1) assuming a > 0;
                             (1/2)    
                         / 2\         
                         \a /      + 1

   For these purposes, you can use the Physics:-Setup command
   with its assumingusesAssume keyword, or use assume itself...

 

And so,

restart;

d := g -> (D@@2)(g) - x^2*g

proc (g) options operator, arrow; (D@@2)(g)-x^2*g end proc

((d@@2)(g) assuming x::constant);

(D@@4)(g)-2*(D@@2)(x)*x*g-2*D(x)^2*g-4*D(x)*x*D(g)-x^2*(D@@2)(g)-x^2*((D@@2)(g)-x^2*g)

restart;

Physics:-Setup(assumingusesAssume = true):

d := g -> (D@@2)(g) - x^2*g

proc (g) options operator, arrow; (D@@2)(g)-x^2*g end proc

((d@@2)(g) assuming x::constant);

(D@@4)(g)-x^2*(D@@2)(g)-x^2*((D@@2)(g)-x^2*g)

restart;

assume(x::constant);

d := g -> (D@@2)(g) - x^2*g

proc (g) options operator, arrow; (D@@2)(g)-x^2*g end proc

((d@@2)(g) assuming x::constant);

(D@@4)(g)-x^2*(D@@2)(g)-x^2*((D@@2)(g)-x^2*g)

restart;

F := () -> simplify(sqrt(x^2));

proc () options operator, arrow; simplify(sqrt(x^2)) end proc

F() assuming x>0;

csgn(x)*x

restart;

Physics:-Setup(assumingusesAssume = true):

F := () -> simplify(sqrt(x^2));

proc () options operator, arrow; simplify(sqrt(x^2)) end proc

F() assuming x>0;

x

restart;

assume(x>0):

F := () -> simplify(sqrt(x^2));

proc () options operator, arrow; simplify(sqrt(x^2)) end proc

F();

x

Download assuming_exx.mw

The OP's second example is quite another matter, related to the current limits of D functionality.

You can specify a reasonable view, and get a more usuable result.

AnimationCercleTrigoFonctiTrigo_ac.mw

You could also add the discont option to the plot of tan, if you don't want to see the vertical lines at the discontinuities, eg.
    plot(tan(x), x = 0 .. t, discont)
Then you could get,

In your Maple 2021 the values of F can overflow if computed at hardware float double-precision, for the upper portion of your range omega=0..200. That makes the upper portion of the plot blank, ie. missing the curve.

There are a few ways around that. One of the simplest approaches is to set Digits:=16 (or higher) at the start of the document.

If I do that in Maple 2021.2 then the following plot appears when I re-execute the whole document:

Plot_determinant_value_vs_omega_ac.mw

In current Maple 2023.0 the numeric problem in hardware double precision is dealt with automatically, and the upper portion of this curve is handled ok by default.

Also, the error message you showed indicated that at some point you may have accidentally assigned the value 160 to the name omega. You'll need to keep that name omega unassigned if you intend on using it as the plotting variable.

Notes: By default setting Digits:=16 allows software floats to be used in the compution of F during plotting, with a wider range of values attainable without overflowing and generating Float(undefined). Another simple alternative is to set  UseHardwareFloats:=false  .  There are also slightly more complicated approaches, including reformulation of the expression F.

@bobvandijk The back-ticks are not visible in the 2D Output if one uses Maple 2023.0 (which is the version that Carl usually uses).

The back-ticks appear in the 2D Output for this kind of subscripted display (double-undescore) in Maple 2022 when using the default setting,
   interface(typesetting=extended):
It is possible to get the atomic name `A__b,c` to display without the backticks visible in 2D Output in Maple 2022, if one uses the setting,
   interface(typesetting=standard):
however I don't particularly recommend that adjusting that to the non-default setting; you might well find something else which you don't care for if you use it.

If you go with the alternative indexed name A[b,c] which also displays as a subscipted name in 2D Ouput then note that you can also enter that in subscripted form in 2D Input mode.

You could do that with the following keystrokes, and a single-underscore:

     A  Ctl-Shift-underscore  b,c

restart

kernelopts(version)

`Maple 2022.2, X86 64 LINUX, Oct 23 2022, Build ID 1657361`

interface(typesetting)

extended

 

For this next input I use the keystrokes,

   A  Ctl-Shift-underscore   b,c

 

A[b, c]

A[b, c]

lprint(%)

A[b,c]

Download sbscr_M2022.mw

It looks like you've used Maple 2015.2, for your attachment.

But the examples work ok for me using Maple 2019.2.1 (or Maple 2023.0, for that matter).

DocumentTools_and_Background_M2019.2.1.mw

 

ps. I did adjust one of your examples to be a Table inside a Group. rather than in an Input (a minor change, not directly related to your issue).

pps. I suspect that the issue in older versions <= M2018.2 is a GUI problem with actually embedding the content. The content results like InlinePlot(T[1]) seem structurally ok, and decode ok.

Here's one way (given what you've done so far):

dont_get_it_ac.mw

First 40 41 42 43 44 45 46 Last Page 42 of 336