acer

32333 Reputation

29 Badges

19 years, 323 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

solve( (a-2)*x=4-a^2, x, parametric);

piecewise(a-2 = 0, [{x = x}], a-2 <> 0, [{x = -a-2}])

solve( x^2+(y-2)^2=0, [x,y], real, parametric);

[[x = 0, y = 2]]


Download solve_p_ex.mw

@Carl Love That's like the second example in my Answer, is it not?

You've got,
    Or(x = abs(x), -x = abs(x))
while I had,
    Or(C + abs(C) = 0, C - abs(C) = 0)

I'm sure that you'll know that I got there by something like,
   S := cos(x) + sqrt(1-sin(x)^2) = 0, cos(x) - sqrt(1-sin(x)^2) = 0:
   simplify(Or(S)) assuming x::real;

@janhardo It's part of the DEtools package.

You seem to have forgotten to load (from) that, in your use of the just the short-form name rifsimp.

@JoyDivisionMan It seems that Maple's difficulty stems from the zero point, and that one only has to break it there.

That can be done with two sets of assumptions (as opposed to my previous four), or with a split of the integral form at 0.

restart;

with(IntegrationTools): with(Statistics):

 

r := sqrt(RandomVariable(Uniform(0,1))):
x := cos(RandomVariable(Uniform(0, 2*Pi))):

 

value(Split(PDF(r*x, t, inert), 0));

piecewise(t < -1, 0, t <= 1, 2*sqrt(-t^2+1)/Pi, 1 < t, 0)


Or, using a pair of assumptions,

PDF(r*x, t) assuming t>0;

piecewise(t <= 1, 2*sqrt(-t^2+1)/Pi, 1 < t, 0)

PDF(r*x, t) assuming t<0;

piecewise(t < -1, 0, -1 <= t, 2*sqrt(-t^2+1)/Pi)

Download pdf_RV_02_split.mw 

This now seems like insight into why Maple (2024.2 at least) doesn't get the simple explicit piecewise answer to this problem. It may be that int itself is getting hung up. Ideally it would be able to get the explicit result without the manual split at 0.

ps. It is not necessary to also split at discont of PDF(r,t) and/or PDF(x,t), in order to get the nice explicit piecewise result.
pps. The portions computed from using such assumptions (ie, disjoint sets that cover -inf..inf) can be properly combined into an actual PDF that respects the support. Using assumptions is not necessarily just a trick. It's obvious that a result obtained under some assumptions is only guaranteed to hold under those same assumptions. This is why I used multiple disjoint sets of assumptions, that together cover the reals. How to join the results with piecewise (and why that'd be desired) should be obvious.

@JoyDivisionMan Note that the formula result for t assumed to be in -1..0 is the same as for t assumed to be in 0..1.

I didn't successfully achieve that same nice form directly, if I merged the assumptions into just the simpler combined assumptions x>-1,x<1 . There are other ways to get it from that, but the above seemed less awkward to me.


ps. You don't mark your Questions with your Maple version. Sometimes it makes a difference in what answer may be attained.

@nm I wrote that to only extract the locals from the module because in the previous Question thread you were lamenting issue with locals.

On the ?module Help page it explains that the locals can be had as the 3rd operand of the module, and the exports can be had as the 1st operand. So that code is easily changed to handle both, as a union.

restart;
A := module()
    export main:=proc()
       print("i am in A:-main");
       B:-foo();
    end proc;

    export B :=module()
       export foo:=proc()
          print("in B:-foo()");
       end proc;
    end module;
end module:
kernelopts(opaquemodules=false): #see @acer code
S := subsindets({op(3,eval(A))} union {op(1,eval(A))}, `::`, (L)->convert(lhs(L),`global`)):
S := map(u->parse(cat("A:-",u)), eval(S,1));
Grid:-Set(0, A:-main, op(eval(S,1)));
Grid:-Run(0, A:-main,[  ]);
Grid:-Wait();

{B, main}

"i am in A:-main"

"in B:-foo()"

Download module_locals_and_exports.mw

@Scot Gould I like it.

I suspect that the datatype=float (or float[8]) might be (a necessary) part of why the mapped `<=` works, similar to how true/false become 1/0 under evalhf.

@nm I am wondering why you need to use Grid:-Set, as opposed to having your modules stored in a .mla archive file stored in a location in libname.

If I write an involved "package" (one or more modules, say) and want to use it in multiple sessions then I store it in a .mla file and make it available via libname. That's pretty common and standard usage.

I wouldn't read my module source from .mpl text file, or define it by executing some worksheet code, each and every time I wanted to use it in a run. That's what .mla archives are for.

I'd only re-read/re-instantiate/define/assign my procedures and modules while actively developing them.

Is it not possible for your to use a .mla to make your modules available to each node? I really don't think that you should need to change all your module locals to exports, so as to be able to Grid:-Set everything. Is there some special requirement we haven't yet heard?

I see the same thing in my Maple 2024.2 for Linux.

It doesn't appear when I place focus on an output with units, and I instead get a long Java exception error to my launching console.

It seems to work ok in my Maple 2024.1.1 for Linux.

@scottwr In your original code you re-assigned to name y at the various stages. That seems to indicate that the original sampling (empirical distribution, [1..6]) isn't needed after it's used.

But in that case, could you not just generate a sample of the empirical distribution [-1,1] right off?

Is this whole operation to be repeated, possibly with different weights?

Do you actually need integer values, or will the floats -1.0,1.0 do? If floats would serve (and if the plot is the main thing) then a hardware double-precision float Matrix could be constructed to contains the numeric results. That might alleviate some overhead in the plot drivers.

What's your target size N? How fast do you need it all to be?

Optimizing the process may depend on such requirements. 

@mmcdara I'm still a bit hazy on the conditions, sorry. I'm not sure what kind of examples are supposed to return `false`.

When you write "powers" do you mean only posint exponents -- excluding fractional and negint exponents?

Does "function" mean function of an unassigned name, ie. not any standard math call? (See additional examples, and choices for K type.)

typefunc_ex_feedback_ac.mw

It is not necessary to hard-code all the module local names, for use in Grid:-Set.

One can do it programmatically, dynamically.

restart;

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

A := module()
  local DEBUG_MSG::truefalse:=false;
  local OTHER:=foo;
  export work_proc:=proc(n::integer)
     print("My flag is ", DEBUG_MSG, OTHER);
  end proc;
end module:

kernelopts(opaquemodules=false):

S := subsindets({op(3,eval(A))}, `::`, (L)->convert(lhs(L),`global`)):
S := map(u->parse(cat("A:-",u)), eval(S,1));

{OTHER, DEBUG_MSG}

Grid:-Set(0, A:-work_proc, op(eval(S,1)));
Grid:-Run(0, A:-work_proc,[ 0 ]);
Grid:-Wait();

"My flag is ", false, foo

A:-DEBUG_MSG := true:
A:-OTHER := blech:

Grid:-Set(0, A:-work_proc, op(eval(S,1)));
Grid:-Run(0, A:-work_proc,[ 0 ]);
Grid:-Wait();

"My flag is ", true, blech


Download grid_set_module_local_2.mw

This seems like quite a muddle, using the original condition with or without some extra assumptions on the names.

For fun, I throw in a crude, small utility that handles these two examples, but of course is not intended as general purpose; it's just a very short demonstration of concept.

(I'm more concerned about wrong results than FAILS.)

restart;

kernelopts(version);

`Maple 2024.2, X86 64 LINUX, Oct 29 2024, Build ID 1872373`

cnv := ee->Or(map(s->ifelse(nops(s)>1,And(s[]),s[]),
                remove~(evalb,[solve(ee)]))[]):

 

cond := x*z=0;

x*z = 0

is( x*y*z=0 ) assuming cond;

false

is( x*y*z=0 ) assuming cond, x::real, z::real;

false

is( x*y*z=0 ) assuming real, cond;

FAIL

cond2 := cnv( cond );
lprint(%);

Or(z = 0, x = 0)

Or(z = 0,x = 0)

is( x*y*z=0 ) assuming cond2;

true

 

cond := expand(x*(z-1)^2)-x=-x;

x*z^2-2*x*z = -x

is( x*y*(z-1)=0 ) assuming cond;

false

is( x*y*(z-1)=0 ) assuming cond, z::real, y::real;

FAIL

is( x*y*(z-1)=0 ) assuming cond, x::real;

false

is( x*y*(z-1)=0 ) assuming cond, x::real, y::real

true

is( x*y*(z-1)=0 ) assuming real, cond;

true

cond2 := cnv( cond );
lprint(%);

Or(x = 0, z = 1)

Or(x = 0,z = 1)

is( x*y*(z-1)=0 ) assuming cond2;

true


Download is_eq_solve.mw

In your very recent Update notes you wrote, "By passing in the name of the whole module A, now nodes are able to see all module A local vaiables."

But that does not seem to be true. You can do it by using Grid:-Set on the fully qualified module-local name. But your note about passing just the module name works for module exports, which are not declared as module locals.

Your original Question specifically mentioned module locals, and the original examples were about such. Later, (but not the first "Update") you changed to all module exports.

My Answer shows one way it can be done for your original module local example.

@FZ Your image still shows an instance of beta(t), when you assign to B.

First 13 14 15 16 17 18 19 Last Page 15 of 591