Stretto

255 Reputation

5 Badges

5 years, 261 days

MaplePrimes Activity


These are replies submitted by Stretto

@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!

 

 

 

 

@Carl Love 

 

This is the problem:

 

Maple has defines the most common command to be something different and then returns meaningless results. You say that gcd and mod are for polynomials and that for integers, the most common case, we have to prefix i... That is ass-backwards.

 

gcd and mod should be for integer(of which mod can be generalized to real w.l.o.g.) and pgcd and pmod should then be used for polynomials...

 

One doesn't make the most common cause use the most uncommon syntax. In all number theory books they will define gcd and mod for integers, not polynomials... not until after the fact.

 

Also, the definition for the gcd and mod of polynomials extends that over integers, so maple is crapping out and producing invalid results when it is clear that this is an issue with maples design... not mine.

 

For example, suppose one day that the government decides to redefine red = go and green = stop... and then gives everyone a ticket and blames them for all the crashes.. Is this logical? Why should have have to learn to jump through hoops just because maple got it wrong?

 

More importantly, if the inputs in to these functions are not defined then how the hell can it make any decisions about anything?

No one has explained to me why gcd(a,b) returns 1 when a and b are not defined! It is immaterial if gcd only accepts polynomials. This would be a programming bug in any normal programming language. It's not correct behavior. The goal of any programming language(including maple) is not to make life for the programmer hell by having obscure side conditions that can be difficult to detect.

 

How many people do you think that come to maple for the first time and are fully familiar with mod outside of maple will know that it is meant for polynomials? Ok, fine, they will learn that it is for polynomials... but that doesn't then explain why gcd(a,b) = 1 when a and b are undefined.

 

This is like defining sin(x)/x = 432 when x = 0. It is illogical and counterproductive.

 

Maple is wrong in this case. Ideally it would be fixed. The fact that mod does work for explicit integers FURTHERS the problem because now mod is overload to work for integers in some cases and not others, but you tell me it only works for polynomials? What precisely is a polynomial to maple? is 3 not a polynomial? is q a polynomial?

These behaviors are wrong. Sure one can work around them, but the mere fact that one has to do so is why they are wrong.

 

I'm not talking about what maple does, it does what it does, I'm talking about what is logically correct... and in most cases what is logically correct is determined by precedence. If I open up the top 50 programming languages they all use mod in the exact same way and there is no problem. Maple chose to behave different for an arbitrary purpose that seems to only produce extra hoops. The main issue is that it silently gives invalid results rather than an error. That is unacceptable. How hard is it for maple to check if the arugments exist?

 

 

 

 

@acer 

 

That works but not what I'm looking for. I do not want to emulate the modulo function. I want to know why it doesn't work in general?

 

fmod doesn't work outside the plot

 

f := n->n*(fmod(n, 4));
f(2);
                          2 fmod(2, 4)

I don't understand why these functions just don't behave in the obvious way. It's really bizzare to me that I have so much trouble with certain functionality in maple. If I do x mod 3 I expect x to be modded by 3 regardless if it is a variable an integer or a real.

 

I know I can define the the function but why isn't maple's mod function defined for these most common cases in the first place when used with variables such as in functions? It seems that maple really loves to try to compute something before it should be and return an invalid result.

 

plot( x mod 3,x=-5..5);

 

It should work, why doesn't it? Is it because maple tries to compute x mod 3 and says "Oh, x is a variable, so let's just return x instead"? Or what?

 

The reason why this is a problem is because in virtually every other CAS and in most programming languages, they work logically and evaluate expressions as they are composed without and strange "logic" that produces invalid results. If I never know what the heck is going on I'll keep forgetting and wasting my time.

 

 

 

@Carl Love 

 

That seems wrong behavior: " If c is any common divisor of p and q, then c divides their GCD. "

where p and q are polynomials. a and b are polynomials... constant polynomials or unknown polynomials.

a and b are not defined anywhere, so how could it even know if there is a common factor or not? They could be polynomials with common factors or not. Usually when maple cannot unambiguously do something it just returns the expression.

 

Can you explain to me why maple thinks a and be have no divisors? [Remember, they are not defined anywhere so I'm having a hard time figuring out how it can make any decision about them]

 

@vv I'm not sure if this is what I want. This seems to be to set the rotation angle by code. I am stricktly talking about interating with the plot using the mouse. It seems to depend the position of the mouse... which is not what I want. This makes it very hard to control. It just simply be rotated relative to the mouse. Of course, we only have 2D so I guess this is why they use the height, but it's very hard to control.

@Christian Wolinski 

 

Thanks... is there any way to set it black? I don't understanding the coloring. I have set and xyz scheme but I can't get black. Is there any way to color based on x y and z for black? (then I could just set z = 0 to be RGB(0,0,0))

 

 

@acer 

Thanks.

@acer Thanks, 2nd case.

@Christian Wolinski 

 

The case I gave above was just an example. I need a general understanding of what maple is doing... why it is creating 2x(x)(x).

@acer 

 

and I remember that, but since I'm not dealing with a polynomnial I figured it wouldn't work... Why would it? If someone told me to pick up that apple and pointed to a bannana why would I think that makes sense?

It makes sense to have something like convert(f, removeBigO)?

@Thomas Richard 

 

The problem seems that when you highlight a word such as double clicking on it the F2 opens up the wrong info. Without highlighting it seems to work.

 

Also, it seems that F1 nor F2 work in a code edit region!

3 4 5 6 7 Page 5 of 7