Carl Love

## 27229 Reputation

11 years, 346 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

## infolevel...

@Alfred_F The easiest way to get some information about what's going on is to set the infolevel. This gives a relatively small amount of info (compared to other ways in Maple), but it's high-quality info because it's formatted details put in the code by its author specifically for you to read. The following returns about 4 screenfuls of info for this problem.

```restart:
infolevel[all]:= 5:
[y, s, x, a, b, c, d]=~ (simplify@eval)(
[sqrt(a^2+b^2), d-b, sqrt(a^2+d^2), a, b, d, b],
solve(
{
d-b = c-d, a/d = tan(45*Pi/180), a*(c-b)/2 = 60, a^2+c^2 = 19^2,
(a,b,c,d ) >~ 0
},
{a,b,d,c},
explicit
)
);
```

The is the level of detail; it could be any positive integer. Usually 5 is the most detail, but that's up to the code's author. The all sets this for all Maple procedures. It could also be a specific command, such as solve.

If you run something, and then want to rerun it with infolevel turned on, make sure to do a restart first. This is to prevent Maple from simply remembering recently done computations and not actually redoing them.

## Worksheet has no code...

As far as I can tell, the worksheet that you posted has no code, only components. I looked for hidden "startup code" and "component code" but didn't find any. However, I admit that I don't know much about finding component code.

## With bells and whistles...

```plots:-spacecurve(
[t*cos(t), t*sin(t), 2/3*sqrt(2)*t^(3/2)], t= 0..Pi,
color= black, thickness= 5,
axis[1]= [color= red, thickness= 3, tickmarks= [-2,2]],
axis[2]= [color= green, thickness= 3, tickmarks= [-2,2,4]],
axis[3]= [color= blue, thickness= 3, tickmarks= [2,4,6,8]],
labels= ['x', 'y', 'z'], labelfont= [helvetica, bold, 14],
axesfont= [helvetica, 12],
view= [-3..3, -2..4, -1..8], scaling= constrained, axes= normal,
projection= .7, orientation= [45, 85, 0]
);```

## Math AI system...

If one is building an AI system capable of solving math word problems, then after the system has translated the problem from natural language to mathematical language (such as algebra), it still needs to know how to enter the problem into Maple (or other CAS). That step---translating from mathematical language to CAS input---is not trivial, even if the work that the CAS needs to do after receiving the input is trivial.

This is an excellent problem for testing or training such a system.

Furthermore, the Maple input needed to solve this isn't trivial, even if the computation that Maple does is. An "epsilon" such as vv used is needed.

## "no improved point could be found"...

@Andiguys To get a plot, you'll need some points where Maximize has actually done something, rather than saying "no improved point could be found."

## coulditbe may be based on solve...

@sursumCorda The true result returned by coulditbe in this case may simply be due to the incorrect result from solve, so I wouldn't judge it too harshly based on this example alone. Still, it would be preferable for it to return a witness.

## I don't get your point...

@Christian Wolinski I don't understand the point that you're trying to make. Could you explain further?

My point is that solve(sys, {p}) returns an incorrect result--one that returns false when substituted back into sys. The fact that solve(sys, {q}) and solve(sys, {p,q}) return correct results is irrelevant (to my current point, but not irrelevant to the overall problem). I obtained the sys immediately above as a pared down case only for the purpose of submitting a bug report. The sys from the OP's actual problem (one of the 98) was actually

sys:= {
p^2*q^2-4*q^3 = 0,  2*p^5-15*p^3*q+27*p*q^2 <= 0,
p < 0, -q < 0, -q^2 < 0, -2*p^2+3*q < 0, -p^2+3*q < 0
}:

@segfault Many procedures in the Maple library (and there are many thousands) are short (say, 5 t0 20 lines) and written in fairly easy to understand Maple. As you read these, you will encounter a few unfamiliar commands, such as `tools/genglobal`. If you're reading a procedure that has many unfamiliar commands, you should probably move on to an easier procedure.

The command LibraryTools:-Browse gives you convenient access to all procedures in the library that are written in Maple, which is the vast majority.

The following is a learning exercise that I devised and practice very frequently. There is no better way to learn a computer language:

1. Find a procedure or other code written by someone else that seems bloated, overwritten, or hard-to-read, etc. Your goal is to simplify this code (without changing its output). Numerous examples can of course be found here on MaplePrimes. The best examples are procedures that have repeated subexpressions. Your goal then is to remove as much repetition as possible. Also, remove unnecessary parentheses.
2. It would be best if you only have a very vague idea of the purpose of the code. This forces you to only make small changes rather than doing a top-down rewrite. But, you may make a great many very small changes.
3. If the code has comments or the author has said something about it, ignore it. Assume (for the time being) that they are likely mistaken. However, assume that the code does something useful (that you don't understand) for somebody and does it correctly. Obviously, this means that you can't practice this exercise on code that has syntax errors, doesn't compile, etc.
4. For each small change that you consider making, ask yourself whether there's any possibility that the code change could change the output. If your answer is "No", make the change. If you can't answer it, run some small test cases of the same small change by itself in some other area than the main code (such as in a scratch worksheet). You don't need to prove mathematically that the code change won't change the output; empirical evidence is enough. Reading help pages is fine at this point.
5. For every small change, check that the code is still syntactically correct. In Maple, you just need to press Return to do this. This makes Maple an excellent learning environemnt.
6. Every few minutes, check that the code still produces the same output.

## Just stop using it...

@segfault Just stop using the procedure and it will revert.

## Got it, thanks...

@nm Thanks, I understand now,

## Which RootOf?...

Please point  out which RootOf needed to be evaluated twice and repost the worksheet with that RootOf hightlighted.

## Bug is in solve...

@sursumCorda No, the bug is in solve, as my Answer clearly shows. RealDomain:-solve is just repeating what it got from solve. If you filed a report against RealDomain:-solve, you should amend it. And I hope you didn't include your whole problem in the report. The complete bug is shown by this simple example:

```sys:= [p^2-4*q = 0, 2*p^5 - 15*p^3*q + 27*p*q^2 < 0]:
solve(sys, {p});
/        (1/2)\    /       (1/2)\
{ p = -2 q      }, { p = 2 q      }
\             /    \            /

eval(sys, [q=1, p=2]);
[0 = 0, -2 < 0]

```

It could be that inequalities with high-degree polynomials are being ignored by solve.

There was no good reason to use RealDomain:-solve. If there are no complex solutions, then there are no real solutions either. It is IMO one of the most frequently misused commands in Maple.

When coulditbe returns true or is returns false, they don't provide witnesses. This alone makes them nearly impossible to trust. The much-more-sophicated command QuantifierElimination:-QuantifierEliminate provides witnesses.

Anytime that you have a combination of algebraic relations and logical operators, you should put it in DNF before procveeding.

## evalindets vs, indets (again)...

I don't intend to sound harsh or critical; I just want you to understand this difference between indets and evalindets or subsindets.

Although your Answer above works well, in light of the other "evalindets vs. indets" Reply that I just posted, I take this as further evidence that you've somehow switched the meanings of evalindets and indets in your mind. Specifically, the evidence in this case is that these 3 lines from your procedure above:

C_used:= indets(sol, And(symbol, suffixed(c__,  nonnegint))):
my_C := map(X-> X = `tools/genglobal`(c__), C_used):
eval(sol, my_C);

do exactly the same thing as

evalindets[flat, 2](sol, suffixed(c__, nonnegint), c__, `tools/genglobal`);

The process requested in this Question is not simply to find the constants (for which indets works great), but to find and replace them, which is a task for evalindets or subsindets.

## indets vs. evalindets...

@nm I think that you don't understand the difference between indets and evalindets. The former, indets, is for simply finding subexpressions; whereas evalindets (or subsindets) are for simultaneously finding and replacing subexpressions.

It's only somewhat of a coincidence that your use of evalindets above works, the coincidence being that the DESol is the entire thing being searched, not merely a subexpression of the thing being searched. So, to extract the 1st argument(s) of any DEsol(s), do

ode:= diff(y(x),x)-y(x)*a-b*y(x)^2=f(x):
my_sol:= DESol( ode, y(x) ):

(op@op~@@2)(1, indets(my_sol, specfunc(DESol)));

To extract the 2nd argument(s), change 1 to 2.

## I use those from context menu...

@C_R Yes, I use those from the plot context menu, not from a toolbar. I wasn't even aware of the existence of a plot toolbar until you showed it a few Replies ago.

 1 2 3 4 5 6 7 Last Page 1 of 699
﻿