Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 32 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@mmcdara Can you explain why your graphs have a cusp at 3*Pi/2? I'd intuitively expect the mean to be a differentiable function of the angle (but I'm not absolutely sure about that).

Continuing where the last post left off:

So, now that you've had a chance to think about last name evaluation, this may already be obvious: If LNE structures are assigned to both A and B (and even if those structures are identical, with the same address), then addressof(A) and addressof(B) will be different, simply because 'A' and 'B' are different. Whereas addressof(eval(A)) and addressof(eval(B)) will reveal information about the stored structures, which may be the same or different (which is the point that Preben made).

LNE is the sole reason for the apparently special effect that eval has on named tables, procedures, and modules (there is no special effect when those structures are unnamed (aka anonymous)). So the role of eval in your initial Question is trivial, and you should edit the title.

What the disassembly of a structure means: Your next set of questions is about diassemble(addressof(A)), etc. For your first example, the returned numbers are

8, 18446744074328626590, 18446744074328154110, 18446744073709551745

As you might guess from its name, disassemble shows the component substructures. The first number, 8, is a key to what type of structure is stored here. The key can be decoded via kernelopts(dagtag= key), In this case, that returns NAME, which makes sense: A is a name (not a table because of LNE). The second number is the address of what's stored in name A, in this case the table. The third number is a pointer (aka address) to the attributes of A (this is an uncommonly used Maple feature (see ?attributes)). The 4th number is a pointer to the string of characters that is literally the name of A, namely "A". If you pointto that last number, you get 65, which is the ASCII byte code for character A. (You cannot experiment with this by copy-and-pasting the above addresses because addresses are session dependent. You'll need to re-execute the relevant addressof commands.)

What about table references? Your next series of issues deals with table references, such as A[1], B[1], A[2]. Unlike tables themselves, table references do not have the LNE property. So, both addressof(A[1]) and addressof(B[1]) are equivalent to addressof("a"). Thus, they are necessarily equal.

If you want information about the table references themselves, then you need to use unevaluation quotes: addressof('A[1]'), etc. If you then disassemble this and look up its dagtag, 10, you'll see that it's a TABLEREF.

I think that I have now provided enough information for you to understand every issue that you raised. If not, or if you have any further questions, let me know.

@sand15 The anomaly with the saved files from your initial Question had nothing to do with tables; however, the anomalies discussed in your most-recently-posted worksheet are specific to tables (and a few other data structures). The relevant phenomenon is called last name evaluation (see ?last_name_eval), and it applies only to tables, procedures, and modules (except modules that are objects). For brevity, I'll call the relevant types LNE.

If a data structure of any non-LNE type is assigned to a name, as in

A:= 7:

then the following relation is false:

addressof(A) = addressof('A'),

the left side being the address of the integer 7 and the right side being the address of the literal name A.

If the 7 in the example is replaced by an LNE-type structure, then the address relation will be true, with both addresses being that of the literal name A. This concept explains many of the anomalies shown in your worksheet.

 

@bliengme Thank you for the kind words. I look forward to seeing the plot that you come up with. There are so many options that can be added.

Unfortunately, you've introduced a major new error into the worksheet, and it's much more serious than anything else discussed so far in this thread. It's only by a remarkable coincidence that you still got the correct final answer. The error is the line k:= k*t. The remarkable coincidence is that that's effectively the same as temporarily setting t=1, which happens to be what t should be at that point. But you can't rely on that! And it's totally baffling to the reader.

@Kitonum Thank you for catching that. I corrected the code in the original.

The OP's header says Maple 2018. In that case, features like until and embedded assignment are too good for me to not use. If there's any legitimate request, I'll retrofit the code.

@Hyan The parameterization is trivial in this case. Just use Kitonum's Answer with the corrected function.

@Hyan "The function provided" -- I think that there's a mistake in your function, 2*x^2 + 3^2 - x*y - 4, because it's highly unusual for a problem at this level to be stated in a form that can be simplified by trivial arithmetic, 3^2 - 4 = 5. So, would you check that please?

"I know spacecurve is for vector sketching" -- I suppose that you could say that. It depends on how you define "vector", whose mathematical definition allows some flexibility (particularly with respect to whether there's a geometric or algebraic point of view). Certainly, points in space could be (and often are) considered vectors. For me, the key distinctions among the various plotting commands are the number of dimensions of input and output. The command spacecurve is for functions from R^1 to R^3 (R = real numbers), i.e.,1 dimension of input and 3 dimensions of output. So, often a space curve is called a "vector-valued function of a single real variable".

"but f(x,1) and f(1,y) should be polynomials right?" -- Yes, they're polynomials (in one variable), but that is a bit beside the point if your interest is getting the space curves. The (totally abstract) specification of a space curve requires at least two equations in three variables[1]. A more-practical specification, and that which is required by spacecurve, is a parameterization: a list (or vector) of three functions of a single real variable. For example, plotting f(1,y) as a space curve could[2] use the parameterization [1, y, f(1,y)], provided that f has been suitably defined, as it is in Kitonum's Answer below.

[1]The situation of 2 equations in 3 variables is handled by plots:-intersectplot. For example, {z = f(x,y), x = 1} is a set of 2 equations in 3 variables, and it's an abstract specification of the space curve in question as the intersection of two surfaces.

[2]I said "could" because parameterizations are not unique. There are an infinitude of parameterizations possible for any given space curve.

@isifesai You can't assign values to both x and x[i] and use them independently. The two names are intrinsically linked. So, you need to change one of the xs.

You should call or email the Maplesoft Customer Service Department.

Since your situation seems a bit suspicious to me, I won't be surprised if they make you take some extra steps to verify that you are the legitimate owner of the license.

@Kitonum Why is it better to not set global Digits?

@vv Oops, I just made a small change to the example code. Please try it again. If you read the plaintext file, you'll understand why the switch makes a difference. This time, there's definitely a difference between .m and .mpl files.

So, the issue has nothing to do with tables or eval.

@jthress1 Hmm. Over the years, I have occasionally noticed non-idempotency in simplify. That is, one hopes that for any X the following relation is true:

simplify(X) = simplify(simplify(X))

But I have definitely (although rarely) encountered situations where the right side is simpler. This may apply in your situation. These should be considered bugs.

Regarding your attempt at further simplification: subs is not algebraically sophisticated. In order for subs(A= B, C) to work, A must be a distinct entity with its own memory address that C has a link (or links) to. Another way of looking at it: If you think of C as a tree of its subexpressions, then A must be a node (or nodes) in that tree.

You can do some more sophisticated substituting like this:

simplify(X, {n__x*u + n__y*v + n__z*w= lambda});

However, this only works for expressions that are essentially polynomials.

@acer If DF is a DataFrame containing columns C1, ..., Cn, then with(DF) is like C1:= DF[C1]; ...; Cn:= DF[Cn];

@bliengme Plot axes can be any variable that you want. And you can include units in the labels. For example (assuming that Z is a function of t, not of x):

plot(Z, t= -6..2, labels= [time*Unit(hour), Temp*Unit(Fahrenheit)]);

@jthress1 You wrote:

  •  Here is my attempt with your method. Did I input this in incorrectly?

It looks correct to me. Is there something that made you supect that it was wrong?

Here's a systematic way to check such a large expression. The command for searching an expression for subexpressions of a certain type is indets. Square roots are stored internally as expressions raised to fractional powers whose denominators are 2. The command for extracting the denominator of a fraction is denom. So the type spec for a square root is anything^(2 &under denom). So the indets command to check your matrix X is

indets(X, anything^(2 &under denom));

If I do the substitution and call the res ulting matrix X1 and rerun the indets with X1 in place of X, the empty set is returned, indicating that there are no more square roots.

First 305 306 307 308 309 310 311 Last Page 307 of 709