Stretto

145 Reputation

5 Badges

1 years, 69 days

MaplePrimes Activity


These are replies submitted by Stretto

@Kitonum 

 

That may work but really isn't ideal. Lot's of extra code to do something simple.

Can an operator be used to suppress such a statement?

 

_!(A := x)

 

and _! will supress the output but everything else would work?

 

Or maybe

_!(A,x);

 

makes the assignment quietly.

 

I mean, all this is because maple desides to ignore colons inside blocks.

 

 

 

@Carl Love 

 

Changing printlevel does nothign to solve the problem. I need to be able to print out statements in EXACTLY the same why I am able to do it outside of loops. Why it is different is assinine. Why are colons not suppressing statements inside the loop? What is the justification? Why would maplesoft take a perfectly fine syntax that is very simple (: vs ;) and then break it inside of a loop?

 

printlevel:= 1;
(for i from 1 to 3 do
   i+4;
   i*3;
end);

 

@vv Doesn't work

That prints only the last statement. I need all statements printed EXCEPT the once I use a colon on... NO different than what is normally done. Why for loops change that behavior is beyond me. Changing print level does nothing to fix this issue.

 

printlevel:= 1;
(for i from 1 to 3 do
   i+4;
   i*3;
end);

 

@vv 

 

and so I'm left with the same issues...

@Kitonum 

 

And so what happens if I have a hundred statements? I have to write print out every time just to suppress one or two statements?

@Mac Dude 

thanks.

@acer 

 

Thanks, it seemed to be the interface setting.

"Now let's set the typesetting level to extended (its default in Maple 2019). "

 

I never recalled changing that setting... although it is possible I suppose. In any case I set it in the start file so it shouldn't be a problem.

@Carl Love 

You never asked that:

 

Standard Worksheet Interface, Maple 2019.1, Windows 10, May 21

   2019 Build ID 1399874
                               3
                            standard

 

You said "To answer properly, I need to know exactly how the output of the things that you show appears on the screen. The copy-and-paste mangles it. "

 

Again you said "@Stretto You're right, it's no different. To answer properly, I need to see exactly how it displays on your screen. Can you post an executed worksheet? "

 

Not once anywere did you ever mention anything about getting those interface settings. vv was the one that mentioned them and he said nothing about it.

 

You are very confused.

 

You say you said things and then say you didn't say things and maybe that is the problem?

 

I'm going to quote your responses direclty by copying and pasting them here:

 

 

If you put immediately before an operator, it makes it inert. So, you can do a %/ b * c, and it'll display like you want. The inertness will remain inert until you use the value command.

Unfortunately, you do need to use some special syntax to get things to display as you want.

If an appears in the first column of input, it's a shell escape, equivalent to a system command. See ?system.

 

@Stretto Unfortunately, the operators do not have the same precedence as their regular counterparts. I'll admit that this is bad design on Maple's part. So, you need to use parentheses to clarify:

(3^3) %/ 3

This is different from (3^3)(%/3). This latter expression is probably something that you'd never actually want. And I'll explain what it does, if you'd care to know.

To answer properly, I need to know exactly how the output of the things that you show appears on the screen. The copy-and-paste mangles it.

@Stretto You're right, it's no different. To answer properly, I need to see exactly how it displays on your screen. Can you post an executed worksheet?

If you're using the command-line interface, I don't think that it's going to be possible to get the display that you want.

If you want it to simplify to 9, just use the regular operators, not the inert ones.

@Stretto I understand (and did understand) exactly what you want; no further explanation of that is necessary; I don't need to see (nor did I ask to see) a worksheet of your original problematic output; I know that it puts under c. In order to help you properly, I need to see the output of

interface(version); interface(prettyprint); interface(typesetting);

You make it exasperating for us to help you, and exasperating for yourself, by going off on tangents, such as what happens for expressions with exponents.

 

 

You are making no sense. Nothingn follows from your posts. First you tell me that all I have to use is % in front of the operator.. I do that, it doesn't work. Then you tell me that I need to use parenthesis to "clarify" and then quote something I typed in previous exactly that and the output which clearly shows it does not work. Then you tell me you need to see exactly the output of the worksheet and I give you the "exact output"(visually) by copying and pasting it and then using maple primes buit in "maple" math. You then tell me that that you never asked for a worksheet...

 

None of it makes any sense to me. You are making claims that make no sense and say I'm making it harder. My original post is quite clear. You responded with somethign that was quite clear, it didn't work though. I said it didn't work, you said I needed to do something different but I did what you said already and it was in my response. You then say you need to see exactly what I'm doing and things just go from bad to worse.

 

What I'm asking for is not complicated and I'd expect these things to be quite simple... it is apprarently not.

@Carl Love 

 

Thanks, that is quite interesting!

@Carl Love 

 

I simply do not want maple to rewrite part of the expression and it is.  Maple is reordering the operations. They are abstract so there is no computaton involved. The reordering complicates things

In the latex notation I gave expresses exactly what maple is doing and I do not want that because it is visually ugly.

 

a/b*c;
                              a c
                              ---
                               b

 

That is what maple is doing. That is the worksheet. I do not want that! I want:

 

                              a
                              ---*c
                               b

 

I am copying and pasting the output. It of course exapnds it for ASCII but they are the same. The point is not the specific output notation but that it is writing b under c. Since c is a complex expression and b is not, it causes a about 40% of the room that could be used to display c to be used up for absolutely no purpose. Ok. it really doesn't squash anything but it takes up extra room to write that fraction. I could just cut off the a/b part and get what I want but then it woul be missing the leading coefficient of a/b.

This should be very easy for maple to handle, it just has to not rewrite the operations.

a/b*c

I used maple math and typed in a/b*c and the above is the output, and that is how it looks in my maple. I do not want that. Here is using %:

You have entered an invalid Maple expression

 

So if % is working for you then it is probably something on your end that makes it work. It doens't seem to be part of standard maple.

 

a/b`*`c should be interpreted as something like what I want, where the multiplication if not rewriten. Of course this doesn't work. I still want a/b and c to be treated as normal expressions.

Your idea of %* is the same... but that too doesnt' work.

 

The examples I gave with real numbers were just examples.I simply do not want maple to rewrite the multiplication by reordering the division a/b*c = a*c/b = (a*c)/b. They are all the same mathematically and maple displays them all the exact same way, yet there are three 3 ways to display them(in fact, an infinite. We could have a/(b/c), 1/(b/(a/c)), etc).

 

In latex it is the difference between something like

 

\frac{1}{2} \sum k^2

 

and

 

\frac{\sum k^2}{2}

 

The first case is far better because we end up with a very visually unappealing expression in the second. It is not balanced. We have a single 2 underneath the entire sum. It doesn't look good at all, yet that is what maple is doing for no apparent good reason.

 

 

 

 

 

@Carl Love 

 

I don't see how this is any different than the one I showed. It doesn't work.

 

(3^3)%/3;
                           %/(27, 3)

 

It does compute 3^3 but it is not returning in a nice format 27/3 but a binary operator. Also, I would like it to simplify so in this case it should actually just return 9(not a big deal though for my use cases).

 

@Carl Love 

 

Thanks.

 

Unfortunately when I do it though it doesn't work:

 

3^3%/3;
                            %/(3, 3)
                           3        

(3^3)%/3;
                           %/(27, 3)

 

(3^3)(%/o);
                               27

 

(3^b)(%/o);
                             /  /27\\
                             | b|--||
                             |  \o /|
                             |3     |
                            b|------|
                             \  o   /
                           3         


b and o are undefined.

@Carl Love 

Thanks. Well, In my mind things that are not defined are not defined and meaningless. x has no meaning until it is defined. For maple to assume it is a polynomial is confusing to me.

You seem to be implying that anything not assigned is treated as a polynomial but that is an arbitrary semantic by maple and it is confusing because of that. Of course, if one learns that and it is reinforced then it is not a big deal.

But typical computer programming languages are very well adapted to programmers needs. There are issues in programmiung and one of the most fundamental is to avoid errors.

Regardless of how maple works, certain semantics are invalid. When an implicit assumption is made it is generally an error in anything, be it pure logic, math, computer programming, or symbolic programming. The problem is that in complex programs it can be very difficult to track down these invalid assumptions.

In a blank worksheet, gcd(a,b) = 1

you say this is normal behavior because a and b are polynomials. To me that just does not make sense.

is a the independent variable or is it a constant of the polynomial? Same for b of course... also what if a = b? then is the gcd still 1?

If maple is making the assumptions that they are polynomials then why not also assume that a = b and just return gcd(a,b) = a? or gcd(a,b) = sgn(a*b)*sqrt(a*b)

It seems quite arbitrary what maple is doing in my mind. It may or may not be(I'm not saying I'm absolute right) but something doesn't jive. I realize one can just accept the behavior as correct but I'm generally not one of those people(although I do realize it is pointless at this point to try to change the behavior.. although ideally I would like to redefine it for my purposes but still use the same names).

It just makes no sense to me how anyone can reason that gcd(a,b) = 1... even in the mathematical sense. It simply is not true in general for any a and b whatever a and b could be. And since we don't know what a and b are how can we get a result? Ok, I know that maple says that they are a polynomial... but that still isn't enough. It's not true for all polynomials a and b.

You say: "An unassigned x is not an integer." " Integers are polynomials." " As I said in the other thread, if a and b are not defined, then they're explicitly polynomials"

But these are contradictory statements. If a is not defined then it is an explicit polynomial... integers are polynomials. An unsigned/undefined a is not an integer.

It seems that you have the hidden assumptions that if a symbolic variable is not defined then it is explicitly a polynomial that is not an integer AND it is never the same as any other symbolic variable of a different name.

With those assumptions then I can see why gcd(a,b) = 1. Without them I cannot.

This is suppose to be math too, so I'm quite supprised that a program built around mathematics would go against the grain of what mathematics is all about.

If I were to ask you "Compute the square of x" you would look at me and say "ERROR ERROR! CANNOT COMPUTE!". You would want to know what x is or at least it's type. You would need to know more information. You wouldn't just return an arbitrary value or make up a result. The square of x depends entirely on what x is and what exactly it means to square it. It's true that we generally assume that x exists in an algebraic structure where we could square it(else why make the statement) but that still isn't enough to do anything. At best we can just return the same statement in a different form such as "It is x^2". In fact, depending on what x is, some values it could take on are squareable and some might not.

I prefer and am predisposed to not have these hidden assumptions.

So, correct me if I'm wrong, but if the following is true then things make more sense:

Maple assumes any symbolic variable that is not explicitly defined to be of a polynomial type on that symbolic variable and not equal to any other symbolic variable of a different name in any way. [gcd(a,b) = 1 means that a and b have no common divisors so it is more than just assuming that a != b in the polynomial/integer ring... it's a very strong assumption and I would be much more conformtable with maple just telling me it can't compute the gcd beause it doesn't have enough information]

I realize this assumption may be stated explicitly somewhere in some document and my only gripe is that this seems, IMO, like a rather arbitrary assumption although I realize it might not be completely arbitrary.

If that is true, then what other assumptions does maple make so I can be less confused? There seems to be a few of these strange things, to me, that maple does and it is totally counter-intuitive. Again, I come from a background of C/C++/C#/D/JS/Python/Lua/etc.  Each language usually has it's quirks but the only CAS I use is maple and I only do it for certain things. It's generally far to slow to be of use except for testing ideas out. In maple I routinly use up 16GB of memory in calculations or hae calculations that take 10's of minutes where I can do the same in C++ that take a small fraction of the space and time. I would like to use maple for more indepth stuff but I've never had the need to really learn it in all it's glory(specially given how slow it generally is for many things).

@Carl Love 

 

Thanks. Interesting to see some of the more advanced ideas.

@acer 

 

Thanks... The problem is my ignorance in understanding maple. I can do basically what I want to do but generally for "complicated" stuff is not satisfactory.

There is something bizzaire about how maple does things that just does not jive with my experiences in using programming languages. My expectations always deceive me in maple in certain situations. I'm used to common programming languages like C and it's pretty straight foward.

 

f := x->...

 

is what I see as a "lambda function". A sort of short hand to define a function. The lhs is just the independent variables and the rhs is what to do with them. This notation is used in some programming languages or some variant. Of course function usage is same generally: f(3), f(n), f(x), etc...

 

The issue is that in some cases there are issues. For example, I can pass f to a proc and it seems to pass in the entire function as sort of object with the independent variable and such... but then other circumstances f is not the same as f(x) and when passed in in to some proc/function it sees it as something different.

One of the problems I was that when I was iterating it was working fine except if I had a depth of 0... i.e., no iteration.. .and then the result was different. It's all hard to explain because this stuff creeps up when I'm trying to solve a problem and it doesn't work out. Then I spend several minutes trying to hack it so I can continue to move along. For example, I tried @@ but it didn't work:

 

C := n->n^2:
C@@(3)(5);
                            @@(C, 3)

 

So I moved on. Using loops to iterate... then put it in a proc to make it more general, etc... to make it more general I'd like to use an arbitrary function(before I was using a global function which works fine). Then things don't quite work, for example:

 

Iter := proc(f, n)

end:

 

The idea is Iter should take an arbitrary function(univariate is fine but sometimes I define a function to have parameters and I still want it to work withe parameters. (One thing maple doesn't seem to have is default values which kinda sucks)

 

Iter := proc(f,n)

    local g, i;
    g := f;    #  We can't use f to iterate on. g should be a "copy" of f.
    for i from 1 to n do

        g := f(g):
    end:
end:

 

but g(f) doesn't make sense. We have to have a value. I could extend Iter but I'd rather use functional/composition like syntax.

 

the above Iter returns

 

Iter(C,3);                               
                               C^8

So clearly C is being treated as a constant.

but

 

Iter := proc(f,n)
    print(f);
    local g, i;
    g := f;    #  We can't use f to iterate on. g should be a "copy" of f.
    for i from 1 to n do
        g := f(g):
    end:
end:

Iter(C,3);
        n->n^2
         C^8

 

So C is being passed as a function but somehow it turns in to an unassigned variable. I guess that is due to g := f;

 

so then I say g := x->f(x);

 

 

Iter := proc(f,n)
    local g, i;
    g := x->f(x);    #  We can't use f to iterate on. g should be a "copy" of f.
    for i from 1 to n do
        g := f(g):
    end:
end:

Iter(C,3);                               
                               g^8

 

which is invalid...

 

so I change to g := f(x);

 

and I get x^16 which is "correct"(well, it's iterated one to much).

 

Iter := proc(f,n)
    local g, i;
    g := f(x);    #  We can't use f to iterate on. g should be a "copy" of f.
    for i from 1 to n do
        g := f(g):
    end:
    g;
end:

So that seems to work. But the g := f(x) is strange is that is the evaluation of f at x. Also it creates a dependency on the name x and also on f being univariate. So it is not as general as I want.

 

I want to simplify the iteration process so it works in general when ever I need it. If I create a new function with several parameters, I don't want to change any of the syntax:

 

C := (n,a,b)->n^a + b;

Iter(C,5);

 

And it will iterate over the first independent but the others are still parameters. In fact, as parameters, I might want to index them.

 

I.e., C(C(n,a1,b1),a2,b2), etc...

 

I don't want to have to treat everyone as a special case. Ideally to have defaults for the most used case and then be able to modify it for more specific cases with the least amount of work. I.e., if I have parameters to be able to specify indexing them, and also to specify the independent variable that is used in the interation which is usually the first(so it defaults to it).

 

Whatever is returned by Iter should be as if I were to define it manually by hand else it does not accomplish it's purpose.

What you've given may work fine:

 

K:=proc(F,X,L2,n)
     foldl(L->F(L,op(_rest)),X,L2$n);
end proc:

for k from 0 to 3 do
    K(f, a, [b,c], k);
end do;

except it doesn't seem to index the parameter list with the interation count.

 

It seems that maple may have default vaules {a := b} makes a default to b... so maybe I can get what I want.

Best I can tell, your code does what I want except it doesn't capture the ability to add depth indexing to the other parameters and doens't default to the case of not doing that. That probably seems relatively easy enough by modifying the L2$n part and using the {a:=b} stuff...

I'll have to play around with it and see...

 

Thanks!

 

 

 

 

1 2 3 4 5 6 Page 3 of 6