## 1002 Reputation

1 years, 231 days

## observation...

In theory, this should be a workaround:

```restart;
use MmaTranslator:-Mma in MapAll(Chop, 1.378834798932344e-15*I*t) end;
# Nevertheless, it does not work as expected.
Error, (in MmaTranslator:-Mma:-MapAll) too many levels of recursion```

But strangely, this works well:

```use MmaTranslator:-Mma in map(Chop, 1.378834798932344e-15*I*t) end use;
=
0

```

Though @acer's approach works here, the `MmaTranslator:-Mma` subpackage does not seem to allow us to go beyond the basics.

## A workaround that still makes use of `su...

You may have to use:

```restart;
(proc(` \$`)
local `&*`;
redefine(`&*`, ['associative']); # Regretfully, “setattribute(`&*`, 'associative');” does not work here.
use `*` = `&*` in
local expr := -(r0+Delta_r)^2*(46*r0-41*Delta_r)*r0^5;
subsop(1=a,2=b,3=c,4=d, expr)
end;
eval(`%`, `&*` = `*`)
end)() =
a b c d

```

The key is 'associative' (instead of `&*`).

## Abs...

Another way may be

`DETools:-DEplot(diff(y(x), x) = abs(1/sqrt(1 - x^2)), y(x), x = -.99 .. .99, y = -1.6 .. 1.6, [y(0) = 0], 'arrows' = 'fish'):`

## Order...

According to the help page, “If the third argument n is present then it specifies the "truncation order" of the series calculations”, so you may simply use:

```series(BesselK(4, x), x = 0, 0);
(-4)      (-2)    / 0\
48 x     - 4 x     + O\x /

```

## Replace...

To avoid explicit "*" or "·", I think that you can use

`subs("&sdot;" = "&#32;", InertForm:-Display((* an inert-form expression *), 'inert' = false));`

As for the second point, maybe you can use

`Sol2 := InertForm:-Display((`%/`@`?[]`@[primpart*numer, denom]*primpart)( Sol2 ), 'inert'=false):`

## expected_type...

```(convert~)~(convert~(convert(x*y*z*z*w*w*w, list, `+`), list, `*`), list, `^`);
=
[[[x, 1], [y, 1], [z, 2], [w, 3]]]

```

?

## Place quotation marks around paths conta...

According to the documentation of Cmd.exe, if the directory path, files, or any information you supply contains spaces, you must use double quotation marks around the text. So a potential workaround is:

```restart; kernelopts(opaquemodules = false):
Compiler:-Build:-buildVarDB["X86_64_WINDOWS"]["LDLIBS"] := StringTools:-RegSubs(StringTools:-Join([convert(curry(sprintf, "(%s%s.*%s)"), function, StringTools:-Escape~([kernelopts('bindir'), kernelopts('dirsep'), ".lib"], 'regexp')) \$ 3], " ") = "\"1\" \"2\" \"3\"", Compiler:-Build:-buildVarDB["X86_64_WINDOWS"]["LDLIBS"]()):
# Thereafter `Compiler:-Compile` will work. ```

I am not sure if this works on your computer, but at least this works for me.
Note that on Windows platforms, the default external C++ compiler distributed with Maple is Clang, so one can download the latest release of the LLVM-based MinGW and then replace the subfolder \$MAPLE_ROOT/llvm manually.

 > restart;
 > interface(verboseproc = 0):
 > p := proc (x::float)::float: options trace: 2.3*x end:
 > cp := Compiler:-Compile(p)
 > assigned(cp);
 (1)
 > kernelopts(opaquemodules = false):
 > Compiler:-Build:-buildVarDB["X86_64_WINDOWS"]["LDLIBS"] := StringTools:-Join(String~("\"", Compiler:-Tools:-fullPath~(Compiler:-Tools:-pathCat~(kernelopts(':-bindir'), ["mrt.lib", "libhf.lib", "maple.lib", NULL])), "\""), " "):
 > cp := Compiler:-Compile(p);
 (2)
 > cp(1e1);
 {--> enter p, args = .1e2
 (3)
 >

## another workaround...

This also works:

```bound := 0:
do until SMTLIB['Satisfiable'](And(
(154*x + 69*y) - 0 = 7**3*m1,
(13*x + 716*y) - 0 = 13**3*m2,
(23*x + 3059*y) - 0 = 23**3*m3,
x > 0, x < y, y = ++bound),
'logic' = "QF_LIA"):
bound;
=
18837

```

Unfortunately, it takes several minutes to solve on my low-end PC.
That may fell a bit slow, yet the human time required to code a faster algorithm is a lot longer than several minutes and perhaps longer than one care to wait.

Edit. Of course the original problem can be reformulated as an integer linear program, but to the best of my knowledge, none of "exact" solvers are integrated into (and accordingly, are unable to take advantage of) modern computer algebra systems. (Actually, when I search for this term, I can only find exact SCIPExact, QSopt_ex and SoPlex, which are all irrelevant to a CAS that is capable of carrying out computations analytically.) Alas, what a pity!

## General outer product...

If I understand right, "[x^2-x*y, x*y-y^2, x*z-y*z, -x^2+y^2, x*y+x*z]" can be obtained as follows:

```convert(expand({eval(MmaTranslator:-Mma:-Distribute([x - y]*[x, y, z], list, `*`), list = expand@``), -x^2 + y^2, x*y + x*z}), list);
=
[       2    2    2   2                            ]
[x y - y , -x  + y , x  - x y, x z - y z, x y + x z]

```

And "[x^3-x^2*y, x^2*y-x*y^2, x^2*z-x*y*z, x*y^2-y^3, x*y*z-y^2*z, x*z^2-y*z^2, -x^3+x*y^2, -x^2*y+y^3, -x^2*z+y^2*z, x^2*y+x^2*z, x*y^2+x*y*z, x*y*z+x*z^2, -x*y*z+z^3, x*y^2+y*z^2-z^3]" can be obtained as follows:

```convert(expand({eval(MmaTranslator:-Mma:-Distribute([x^2 - x*y, x*y - y^2, x*z - y*z, -x^2 + y^2, x*y + x*z]*[x, y, z], list, `*`), list = expand@``), -x*y*z + z^3, x*y^2 + y*z^2 - z^3}), list);
=
[   2    3    2      3   2        2    3      2   3    2
[x y  - y , -x  y + y , x  y - x y , -x  + x y , x  - x  y,

2      2            3           2               2
x z  - y z , -x y z + z , x y z - y  z, x y z + x z ,

2            2      2     2             2      2
x y  + x y z, -x  z + y  z, x  z - x y z, x  y + x  z,

2      2    3]
x y  + y z  - z ]

```

## Replace...

@minhthien2016 Alternatively,

```subs('y' = 1, collect('y' * ~ [exp1, exp2], x, normal));
=
[ 3              2                 3            2              ]
[x  + (3 m - 1) x  - (4 m + 3) x, x  + (m + 1) x  + (4 m + 3) x]

```

## pattern matching...

```solve('identity'(aa/f^bb = 1.234/(f^6.789), f), {aa, bb});
=
{aa = 1.234000000, bb = 6.789000000}

PDETools:-Solve(aa/f^bb = 1.234/(f^6.789), {aa, bb}, 'independentof' = f);
=
{aa = 1.234000000, bb = 6.789000000}

```

`match`/`patmatch`/`typematch` also works.

## Getting work done shouldn't be a struggl...

For some unknowable reason, Maple cannot fully simplify the L. Fortunately, a workaround exists:

 > restart;
 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >

## Apply a specified reduction argument to ...

```nequal:=proc(\$)
options hfloat;
if procname::indexed(posint&under(k->k-2))then
local n:=op(procname),l:='`tools/genglobal`(evaln(i))'\$n-1,j,m::nonnegint:=0;
eval(eval(foldl(uneval(seq),ifelse((n-2)*24-`+`(l)>=1,++m,NULL),seq(l[j]=ceil(((n-2)*24-`+`(l[..j-1]))/(n-(j-1)))..`if`(j>1,l[j-1],(n-2)*24-(n-1)),j=n-1..1,-1))));
print(m)
fi
end:```

Unfortunately, it is not more efficient:

```(* a function analogous to OP's `nequal3` and `nequal4` *)
nequal5:=proc()
option autocompile;
local u,v,w,x,a_5;
a_5:=0;
for u from ceil((5-2)*24/(5-0)) to (5-2)*24-5+1 do
for v from ceil(((5-2)*24-u)/(5-1)) to u do
for w from ceil(((5-2)*24-u-v)/(5-2)) to v do
for x from ceil(((5-2)*24-u-v-w)/(5-3)) to w do
if (5-2)*24-u-v-w-x>=1 then
a_5:=a_5+1;
end if;
end do;
end do;
end do;
end do;
print(a_5);
end proc:```
```CodeTools:-Usage(nequal[5]()):
CodeTools:-Usage(nequal5()):  =
10642

memory used=135.94MiB, alloc change=8.00MiB, cpu time=3.59s, real time=3.54s, gc time=187.50ms

10598

memory used=35.71KiB, alloc change=0 bytes, cpu time=94.00ms, real time=87.00ms, gc time=0ns

```

Yet the result is guaranteed to be correct.

## uneval...

E.g.,

```decisions := "accept", "reject":
T := 2:
`?()`(`if`, [T < 1, decisions]);
=
"reject"

```

Note that here you cannot directly use `apply`.
Another way:

```eval('ifelse'(T > 1, decisions));
=
"accept"

```
 1 2 3 4 5 Page 2 of 5
﻿