acer

32368 Reputation

29 Badges

19 years, 333 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The Color Collections Help-page explains quite a bit of the purposes and nature of the various stock color palettes.

I don't know of any programmatic mechanism (ie. GUI streamcall) that would cause the GUI to reexecute all inputs in usual Execution Groups and Document Blocks.

The "action code" of Sliders can be used to update other Embedded Components (or do file i/o, escaped system calls, etc), but as far as I know it cannot directly affect normal input/output of the worksheet.

It is possible for the action code to replace some previously embedded content (lock, stock, and barrel). And that includes re-embedding some whole new .mw there. However I also don't know of any mechanism that would programmatically execute&save an external .mw file. Even if such a kludge worked it wouldn't really be the same as the normal input/ouput areas.

Programmatic reconstruction of the entrie .mw worksheet from scratch would be a great deal of work, and opening such in a separate new GUI tab for each Slider change sounds awkward and not useful. So, I'm afraid that I'm out of ideas here.

These results are in a reasonably simple form.
 

u1 := RootOf(4*_Z^2 + (4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) - 4)*_Z
             + 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1)^2
             - 4*RootOf(60*_Z^3 - 60*_Z^2 + 15*_Z - 1) + 1):

 

[simplify(allvalues~(RootOf~(simplify(evalc({allvalues(op(u1))})))))[]];

[(1/3)*cos((1/3)*arctan(3/4))+1/3, -(1/6)*cos((1/3)*arctan(3/4))+1/3-(1/6)*3^(1/2)*sin((1/3)*arctan(3/4)), -(1/6)*cos((1/3)*arctan(3/4))+1/3+(1/6)*3^(1/2)*sin((1/3)*arctan(3/4))]

evalf(%);

[.6590276223, .1090390090, .2319333686]

evalf(u1);

.2319333685

Download RO_ex.mw

It seems to me that you want/need a mechanism to force your shootNL procedure to return either uN(bV) or vN(bV). Your original attempt had shootNL return the expreszsion-sequence of both values.

Your attempt at using fsolve was running into additional problems because the shootNL calls were being prematurely evaluated at the symbolic names sU and sV.

Here's a quick fix to some of those problems. But I don't see any root (of both u(bV) and v(bV)) in your given ranges 0.5..1 for parameters sU and sV.

fsolveProblem_ac.mw

ps. I didn't bother to make this more efficient (eg. by using the dsolve/numeric parameters option and functionality). First you should figure out whether it's doing what you expect.

If one examines the complexplot3d internal code with showstat then one can see that extra options are passed along to plot3d, via _rest . This allows one to overrride the default color procedure when calling complexplot3d.

Using the operator-form calling sequence with the complexplot3d command below I'll show an example that forces (via argument) an effect similar to the default, as well as another example forcing abs(z) for coloring.

Note that the procedure I'm using for the color option below has two parameters, just as does (?plot3d,colorfunc) the underlying plot3d command that gets called to do the actual construction. The complexplot3d command is like a convenient front-end, allowing the real and imaginary plotting variables to be bundled and passed together for both its expression/operator and its ranges. But we can deal with the color option by handling the real and imaginary components unbundled.

plots:-complexplot3d(z->z, -2 - 2*I .. 2 + 2*I,
                     color=proc(re,im) argument(re+I*im); end proc,
                     style=surfacecontour, lightmodel=none,
                     labels=[Re(z),Im(z),``], orientation = [-90, 0, 0]);

Download complexplot3d_ex.mw

plots:-complexplot3d(z->z, -2 - 2*I .. 2 + 2*I,
                     color=proc(re,im) abs(re+I*im); end proc,
                     style=surfacecontour, lightmodel=none,
                     labels=[Re(z),Im(z),``], orientation = [-90, 0, 0]);

Download complexplot3d_ex2.mw

There are several ways to supply arbitrary color functions.  See ?plot3d,colorfunc 

Instead of using command complexplot3d one could also build the desired plotting structure by using just plot3d with something like z=re+im*I for an expression-form calling sequence, with the two plotting variables re and im.

Here too one doesn't have to use simply,
   color=argument(re+I*im)
but instead one can adjust the formula as desired. Below I merely mimic the default effect.

plot3d(abs(re+I*im), re=-2..2, im=-2..2,
       color=argument(re+I*im),
       style=surfacecontour, lightmodel=none,
       labels=[Re(z),Im(z),``], orientation = [-90, 0, 0]);

plot3d_cplx.mw

I am guessing that you want a stand-alone term xi = xi^1 to become H(1)*xi.

Let me know if I've guessed that wrongly.

restart;

expr := xi - xi^2 + 1/xi^3 - 1/xi

xi-xi^2+1/xi^3-1/xi

eval(applyrule([xi^(k::integer)=H(k)*__P(k)],expr),
     __P=(u->xi^op(u)));

H(1)*xi-H(2)*xi^2+H(-3)/xi^3-H(-1)/xi

thaw(subs(xi=H(1)*xi,
          subsindets(subsindets(expr,identical(xi)^integer,
                     u->H(op(2,u))*u),
                     identical(xi)^integer,freeze)));

H(1)*xi-H(2)*xi^2+H(-3)/xi^3-H(-1)/xi


If you want to exclude the rule for xi and 1/xi ,

eval(applyrule([xi^(k::And(integer,Non({1,-1})))=H(k)*__P(k)],
               expr),
     __P=(u->xi^op(u)));

xi-H(2)*xi^2+H(-3)/xi^3-1/xi

Download repl_ex.mw

Since Maple 18 the plot3d command accepts an option to directly put an image on a surface (including a sphere, etc).

Prior to that it could be done by manipulating structures. I made an old Post ,and a few others, linked from there, on that general topic. Some of those bits of functionality have found their way into Library commands.

seq(`&#`||k||`;`,k=945..969);

`α`, `β`, `γ`, `δ`, `ϵ`, `ζ`, `η`, `θ`, `ι`, `κ`, `λ`, `μ`, `ν`, `ξ`, `ο`, `π`, `ρ`, `ς`, `σ`, `τ`, `υ`, `φ`, `χ`, `ψ`, `ω`

Download ent_seq.mw

Those are just Maple names which line-print like the unicode decimal codes and pretty-print (2D Output) like the typeset lowercase Greek letters.

For example, the Maple name `α` gets typeset in 2D Output as the symbol for the Greek letter alpha.

You don't need to wrap in any MathML style markup (eg. mo(...), mi(...) ) for that basic effect.

ps. It's not entirely clear exactly what you wanted to accomplish. Perhaps you're trying to do something different. Are you looking for a way to programmatically generate the literal names alpha, beta,...,omega as written in the Latin alphabet?

 

restart;

 

is_symbol_inside_func_only:=
  (e,f,y)->type(subsindets(e,specfunc(Not(freeof(y)),f),freeze),freeof(y)):

 

expr:=3*ln(1+y)+ln(3*y)*y+ln(y)+cos(7*y):
is_symbol_inside_func_only(expr,ln,y); #should return false

expr:=3*ln(1+y)+ln(3*y):
is_symbol_inside_func_only(expr,ln,y); #should return true

expr:=ln(y)+ln(3*y)+cos(y):
is_symbol_inside_func_only(expr,ln,y); #should return false


expr:=3+cos(y):
is_symbol_inside_func_only(expr,cos,y); #should return true

expr:=y+ln(y):
is_symbol_inside_func_only(expr,ln,y); #should return false

false

true

false

true

false

Download type_chk_ex.mw

That is the behavior of evalb, which is the default mechanism for if..then conditional testing. (That Help page describes the kinds of equivalence it tests.)

For such polynomial comparison you have a few alternatives -- to get a mathematical equivalence test of the kind needed here -- including expanding (or putting the difference into normal form) before comparing, or using is, or testeq,

evalb( (x+1)^2 = x^2+2*x+1 );

false

Any of the tests at end could be used here instead.

(You wouldn't need the wrapping evalb calls, though,
 since that's automatically part of the if..then check.)

if expand( (x+1)^2=x^2+2*x+1 ) then
   print(1);
else
   print(0);
end if;

1

evalb( expand( (x+1)^2 = x^2+2*x+1 ) );

true

evalb( normal( (x+1)^2 - (x^2+2*x+1) = 0 ) );

true

testeq( (x+1)^2=x^2+2*x+1 )

true

is( (x+1)^2=x^2+2*x+1 );

true

Download evalb_et_alia.mw

In general some such mathematical tests for equivalence are potentially more expensive than others. The user gets to decide which might be used.

In Maple 2021 and later the form you want is produced directly. (You haven't told us what older version you are using.)

Here are three different ways to get that integration result.

restart;

kernelopts(version); # later versions get it directly

`Maple 2020.2, X86 64 LINUX, Nov 11 2020, Build ID 1502365`

H:=Int(x^17*cos(x^6),x):

expand(value(IntegrationTools:-Parts(H,x^6)));

(1/3)*x^6*cos(x^6)+(1/6)*x^12*sin(x^6)-(1/3)*sin(x^6)

expand(convert(int(x^17*cos(x^6),x=0..x),trig));

(1/3)*x^6*cos(x^6)+(1/6)*x^12*sin(x^6)-(1/3)*sin(x^6)

int(x^17*cos(x^6),x=0..x,method=meijerg);

(1/3)*x^6*cos(x^6)+(1/6)*x^12*sin(x^6)-(1/3)*sin(x^6)

Download int_old_ex.mw

ps. In Maple 2021 and later the result,
   1/3*x^6*cos(x^6)+1/6*(x^12-2)*sin(x^6)
is produced by default (no method) and by method=risch, and a close trig form by method=meijerg. In Maple 2020 and earlier the method option was not supported for indefinite integration (hence my 3rd workaround above).

You appear to have made two kinds of mistake.

The first is that it looks like you've forgotten to put either an explicit multiplication symbol or a space (to denote multiplication implicitly) between the name a and the left open-parenthesis.

The result is that you've entered a(x-a) which is a function call of a (some as yet undefined operator...). You haven't used any syntax for a*(x-a) a product of a and x-a.

The second mistake is that you subtracted instead of added.

restart

expr := (x-a)^2-2*a(x-a)

(x-a)^2-2*a(x-a)

lprint(expr)

(x-a)^2-2*a(x-a)

indets(expr, function)

{a(x-a)}

new := (x-a)^2-2*a*(x-a)

(x-a)^2-2*a*(x-a)

lprint(new)

(x-a)^2-2*a*(x-a)

indets(new, function)

{}

expand(new)

3*a^2-4*a*x+x^2

intended := (x-a)^2+2*a*(x-a)

(x-a)^2+2*a*(x-a)

expand(intended)

-a^2+x^2

Download 2d_mul_ex.mw

There are several things you can do with that in Maple. For example,

restart;

ee := Sum((-1)^r*x^r, r=0..N);

Sum((-1)^r*x^r, r = 0 .. N)

value(ee);
eval(%, N=4);
sort(normal(%), x, ascending);

-(-x)^(N+1)/(x+1)+1/(x+1)

x^5/(x+1)+1/(x+1)

1-x+x^2-x^3+x^4

add((-1)^r*x^r, r=0..4);

1-x+x^2-x^3+x^4

limit(ee, N=infinity) assuming x<1, x>-1;

1/(x+1)

convert(1/(x+1), FPS);

Sum((-1)^k*x^k, k = 0 .. infinity)

series(1/(x+1), x)

series(1-x+x^2-x^3+x^4-x^5+O(x^6),x,6)

Download sum_ex.mw

ps. I converted your Post into a Question.

The following code shows how you can programmatically turn equations into such scalar expressions, or vice versa.

It also let's you do that if you have a mix of both. But it can also work if you have just all one type, or the other.

It's a simple task, so the code to handle it ought to be simple. I've tried to make this code straightforward, so that a Maple beginner could learn a bit from it. I deliberately didn't make it as super terse as possible.

restart;

ex1 := a*x^2 + b*x = v:

ex2 := c*x^2 + d*x - w:


Suppose you have a mixed collection -- some equalities, some scalar expressions

L := [ex1, ex2];

[a*x^2+b*x = v, c*x^2+d*x-w]

Turn all the equalities into scalar expressions.

map(expr -> ifelse( expr::`=`,
                    (lhs-rhs)(expr),
                    expr ),
    L);

[a*x^2+b*x-v, c*x^2+d*x-w]

Turn all the scalar expressions into equalities.

map(expr -> ifelse( expr::`=`,
                    expr,
                    expr=0 ),
    L);

[a*x^2+b*x = v, c*x^2+d*x-w = 0]


And now, a brief note on the syntax for invoking type

type(ex1, `=`);
evalb( ex1::`=` ); # shorthand that works in conditionals

true

true

Download type_equals.mw

The following is a glossed-over over-simplification.

Personal computers that one could purchase today have CPUs with associated hardware (circuits) specialized for the task of performing arithmetic on floating-point numbers stored/encoded in a mere 64 bits (double precision) or 32 bits (single precision) of memory.

Such so-called "hardware floats" are restricted in range, both in terms of the number of decimal places of the mantissa (roughly 15 decimal digits for double precision) and exponent.

If your machine's Operating System is made aware via some program (eg. compiled C, Maple, etc) of such floats in memory then it can make calls to have the relevant hardware chip perform such "direct" arithmetic operations. The hardware chips of personal computers made today can do billions of such operations per second (provided the program and OS can supply them that fast).

The essence of this speed is due to the numbers being stored in (64, or 32) bits that are encoded in a form that the hardware arithmetic unit understands directly, and the fact that the range in which these hardware floats exist is quite restricted. The restricted possible range of these floats allows for adequately accurate yet very fast dedicated circuitry or algorithms to be possible.

But Maple can also handle floating-point numbers from a much wider range -- with many more possible decimal digits, and much smaller/greater exponent. The floating-point arithmetic on such so-called "software float" numbers is emulated by the software program, and the numbers are stored in another kind of specialized encoding, ie. a more involved, higher level, dedicated data structure. These operations are considerably slower than those so-called hardware float operations mentioned earlier. Such software floats also require additional overhead (eg. memory-management).

Maple is an interpreted language, and the Maple program has a core interpreter that performs symbolic computations as well as performs/dispatches integer and software-float computations. Maple also has an alternate interpreter, available as the evalhf command, which can do float arithmetic more quickly because it uses the very compact hardware float representation and the mentioned low-level computations that the machine's chips can perform directly. Sometimes the relative performance benefit is as high as a factor of 15-30. The evalhf benefit is mostly restricted to a relatively smaller assortment of numeric operations, however.

Throughout the above, I've just written "arithmetic". But the situation is similar for elementary operations such as sqrtsin, exp, etc. Either the Operating System's runtime math library or the hardware chipset offers dedicated mechanisms to compute those operations accurately and quickly for hardware floats. Computing those for arbitrary precision software floats is computationally more expensive.

There are a couple of other ways to get some speed benefits of hardware float computation, from within Maple. Eg. the Compiler, and option hfloat on a procedure. (See also these two articles [1], [2], now old.)

First 30 31 32 33 34 35 36 Last Page 32 of 336