Question: how to make simplify run through same code each time?

Update 

Also, is there a way to disable the use of remember tables permanently in Maple? This causes me so much trouble and It is cause of why Maple behave differently at different times.

Help shows how to do it if one knows the name of the module or procedure. But Maple has 1000's of these. There does not seem to be a way to tell maple

          forget(all)

and have set once. (may be something I can put in the ini file, to disable this feature).

At the end of help it says

"As a special case, specifying f as an empty range allows for selective clearing of remember table entries from all remember tables in the system.  This requires a second argument, to indicate which entries to clear. For example, forget(..,x), which will clear all remembered entries in the system that reference x.  "

But what is x in the above?? If I do forget(..) it does not work.

---- end update ------------------------------------------------------------------------------------------------------------------

Adding printlevel:=20, I see simplify generate/runs through longer code the first time. The second time calling the same exact simplify code, now it shows it runs through much shorter code. 

I am assuming printlevel is behaving correctly each time.

This must be due to cache simplifies keeps somewhere, or some internal settings it updates from first time and this is what causes it to do shorter run second time.

Without doing restart, how can make force simplify to run through same code it did the first time and each time? i.e. as if it was called the very first time each time?

I tried forget, but it is not doing anything.

Here is worksheet.  The code is simply this

printlevel:=0;
restart;
printlevel:=20;
simplify(3*x^3/x+sin(x^2)/4);  #long printout

simplify(3*x^3/x+sin(x^2)/4);  #short printout

printlevel:=0;
forget(simplify,forgetpermanent = true,reinitialize=true);

printlevel:=20;
simplify(3*x^3/x+sin(x^2)/4); #still same short printout

So there is something else needs to be cleared? Only way to get the long printout is to do restart. but ofcourse I can't do restart in middle of a loop.

I tried gc() also, but had no effect. 

What other commands are there to do this? I do use Physics and it is on my libname.

printlevel:=0;

0

restart;

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1849 and is the same as the version installed in this computer, created 2025, March 12, 12:37 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

printlevel:=20;

20

simplify(3*x^3/x+sin(x^2)/4);

{--> enter sin, args = x^2

{--> enter \`type/SymbolicInfinity\`, args = x^2

false

<-- exit \`type/SymbolicInfinity\` (now in sin) = false}

{--> enter \`sin/normal\`, args = x^2

{--> enter \`tools/sign\`, args = x^2

-x^2

1

<-- exit \`tools/sign\` (now in \`sin/normal\`) = 1}

1

-sin(x^2)

sin(x^2)

<-- exit \`sin/normal\` (now in sin) = sin(x^2)}

sin(x^2)

{--> enter \`trig/linear_in_Pi\`, args = x^2

{--> enter collect, args = x^2, Pi

{Pi}

{Pi}

{}

Pi

recursive

proc (x) options operator, arrow; x end proc

x^2

<-- exit collect (now in \`trig/linear_in_Pi\`) = x^2}

x^2

<-- exit \`trig/linear_in_Pi\` (now in sin) = x^2}

x^2

sin(x^2)

<-- exit sin (now at top level) = sin(x^2)}

{--> enter simplify, args = 3*x^2+(1/4)*sin(x^2)

false

{--> enter \`simplify/do\`, args = 3*x^2+(1/4)*sin(x^2)

{--> enter \`tools/membertype\`, args = Not(Or(algebraic, list, set, relation, range)), 3*x^2+(1/4)*sin(x^2)

false

<-- exit \`tools/membertype\` (now in \`simplify/do\`) = false}

{--> enter \`simplify/check_constant\`, args = 3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/check_constant\` (now in \`simplify/do\`) = false}

false

"top"

3*x^2+(1/4)*sin(x^2)

1

{}

{--> enter \`type/ratpoly\`, args = 3*x^2+(1/4)*sin(x^2), complex(numeric)

{x}

<-- exit \`type/ratpoly\` (now in \`simplify/do\`) = false}

{--> enter \`simplify/recurse\`, args = 3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/recurse\` (now in \`simplify/do\`) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

[]

table( [ ] )

{3*x^2+(1/4)*sin(x^2)}

{--> enter \`simplify/check_constant\`, args = 3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/check_constant\` (now in \`simplify/do\`) = false}

false

{--> enter \`simplify/getkernels\`, args = 3*x^2+(1/4)*sin(x^2), false

{x^2, (1/4)*sin(x^2), 3*x^2+(1/4)*sin(x^2), sin(x^2)}

<-- exit \`simplify/getkernels\` (now in \`simplify/do\`) = {x^2, (1/4)*sin(x^2), 3*x^2+(1/4)*sin(x^2), sin(x^2)}}

{x^2, (1/4)*sin(x^2), 3*x^2+(1/4)*sin(x^2), sin(x^2)}

{--> enter \`simplify/getinds\`, args = {x^2, (1/4)*sin(x^2), 3*x^2+(1/4)*sin(x^2), sin(x^2)}

{power, trig}

<-- exit \`simplify/getinds\` (now in \`simplify/do\`) = {power, trig}}

{power, trig}

{--> enter \`simplify/sortinds\`, args = {power, trig}

53

48

[[power, 53], [trig, 48]]

[trig, power]

[trig, power]

<-- exit \`simplify/sortinds\` (now in \`simplify/do\`) = [trig, power]}

[trig, power]

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

[trig, power]

1

`simplify/trig`

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2), [power]

`simplify/power`

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2), []

3*x^2+(1/4)*sin(x^2)

{--> enter \`simplify/check_constant\`, args = 3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/check_constant\` (now in \`simplify/do\`) = false}

false

{--> enter \`simplify/getkernels\`, args = 3*x^2+(1/4)*sin(x^2), false

{x^2, (1/4)*sin(x^2), 3*x^2+(1/4)*sin(x^2), sin(x^2)}

<-- exit \`simplify/getkernels\` (now in \`simplify/do\`) = {x^2, (1/4)*sin(x^2), 3*x^2+(1/4)*sin(x^2), sin(x^2)}}

{}

{--> enter \`type/ratpoly\`, args = 3*x^2+(1/4)*sin(x^2), extended_numeric

{x}

<-- exit \`type/ratpoly\` (now in \`simplify/do\`) = false}

{--> enter \`simplify/getinds\`, args = {x^2, (1/4)*sin(x^2), 3*x^2+(1/4)*sin(x^2), sin(x^2)}

{power, trig}

<-- exit \`simplify/getinds\` (now in \`simplify/do\`) = {power, trig}}

{--> enter \`simplify/sortinds\`, args = {power, trig}

53

48

[[power, 53], [trig, 48]]

[trig, power]

[trig, power]

<-- exit \`simplify/sortinds\` (now in \`simplify/do\`) = [trig, power]}

[trig, power]

{--> enter \`simplify/power_exp\`, args = 3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

false

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

true

<-- exit \`simplify/power_exp\` (now in \`simplify/do\`) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

{--> enter \`simplify/check_constant\`, args = 3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/check_constant\` (now in \`simplify/do\`) = false}

false

{--> enter \`simplify/do/content\`, args = 3*x^2+(1/4)*sin(x^2)

1/4, 12*x^2+sin(x^2)

<-- exit \`simplify/do/content\` (now in \`simplify/do\`) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

{--> enter \`simplify/recurse_on_constants\`, args = 3*x^2

3, x^2

<-- exit \`simplify/recurse_on_constants\` (now in \`simplify/do\`) = 3*x^2}

{--> enter \`simplify/recurse_on_constants\`, args = (1/4)*sin(x^2)

1/4, sin(x^2)

<-- exit \`simplify/recurse_on_constants\` (now in \`simplify/do\`) = (1/4)*sin(x^2)}

{--> enter \`simplify/recurse_on_constants\`, args = 3*x^2+(1/4)*sin(x^2)

0, 3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/recurse_on_constants\` (now in \`simplify/do\`) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/do\` (now in simplify) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

{--> enter simplify, args = 3*x^2+(1/4)*sin(x^2), size, applysimplifysize = false

{--> enter \`simplify/do\`, args = 3*x^2+(1/4)*sin(x^2), size

false

3*x^2+(1/4)*sin(x^2), size

2

{}

[`simplify/size`]

table( [ ] )

{3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

<-- exit \`simplify/do\` (now in simplify) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

<-- exit simplify (now in simplify) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

<-- exit simplify (now at top level) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

simplify(3*x^3/x+sin(x^2)/4);

value remembered (at top level): sin(x^2) -> sin(x^2)

{--> enter simplify, args = 3*x^2+(1/4)*sin(x^2)

false

value remembered (in simplify): \`simplify/do\`(3*x^2+(1/4)*sin(x^2)) -> 3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

{--> enter simplify, args = 3*x^2+(1/4)*sin(x^2), size, applysimplifysize = false

3*x^2+(1/4)*sin(x^2)

<-- exit simplify (now in simplify) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

<-- exit simplify (now at top level) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

printlevel:=0;
forget(simplify,forgetpermanent = true,reinitialize=true);

0

printlevel:=20;

20

simplify(3*x^3/x+sin(x^2)/4);

value remembered (at top level): sin(x^2) -> sin(x^2)

{--> enter simplify, args = 3*x^2+(1/4)*sin(x^2)

false

value remembered (in simplify): \`simplify/do\`(3*x^2+(1/4)*sin(x^2)) -> 3*x^2+(1/4)*sin(x^2)

3*x^2+(1/4)*sin(x^2)

{--> enter simplify, args = 3*x^2+(1/4)*sin(x^2), size, applysimplifysize = false

3*x^2+(1/4)*sin(x^2)

<-- exit simplify (now in simplify) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

<-- exit simplify (now at top level) = 3*x^2+(1/4)*sin(x^2)}

3*x^2+(1/4)*sin(x^2)

 

 

Download how_to_clear_simplify_cache_march_24_2025.mw

Anyone has Maple 2025 could check if same behaviour there also?

Please Wait...