Carl Love

Carl Love

28050 Reputation

25 Badges

12 years, 336 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Kitonum The applyrule method is great. Vote up!

@taro Thank you. I'm sorry that my technique is so complicated. Kitonum's first method is simpler but only works because of a lucky quirk in Maple's internal representation of expressions: The 2 is stored separately from the rest of the exponent. I think that Kitonum's second method, using applyrule, is the best alternative.

@Kitonum I considered trying what you did, but I decided against it because I didn't think that ex was a syntactic subunit of the exponent. Notice that it doesn't appear in indets(e, anything). However, looking at dismantle(e), I can see that it is. It's the PROD(5) on line 5, and it's distinct from the coefficient 2 on line 20.

SUM(5)
   POWER(3)
      NAME(4): g
      SUM(3)
         PROD(5)              #This is ex
            SUM(7)
               NAME(4): sigma
               INTNEG(2): -1
               NAME(4): k
               INTPOS(2): 1
               INTPOS(2): 1
               INTPOS(2): 1
            INTPOS(2): 1
            SUM(5)
               INTNEG(2): -1
               INTPOS(2): 1
               NAME(4): sigma
               INTPOS(2): 1
            INTNEG(2): -1
         INTPOS(2): 2            #This is the coefficient 2
   INTPOS(2): 1
   PROD(3)
      NAME(4): tau
      INTPOS(2): 2
   INTNEG(2): -1

@ Okay, good point. Yes, the semantics of

y[index]:= anything;

differs depending on whether y is a mutable or immutable container. Lists and sets are immutable containers; tables and rtables are mutable containers. It's impossible to change the contents of an immutable container. Any attempt to change the contents results in the creation of a new container with copied and modified contents. The failure to understand this is probably the number-one cause of inefficient Maple code. Maple shouldn't allow the statement above when y is a list, but it does, begrudgingly, and only if y has fewer than 100 elements.

In your most-recent example, it's important to realize that it's not the statement y:= x that causes the list to be copied! It's the statement y[2]:= 3 that makes the copy. This can be verified like this:

restart:
addressof~([x,y]);
     [18446744792117435038, 18446744792117435070]

x:= [1,2,3]:  addressof~([x,y]);
     [18446744792119857038, 18446744792117435070]

y:= x:  addressof~([x,y]);
     [18446744792119857038, 18446744792119857038]  #x and y point to the same object.

y[2]:= 3:  addressof~([x,y]);
     [18446744792119857038, 18446744792119860222]  #x and y point to different objects.

So, regardless of whether x is a Matrix, a list, a name, or just a scalar, the statement y:= x never makes a copy of x; it just makes a new pointer to an existing object. It's behavior is consistent.

What you want to do is very easy with { }, fsolve, and select. But before I show you how to do that, I need to know what you mean by "function value at a root is positive." By the definition of root, the function value at a root is 0.

@MAHMOUDHM Yes, I saw your update. Please make as many changes as you can regarding the advice that you've already received here and, as Acer said, post your update in this thread.

I saw that you made changes regarding my first four points, but that you kept the pi. That was disappointing.

@ Your first sentence got cut off because of the stringent length restriction of the titles of Replies.

Anyway, yes, okay, there's a difference when the left operand of := is subscripted, which I mentioned with my y[..]:= example. Subscripting the left operand doesn't really apply with scalars. Okay, you're substituting concatenation for subscripting; I see the analogy, but I think that it's stretched thin: x[1] and x[2] are two objects in the same container, whereas x1 and x2 are separate containers.

Does it seem to you that Maple is different from any other programming language in this regard? It's been a long time since I've used another language extensively.

@hillbilly True zooming can be done with the viewpoint option to plot3d, and any 2d plot can be done in plot3d. See this Question: http://www.mapleprimes.com/questions/201992-Zoom-Animation-With-Time

@Vic For each of the three systems that you've posted, I get equivalent results from all three methods (msolve, Linsolve, and LinearAlgebra:-Modular-LinearSolve) as shown in the worksheet that I've posted below. If you think that you're getting different results, please post a worksheet showing that. You can use my worksheet as a model for the correct usage of the three solution methods.

restart:

macro(LA = LinearAlgebra, LAM = LinearAlgebra:-Modular):

systems:= {
     0 = f[[1, 5]]-f[[1, 3]], 0 = f[[1, 6]]-f[[1, 4]], 0 = f[[2, 4]]-f[[1, 4]], 0 = f[[2, 5]]-f[[1, 3]],
     0 = f[[2, 6]]-f[[1, 3]], 0 = f[[2, 6]]-f[[1, 5]], 0 = f[[2, 6]]-f[[2, 5]], 0 = f[[2, 7]]-f[[1, 4]],
     0 = f[[2, 7]]-f[[1, 6]], 0 = f[[2, 7]]-f[[2, 4]], 0 = f[[3, 1]]-f[[1, 5]], 0 = f[[3, 1]]-f[[2, 5]],
     0 = f[[3, 1]]-f[[2, 6]], 0 = f[[3, 1]]-f[[3, 7]], 0 = f[[3, 5]]-f[[1, 4]], 0 = f[[3, 5]]-f[[2, 4]],
     0 = f[[3, 6]]-f[[1, 5]], 0 = f[[3, 6]]-f[[2, 5]], 0 = f[[3, 7]]-f[[1, 3]], 0 = f[[3, 7]]-f[[1, 5]],
     0 = f[[3, 7]]-f[[2, 5]], 0 = f[[3, 7]]-f[[2, 6]], 0 = f[[4, 1]]-f[[1, 6]], 0 = f[[4, 1]]-f[[2, 4]],
     0 = f[[4, 1]]-f[[2, 7]], 0 = f[[4, 1]]-f[[3, 5]], 0 = f[[4, 1]]-f[[4, 6]], 0 = f[[4, 2]]-f[[2, 7]],
     0 = f[[4, 2]]-f[[3, 5]], 0 = f[[4, 2]]-f[[4, 6]], 0 = f[[4, 2]]-f[[4, 7]], 0 = f[[4, 6]]-f[[1, 4]],
     0 = f[[4, 6]]-f[[2, 4]], 0 = f[[4, 6]]-f[[3, 5]], 0 = f[[4, 7]]-f[[1, 6]], 0 = f[[4, 7]]-f[[2, 4]],
     0 = f[[4, 7]]-f[[2, 7]], 0 = f[[4, 7]]-f[[3, 5]], 0 = f[[4, 7]]-f[[4, 6]], 0 = f[[5, 1]]-f[[2, 6]],
     0 = f[[5, 1]]-f[[3, 6]], 0 = f[[5, 1]]-f[[3, 7]], 0 = f[[5, 1]]-f[[5, 7]], 0 = f[[5, 2]]-f[[2, 6]],
     0 = f[[5, 2]]-f[[3, 6]], 0 = f[[5, 2]]-f[[3, 7]], 0 = f[[5, 3]]-f[[4, 6]], 0 = f[[5, 3]]-f[[4, 7]],
     0 = f[[5, 7]]-f[[1, 5]], 0 = f[[5, 7]]-f[[2, 6]], 0 = f[[5, 7]]-f[[3, 6]], 0 = f[[5, 7]]-f[[3, 7]],
     0 = f[[6, 1]]-f[[2, 7]], 0 = f[[6, 1]]-f[[4, 7]], 0 = f[[6, 2]]-f[[3, 7]], 0 = f[[6, 2]]-f[[5, 7]],
     0 = f[[6, 3]]-f[[5, 7]], 0 = f[[6, 4]]-f[[4, 7]], 0 = f[[7, 2]]-f[[4, 7]], 0 = f[[7, 3]]-f[[5, 7]],
     1 = f[[1, 5]]-f[[1, 4]], 1 = f[[1, 6]]-f[[1, 3]], 1 = f[[1, 6]]-f[[1, 5]], 1 = f[[2, 4]]-f[[1, 3]],
     1 = f[[2, 5]]-f[[1, 4]], 1 = f[[2, 5]]-f[[2, 4]], 1 = f[[2, 6]]-f[[1, 4]], 1 = f[[2, 6]]-f[[1, 6]],
     1 = f[[2, 6]]-f[[2, 4]], 1 = f[[2, 7]]-f[[1, 3]], 1 = f[[2, 7]]-f[[1, 5]], 1 = f[[2, 7]]-f[[2, 5]],
     1 = f[[2, 7]]-f[[2, 6]], 1 = f[[3, 1]]-f[[1, 6]], 1 = f[[3, 1]]-f[[2, 4]], 1 = f[[3, 1]]-f[[2, 7]],
     1 = f[[3, 1]]-f[[3, 5]], 1 = f[[3, 5]]-f[[1, 3]], 1 = f[[3, 5]]-f[[2, 5]], 1 = f[[3, 6]]-f[[1, 4]],
     1 = f[[3, 6]]-f[[2, 4]], 1 = f[[3, 6]]-f[[3, 5]], 1 = f[[3, 7]]-f[[1, 4]], 1 = f[[3, 7]]-f[[1, 6]],
     1 = f[[3, 7]]-f[[2, 4]], 1 = f[[3, 7]]-f[[2, 7]], 1 = f[[4, 1]]-f[[1, 5]], 1 = f[[4, 1]]-f[[2, 5]],
     1 = f[[4, 1]]-f[[2, 6]], 1 = f[[4, 1]]-f[[3, 6]], 1 = f[[4, 1]]-f[[3, 7]], 1 = f[[4, 2]]-f[[2, 5]],
     1 = f[[4, 2]]-f[[2, 6]], 1 = f[[4, 2]]-f[[3, 6]], 1 = f[[4, 2]]-f[[3, 7]], 1 = f[[4, 6]]-f[[1, 5]],
     1 = f[[4, 6]]-f[[2, 5]], 1 = f[[4, 6]]-f[[3, 6]], 1 = f[[4, 7]]-f[[1, 5]], 1 = f[[4, 7]]-f[[2, 5]],
     1 = f[[4, 7]]-f[[2, 6]], 1 = f[[4, 7]]-f[[3, 6]], 1 = f[[4, 7]]-f[[3, 7]], 1 = f[[5, 1]]-f[[1, 6]],
     1 = f[[5, 1]]-f[[2, 7]], 1 = f[[5, 1]]-f[[4, 6]], 1 = f[[5, 1]]-f[[4, 7]], 1 = f[[5, 2]]-f[[2, 7]],
     1 = f[[5, 2]]-f[[3, 5]], 1 = f[[5, 2]]-f[[4, 6]], 1 = f[[5, 2]]-f[[4, 7]], 1 = f[[5, 3]]-f[[3, 6]],
     1 = f[[5, 3]]-f[[5, 7]], 1 = f[[5, 7]]-f[[1, 6]], 1 = f[[5, 7]]-f[[2, 7]], 1 = f[[5, 7]]-f[[3, 5]],
     1 = f[[5, 7]]-f[[4, 6]], 1 = f[[6, 1]]-f[[2, 6]], 1 = f[[6, 1]]-f[[3, 7]], 1 = f[[6, 1]]-f[[5, 7]],
     1 = f[[6, 2]]-f[[2, 7]], 1 = f[[6, 2]]-f[[4, 7]], 1 = f[[6, 3]]-f[[4, 6]], 1 = f[[6, 3]]-f[[4, 7]],
     1 = f[[6, 4]]-f[[5, 7]], 1 = f[[7, 2]]-f[[3, 7]], 1 = f[[7, 2]]-f[[5, 7]], 1 = f[[7, 3]]-f[[4, 7]]
}:
vars:= [indets(systems, name)[]]:
Ab:= LA:-GenerateMatrix(systems, vars, augmented):


SolLAM:= [LAM:-LinearSolve(2, LAM:-Mod(2, Ab, integer[]), 1, inplace= false)]^~%T;

SolLAM := [Vector[row](26, {(1) = 0, (2) = 1, (3) = 0, (4) = 1, (5) = 1, (6) = 0, (7) = 0, (8) = 1, (9) = 0, (10) = 1, (11) = 0, (12) = 0, (13) = 1, (14) = 1, (15) = 1, (16) = 1, (17) = 0, (18) = 0, (19) = 1, (20) = 0, (21) = 1, (22) = 0, (23) = 0, (24) = 1, (25) = 1, (26) = 0}, datatype = integer[8], order = C_order), Vector[row](26, {(1) = 1, (2) = 1, (3) = 1, (4) = 1, (5) = 1, (6) = 1, (7) = 1, (8) = 1, (9) = 1, (10) = 1, (11) = 1, (12) = 1, (13) = 1, (14) = 1, (15) = 1, (16) = 1, (17) = 1, (18) = 1, (19) = 1, (20) = 1, (21) = 1, (22) = 1, (23) = 1, (24) = 1, (25) = 1, (26) = 1}, datatype = integer[8], order = C_order)]

Sol1:= (Linsolve(Ab[..,..-2], Ab[..,-1], 'r') mod 2)^+;

Sol1 := Vector[row](26, {(1) = _t[26], (2) = 1+_t[26], (3) = _t[26], (4) = 1+_t[26], (5) = 1+_t[26], (6) = _t[26], (7) = _t[26], (8) = 1+_t[26], (9) = _t[26], (10) = 1+_t[26], (11) = _t[26], (12) = _t[26], (13) = 1+_t[26], (14) = 1+_t[26], (15) = 1+_t[26], (16) = 1+_t[26], (17) = _t[26], (18) = _t[26], (19) = 1+_t[26], (20) = _t[26], (21) = 1+_t[26], (22) = _t[26], (23) = _t[26], (24) = 1+_t[26], (25) = 1+_t[26], (26) = _t[26]})

Sol2:= SolLAM[1] + indets(Sol1,name)[]*SolLAM[2];

Sol2 := Vector[row](26, {(1) = _t[26], (2) = 1+_t[26], (3) = _t[26], (4) = 1+_t[26], (5) = 1+_t[26], (6) = _t[26], (7) = _t[26], (8) = 1+_t[26], (9) = _t[26], (10) = 1+_t[26], (11) = _t[26], (12) = _t[26], (13) = 1+_t[26], (14) = 1+_t[26], (15) = 1+_t[26], (16) = 1+_t[26], (17) = _t[26], (18) = _t[26], (19) = 1+_t[26], (20) = _t[26], (21) = 1+_t[26], (22) = _t[26], (23) = _t[26], (24) = 1+_t[26], (25) = 1+_t[26], (26) = _t[26]}, order = C_order)

MSol:= msolve(systems, 2);

{f[[1, 3]] = _Z1, f[[1, 4]] = 1+_Z1, f[[1, 5]] = _Z1, f[[1, 6]] = 1+_Z1, f[[2, 4]] = 1+_Z1, f[[2, 5]] = _Z1, f[[2, 6]] = _Z1, f[[2, 7]] = 1+_Z1, f[[3, 1]] = _Z1, f[[3, 5]] = 1+_Z1, f[[3, 6]] = _Z1, f[[3, 7]] = _Z1, f[[4, 1]] = 1+_Z1, f[[4, 2]] = 1+_Z1, f[[4, 6]] = 1+_Z1, f[[4, 7]] = 1+_Z1, f[[5, 1]] = _Z1, f[[5, 2]] = _Z1, f[[5, 3]] = 1+_Z1, f[[5, 7]] = _Z1, f[[6, 1]] = 1+_Z1, f[[6, 2]] = _Z1, f[[6, 3]] = _Z1, f[[6, 4]] = 1+_Z1, f[[7, 2]] = 1+_Z1, f[[7, 3]] = _Z1}

Sol3:= eval(<eval(vars, MSol)>^+, indets(MSol, suffixed(_Z))=~ indets(Sol1, name));

Sol3 := Vector[row](26, {(1) = _t[26], (2) = 1+_t[26], (3) = _t[26], (4) = 1+_t[26], (5) = 1+_t[26], (6) = _t[26], (7) = _t[26], (8) = 1+_t[26], (9) = _t[26], (10) = 1+_t[26], (11) = _t[26], (12) = _t[26], (13) = 1+_t[26], (14) = 1+_t[26], (15) = 1+_t[26], (16) = 1+_t[26], (17) = _t[26], (18) = _t[26], (19) = 1+_t[26], (20) = _t[26], (21) = 1+_t[26], (22) = _t[26], (23) = _t[26], (24) = 1+_t[26], (25) = 1+_t[26], (26) = _t[26]})

LA:-Equal(Sol1,Sol2);

true

LA:-Equal(Sol1,Sol3);

true

 


Download mod2_sys.mw

@ I don't see any inconsistency. You can do the same thing with Matrices:

x:= <2>:  y:= x:  y:= <3>:  x;

and x will still be <2>. Compare with

x:= <2>:  y:= x:  y[..]:= <3>:  x;

Now x will be <3>.

@Vic What did you do to confirm that this system has a solution? For me, neither msolve nor Linsolve return a solution.

There is no way to send the evaluation procedures to Excel, which couldn't interpret the Maple code anyway. But if you want to send four lists or vectors of y values to Excel, that can be done. In that case, I need to know the ending value of t and the step value of t.

Dr. Subramanian: Your comment makes absolutely no sense to me unless I suppose that you meant to say 2D input rather than 1D input.

@artfin To avoid extra-space errors (and for many other reasons), use 1D input (aka Maple Input). In 1D input, f(x) and f (x) mean exactly the same thing; in 2D input, f(x) means function application and f (x) means multiplication.

This is how I found the error. In the error message that you posted, I can see a "naked" sin. By naked, I mean that it has no argument. To find which equation has the naked sin, do

for k to 8 do indets(eq[k], name) end do:

(The only return from these commands should be {t}.) This shows that there's a naked sin in eq[5]. So I look at f5. I know that naked function errors are often caused by extra spaces in 2D input. So I look (just by eye) for an extra space after a sin in f5.

@max125 

root[8](x) is identical to x^(1/8). Since your problem says x^(1/8), why didn't you just use that?

First 393 394 395 396 397 398 399 Last Page 395 of 709