Carl Love

Carl Love

24332 Reputation

25 Badges

9 years, 356 days
Natick, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@MathPrincess123 

I thought that you might want to handle the negative-exponent case, but I didn't include it because the quotient and remainder need to be treated separately. To restore the original variable, the exponents of the remainder need to be reduced in the negative direction, but the exponents of the quotient do not.

So, add this procedure:

QuoRem:= proc(n, d, x::name)
local X, ND, R, m, q, r;
    (ND,R):= FractionalExponentAdjuster([n,d], x, X);
    m:= min(0, ldegree~(ND, X)[]);
    q:= quo(expand(ND/~X^m)[], X, r);
    #Remainder gets downshifted, but quotient does not:
    R(q), R(expand(X^m*r))
end proc
:

To use it, simply do

(qNSR, rNSR):= QuoRem(NSR, deltaa, q);
expand(qNSR*deltaa + rNSR - NSR);
#Test---should get 0

And, no, it was not "an easy question".

@Wes I don't think that you understand the meaning of CDFPDF, and Quantile. If is a continuous random variable, and x is a real number, then CDF(X, x) is the probability that X <= x. So, CDF returns a probability, a number between 0 and 1. PDF(X, x) is the derivative with respect to x of CDF(X, x). It is mainly of theoretical interest; there's no practical value to evaluating it at a specific number such as with your attempt PDF(Y, 0.05)Quantile(X, p) is the functional inverse of CDF(X, x); in other words, it's the solution x of the equation CDF(X, x) = p. Note that p here is a probability.

@max125 What output were you expecting? If it's [2, 7], it can be obtained as 

(f@op)~([[2,0], [3,4]]); 

@vv After doing several experiments replacing the bindings with modules (either nested or unnested), I agree with you that it's a bug; the result should be (a+b)*a. For example, nested modules:

restart:
A:= module() export a:= :-a+b, B:= module() export b:= a - :-b; end module; end module:
use A in use B in a*b end use end use;

 

@vv My guess is that the order that the automatic simplifications are applied makes the difference.

@vv It agrees, like this:

`%%%%subs`(
    {x= 0, y= 0}, 
    `%%%subs`(a= a+b+x, `%%subs`(%subs(a= a+b+x, b= a-b+y), a*b))
):
(value@@4)(%);
                                   2
                            (a + b) 

(I realize that there are problems with this example!)

@vv I think that you're ignoring that the outer use also changes the a in b= a-b.

I make sense of this example via this simulation:

`%%%subs`(a= a+b, `%%subs`(%subs(a= a+b, b= a-b), a*b));
  %%%subs(a = a + b, %%subs(%subs(a = a + b, b = a - b), a b))

value(%);
              %%subs(a = a + b, %subs(b = a, a b))

value(%);
                           /            2\
                      %subs\a = a + b, a /

value(%);
                                   2
                            (a + b) 

 

@The function Show a worksheet for what you did get. B.A is definitely a 3x3 matrix, both in Maple and in math.

@The function The angle bracket constructor for row vectors uses the vertical bar character (|) as the element separator:

A:= <1 | 3 | 4>;

You can also enter it as a column vector and take its transpose:

A:= <1, 3, 4>^%T;

B:= <5, -2, 1>;

Multiplication of vectors and matrices is non-commutative (i.e., order matters), so it uses a different operator: the dot `.` rather than `*`.

A.B; B.A;

In this case, A.B will be a single number, and B.A will be a 3x3 matrix.

@ecterrab You wrote:

  • ...unwith unloads the package and forget clears remember tables from results obtained with the package, both concepts apply to any package. This is expected and what one needs to do, @Carl Love....

Look again at my 2nd example, repeated below. The result that I wanted to remove hadn't been obtained with the package, and, had I been a naive user, I would have had no reason to suspect that the result was different simply because Physics had been loaded (yet hadn't been otherwise used).

#In this example, no command from Physics is explicitly used, yet the results
#from top-level :-diff are different.
restart:	
with(Physics): 	
:-diff(:-conjugate(f(x)), x);

Of course, in actual practice there's a lengthy computation that involves diff rather than a simple call to diff as shown. Thus, a naive user would have no way of knowing what needs to be forgotten.

@Preben Alsholm Thank you. That second example  is more concerning to me because there's no way to know which commands one needs to apply forget to. The unwithing routine for Physics should have the responsibility of taking care of the forgetting.

The example that led to my discovery of this anomaly was a Question here on MaplePrimes that I was attempting to answer yesterday. The user had done with(Physics) just to use Physics:-Setup(...). Then we tried to remove some higher-degree terms from a complicated PDE containing some derivatives of conjugates of the unkown functions. After many attempts, I noticed that the result was completely different depending on whether with(Physics) had been used. Naturally, the next thing I tried was replacing diff with :-diff, to no avail.

By the way, I have no opinion about which form of the derivative of conjugate is better. I just think that there should be a way to switch from one to the other without rigamarole.

@acer Thank you. I guess that there's a bug in forget when the syntax forget(.., whatever) is used. 

The procedure `simpl/conjugate` is on the list of 130 procedures that I just posted above.

@vv For what it's worth, here is a list of 130 top-level-named procedures and appliable modules that reference either the Physics package or global `Physics/Initialized`. (Yes, I realize that many of these are members of older table-based packages and are thus in some sense not top-level names.)

restart:
kernelopts(opaquemodules= false):
interface(warnlevel= 0):
Ph:= CodeTools:-Usage(
    select(
        P-> local pn;            
            try        
                (pn:= ``||(P))::callable
                and indets(
                    ToInert(eval(`if`(pn::procedure, pn, pn:-ModuleApply))),
                    identical("Physics", "Physics/Initialized")
                ) <> {}
            catch: false
            end try,        
        index~(op~(1, {LibraryTools:-ShowContents()[]}), ..-3)
    )
): 
nops(Ph);
(p-> printf("%A\n", p))~(sort([Ph[]])):  
memory used=0.52GiB, alloc change=211.81MiB, 
cpu time=11.24s, real time=10.50s, gc time=2.25s

                              130

ODEtools/Xcommutator
ODEtools/Xgauge
ODEtools/ch
ODEtools/collect
ODEtools/equinv
ODEtools/firint
ODEtools/firint/PDE
ODEtools/first_integral
ODEtools/get_diff_vars_in_expression
ODEtools/info
ODEtools/isolate
ODEtools/odepde
ODEtools/odsolve
ODEtools/redode
ODEtools/remove/hard
ODEtools/subs/do
ODEtools/y(x)_to_y
PD/convert/compseq
PD/diff
PDEAdvisor/high_order/Fourier
PDEAdvisor/high_order/Hankel
PDEAdvisor/high_order/Laplace
PDEAdvisor/high_order/Mellin
PDEtools/U_to_u
PDEtools/difforder/do
PDEtools/isolate
PDEtools/pdesys
PDEtools/useD
PDEtools/useD/diff_to_D
PDEtools/useD/onediff
assuming
assuming/names
combine/cmbtms
combine/exp
combine/linear
combine/linear/do
combine/linear/sort
combine/power
combine/wrt
convert/D
convert/DESol
convert/eval/from_diff
dchange/diff/tr+itr
dchange/funcs
dsolve
dsolve/IC
dsolve/IC/easy
dsolve/IC/get_x_val_and_diff_ord
dsolve/IC/implicit
dsolve/PDE
dsolve/func_in_args
dsolve/general_and_particular
eval/Diff
eval/diff
evalc/abs
evalc/evalc
expand/conjugate
expand/exp/+
expand/ln
expand/power
index/PhysicsTensor
intat
intfactor/formal
is/internal
is/internal/eqns_inds
is/preproc
is/solve
latex
liesymm/convert/D
odeadv/MRL/ch
odeadv/sym_pat/[F(x)+G(y),0]
odetest
odetest/ODESolStruc
odetest/linear
odetest/series
odsolve/Riccati/symmetric
odsolve/high_order/exp_reduce/integrate
odsolve/parametric/Lie
odsolve/solvable/do
odsolve/solvable/linear_homogeneous
odsolve/sort_ODESolStruc/DESol_reduction
pdetest
pdsolve
pdsolve/BC/2nd_order/Series
pdsolve/LagrangeCharpit
pdsolve/ToMissingDependentVariable
pdsolve/checksol
pdsolve/fixedfunc
pdsolve/iPDE
pdsolve/info
pdsolve/resinco
pdsolve/sep/casesplit/do
pdsolve/strip/solve/dsys
pdsolve/sys/hint2
pdsolve/sys/info
pdsolve/sys/sequential
pdsolve/sys/sort
pdsolve/sys/sort/lex
print/Diff
print/Int
print/diff
print/int
property/ObjProperty
redode/many
sdsolve/odeset
sdsolve/ok
sdsolve/process_answer
sdsolve/sequential/sys_and_funcs
sdsolve/sysODE/islinear
signum
simpl/abs
simpl/conjugate
simplify/commonpow
simplify/conjugate
simplify/table
symgen/formal
tools/RewriteRoutinesToUsePhysicsCommands
tools/Typeset
tools/UsePhysics
tools/UsePhysicsOperators
tools/atomize_names
tools/degree
tools/df_dt
tools/map
tools/operate_on_sequence
tools/type
type/PDEtools/known_function
type/PhysicsUnitVectors
type/PhysicsVectors
value/Intat/do

 

@Ahmed111 In Maple 2022, the result depends on whether or not you use with(Physics). If you don't, the result is 0. So, in your Maple 18, it may be 0 even if you do use with(Physics). I note (see the Question that I recently posted) that Physics:-diff and regular diff treat conjugate differently, and that once either with(Physics) or Physics:-diff is used, it's impossible to get back the regular diff behavior without a restart

@Ahmed111 How do you want the derivatives of the epsilons to be handled in the linearization? For example, I could remove all terms that contain an epsilon derivative (of any order) raised to power 2 or higher.

1 2 3 4 5 6 7 Last Page 1 of 634