acer

32303 Reputation

29 Badges

19 years, 308 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@C_R As stated, your middle paragraph's claim is not true. You wrote, "In Unit:-Simple Maple does not assume anything. The unit of x is left open and no dimensional check is performed unless x is assigned to a value."

Some dimensional checks are done even if x has no assigned value, with Units:-Simple loaded. Perhaps you instead meant to write that no dimensional test is done directly on x itself. That's not what you wrote.

Some dimensional checks are indeed done. That's why the OP's second example fails under Units:-Simple. The dimensional checks performed in that example -- on the terms to which unassigned x is added -- lead to a contradiction.

with(Units:-Simple):

(x+Unit(m))*(x+Unit(s));

Error, (in Units:-Simple:-*) the following expressions imply incompatible dimensions: {Units:-Unit(m)+x, Units:-Unit(s)+x}

Download unsimpex.mw

@Thomas Richard Even with Units:-Simple loaded (via with(Units), or explicitly), there'll always be someone generating expressions with uncombined units.

Eg. using subs instead of the eval export.

@Thomas Richard I feel that another example is useful here, for two reasons:

1) Units:-Split does not first combine units.
2) convert(..,unit_free,t) also allows the unit to be assigned to unevaluated name t.

restart;

expr := 4*x*Unit(cm) + 3*Unit(mm);

4*x*Units:-Unit(cm)+3*Units:-Unit(mm)

 

A,B := Units:-Split(combine(expr,':-units')):

A,B;

(1/25)*x+3/1000, Units:-Unit(m)

S := convert(expr,':-unit_free','T'):

S,T;

(1/25)*x+3/1000, Units:-Unit(m)

Download units_split.mw

Note that with the combine, Split merely returns the expression, and 1 (one) for the unit. (Maple 2024.0)

expr := 4*x*Unit(cm) + 3*Unit(mm);

4*x*Units:-Unit(cm)+3*Units:-Unit(mm)

Units:-Split(expr);

4*x*Units:-Unit(cm)+3*Units:-Unit(mm), 1


Of course, for the OP's original example no extra combine(..,units) or simplify call is needed.

Note that in general that combining also has the effect of turning the result into the base units for the current system, eg. m=meter for SI in the original example. Neither Split alone nor convert(...,unit_free) will affect the units in these (...no addition):

g_moon := 1.635000000*Unit(('m')/'s'^2):

 

A,B := Units:-Split(g_moon):

A,B;

1.635000000, Units:-Unit(m/s^2)

S := convert(g_moon,':-unit_free','T'):

S,T;

1.635000000, Units:-Unit(m/s^2)


These don't change to base units (...no addition).

foo := 1.635000000*Unit(cm/year):

 

A,B := Units:-Split(foo):

A,B;

1.635000000, Units:-Unit(cm/yr)

S := convert(foo,':-unit_free','T'):

S,T;

1.635000000, Units:-Unit(cm/yr)

ps. The Units:-Split command was introduced in Maple 2021, and is not available in earlier versions. The convert(...,unit_free) call works in all previous releases having the Units package.

@salim-barzani See the following attachment, which behaves like dharr's f12, which he ran using Maple 2023.

f12_dharr_ac_2021.2.mw

I converted one expression to `diff` to enable a key substitution to work in Maple 2021, since you have that version.

@salim-barzani 

Please stop posting multiple wholly separate Question threads for the same items.

Such duplicates get flagged as such and may be deleted.

[edit] You can use the Branch button at the bottom of this Question to create a new related Question thread with cross-reference links, so that the content and details are not split.

I have deleted a duplicate of this.

@salim-barzani Wholly separate and duplicate Question threads on this may be flagged and/or deleted.

If you want to spawn a related new Question thread on it then you could use the Branch item at the bottom of this body of this Question.

@janhardo 

Now, how about handling a sequence of more than one assumption (passed together simultaneously, in a list)?

@emendes The coeffs command deals with (expanded) polynomials. But things like cos(w) and exp(s+w) are not polynomial in w, and neither is your expression.

The freeze command can turn expressions into names, and thaw reverts that.

So I use freeze here to turn those problematic terms into temporary names, which makes a polynomial (in your given names and the temp names) out of your expression. Then I get the coefficients of x,y,z,w and these temp names. Then I slap it all into a nice list-of-lists while thawing the temp names back to their original expressions.

The same operations as before, but spilt into more steps:

restart;

expr := alpha*((epsilon-1)*x+y-3*x*z-epsilon/3*x^3+b*sin(w)+3+exp(c+w));

alpha*((epsilon-1)*x+y-3*x*z-(1/3)*epsilon*x^3+b*sin(w)+3+exp(c+w))

V := indets(expr,function(satisfies(u->depends(u,{x,y,z,w})))) union {x,y,z,w};

{w, x, y, z, exp(c+w), sin(w)}

# turning the function calls into names
Vf := freeze~(V);

{w, x, y, z, `freeze/R0`, `freeze/R1`}

subs(V=~Vf,expr);

alpha*((epsilon-1)*x+y-3*x*z-(1/3)*epsilon*x^3+b*`freeze/R1`+3+`freeze/R0`)

R := [coeffs(frontend(expand,[%]), Vf, 'S')];

[3*alpha, alpha, alpha*b, -(1/3)*alpha*epsilon, alpha*epsilon-alpha, alpha, -3*alpha]

# without reverting, via `thaw`
L := [seq([S[i],R[i]],i=1..nops([S]))];

[[1, 3*alpha], [`freeze/R0`, alpha], [`freeze/R1`, alpha*b], [x^3, -(1/3)*alpha*epsilon], [x, alpha*epsilon-alpha], [y, alpha], [x*z, -3*alpha]]

# reverting, via `thaw`
L := [seq(thaw([S[i],R[i]]),i=1..nops([S]))];

[[1, 3*alpha], [exp(c+w), alpha], [sin(w), alpha*b], [x^3, -(1/3)*alpha*epsilon], [x, alpha*epsilon-alpha], [y, alpha], [x*z, -3*alpha]]

# for fun
L := sort(%);

[[1, 3*alpha], [x, alpha*epsilon-alpha], [y, alpha], [x^3, -(1/3)*alpha*epsilon], [x*z, -3*alpha], [exp(c+w), alpha], [sin(w), alpha*b]]

`+`(map(`*`@op,L)[]);

3*alpha+x*(alpha*epsilon-alpha)+alpha*y-(1/3)*alpha*epsilon*x^3-3*alpha*x*z+exp(c+w)*alpha+sin(w)*alpha*b

simplify(expr - %);

0


Download acf_ex3.mw

@janhardo Your latest Reply's attachment contains code with the following mistake:

You have,

   "Definite_integral_with_assumption"
        = proc(expression, assumption::nonnegint) ...  end proc

and your FSsimp code is calling that inner procedure and passing it (the FSimp argument) assumption as its second argument. But your usage examples have the passed values for assumption being things other than actual integers. 

If you try your example,
  e3 := Int(exp(-u*x)*x^(1/3), x = 0 .. infinity);
  FSimp(e3, 15, true, 2, false, u::nonnegint );

then FSimp uses u::nonnegint for its own assumption parameter. And that internal procedure receives u::nonnegint as its own second argument, when called by FSimp.

Now, do you understand that the expression
   u::nonnegint
is not itself an integer? Do you understand that the expression u::nonnegint is not itself of type nonnegint?

Why are you putting the specification ::nonnegint on assumption the second parameter of your inner procedure? It doesn't make sense.

ps. You wrote, "...not working is Definite integral with assumption method yet" [emphasis mine]. But that example did in fact work in the edited attachment I gave in my previous Reply. You've broken it with this new coding mistake.

Please add your followup queries here (eg. about using or subistituting with these values in a loop), instead of spawning wholly separate new Question threads on it.

You want more than 190 edges, for an undirected graph with 20 vertices?

(Of course, a seg-fault is a bug.)

@janhardo There were several basic coding mistakes.

Your integration-with-assumptions procedure was written by you to expect the assumption as second argument, but your code forgot to pass that second argument -- which made it error out.

Also you had the FSimp parameter-specification assumption::algebraic but that type doesn't include u<=0. (now edited in attachment with highlights in red)

Also that method's procedure was only printing its result and returning NULL, instead of actually returning the result (now edited in attachment, but not highlighted).

The algebraic and simplifcation methods were classifed and also utilized with their method numbers mixed up/reversed, by you. That's why your other example was not working. (now edited in attachment with highlights in green)

FSimp-integration-assuming_Mprimes_17-7-2024_ac.mw

ps. I have not changed the basic structure of your approach, even though I think it is misguided. I've only made edits to make it work within your approach.

@Ariathm [edited] The only reason that I used kappa->infinity was because you wrote about that elsewhere in this thread.

It now seems that you don't want kappa=infinity. That was not clear to me. Thanks for followup indicating some aspect of an underlying physical problem.

@nm As you have indicated, this problematic behavior is a regression bug from Maple 2023.2 to Maple 2024.

Elision of very large output used to work fine (for many releases) with typesetting=standard (which was the cross-platform default up until & including Maple 2016).

First 31 32 33 34 35 36 37 Last Page 33 of 591