Dryan

10 Reputation

6 Badges

10 years, 307 days

MaplePrimes Activity


These are replies submitted by Dryan

@Joe Riel 

Thank you very much for your short introduction. It definitely helped me along a bit. All the same I still have some issues with that.

First, an interpretation question on the lines

if andmap( l -> l[2] :: (identical(q) = anything), L) then

            L := map(l -> [l[1],op([2,2],l)], L);

I´m pretty sure I know what is done by the first given line, but I don´t know on what way this is done. Mainly I can´t figure out what "l -> l[2]" does and what is actually meant by l as you didn´t define it. It is only set as a local variable for this procedure (as I see it).

In the second line I´m not sure what is done there!? And what is meant by l[2] here as you used l[1] before?

Then, another issue, but I think it will be answered along with an explanation to the lines mentioned: how do you tell Maple how often to check whether all "q"´s are identical? What I mean is, on what way does Maple figure out in how many pieces this pw is split up into and then check the q for exactly this amount? I couldn´t find how this is done anywhere.

And last my main issue, as I could just ignore the other issues and c/p your suggestion without real comprehension of what is done in each step. But in this case I couldn´t do that anyway. The way you set up the procedure doesn´t work with the piecewise function as I have them in my problem.

The way you defined the pw is: 

piecewise(x < 1,q[O] = x,q[O] = x^2)

whereas I have them in a form like:

piecewise(x < 1,q[O] = x, [])

And of course the "otherwise" part of the function is not an equation. That way the procedure can´t solve the way you suggested. Is there a way around this problem? For example by somehow omitting the check for the "otherwise" part of the piecewise?

 

Thanks again for your great help, I really appreciate it.

Dryan

@Joe Riel 

Thank you very much for your short introduction. It definitely helped me along a bit. All the same I still have some issues with that.

First, an interpretation question on the lines

if andmap( l -> l[2] :: (identical(q) = anything), L) then

            L := map(l -> [l[1],op([2,2],l)], L);

I´m pretty sure I know what is done by the first given line, but I don´t know on what way this is done. Mainly I can´t figure out what "l -> l[2]" does and what is actually meant by l as you didn´t define it. It is only set as a local variable for this procedure (as I see it).

In the second line I´m not sure what is done there!? And what is meant by l[2] here as you used l[1] before?

Then, another issue, but I think it will be answered along with an explanation to the lines mentioned: how do you tell Maple how often to check whether all "q"´s are identical? What I mean is, on what way does Maple figure out in how many pieces this pw is split up into and then check the q for exactly this amount? I couldn´t find how this is done anywhere.

And last my main issue, as I could just ignore the other issues and c/p your suggestion without real comprehension of what is done in each step. But in this case I couldn´t do that anyway. The way you set up the procedure doesn´t work with the piecewise function as I have them in my problem.

The way you defined the pw is: 

piecewise(x < 1,q[O] = x,q[O] = x^2)

whereas I have them in a form like:

piecewise(x < 1,q[O] = x, [])

And of course the "otherwise" part of the function is not an equation. That way the procedure can´t solve the way you suggested. Is there a way around this problem? For example by somehow omitting the check for the "otherwise" part of the piecewise?

 

Thanks again for your great help, I really appreciate it.

Dryan

@Joe Riel 

I could imagine your idea would work. That is if Maple can handle piecewise variables substitued in other equations which I have not tried before.

But, shame on me ;-) , I am a bit confused seeing that procedure. I know it is partly my fault because I can´t give you the complete function but I can´t "read" your procedure, meaning I don´t exactly know what some commands stand for or what parts are commands at all and what should be related to my equation... Is there some help page to explain? I read the help for procedures and some related topics but I still can´t interpret what exactly you are doing.

If it doesn´t take up too much time, I´d be grateful for some basic insight in procedure programming by telling me what in your given example would L, q and l stand for. And what is done by

L := PiecewiseTools:-ToList(pw)

and

          if andmap( l -> l[2] :: (identical(q) = anything), L) then

             L := map(l -> [l[1],op([2,2],l)], L);

             return q = piecewise(seq(op(l), l in L));

I tried to decipher the procedure myself with the help files but I couldn´t figure it out.

@Joe Riel 

I could imagine your idea would work. That is if Maple can handle piecewise variables substitued in other equations which I have not tried before.

But, shame on me ;-) , I am a bit confused seeing that procedure. I know it is partly my fault because I can´t give you the complete function but I can´t "read" your procedure, meaning I don´t exactly know what some commands stand for or what parts are commands at all and what should be related to my equation... Is there some help page to explain? I read the help for procedures and some related topics but I still can´t interpret what exactly you are doing.

If it doesn´t take up too much time, I´d be grateful for some basic insight in procedure programming by telling me what in your given example would L, q and l stand for. And what is done by

L := PiecewiseTools:-ToList(pw)

and

          if andmap( l -> l[2] :: (identical(q) = anything), L) then

             L := map(l -> [l[1],op([2,2],l)], L);

             return q = piecewise(seq(op(l), l in L));

I tried to decipher the procedure myself with the help files but I couldn´t figure it out.

By working on I meant that I still need to handle q[O] as a variable in other equations. With this I would think your first suggestion would be more useful in this case but I don´t exactly know how to implement this.

What I said (or wanted to express, anyway) is, that as a solution of a maximization (diff(f,q[O]), then solve({f´, 0<q[O]}, q[O]) I got a piecewise. This would look like:

piecewise(x<1, q[O]=x, x^2)

One of my problems here is that I can´t assign q[O] as the piecewise, all I would get is "error, recursive argument". I don´t know - again - how to avoid this error. One idea was to somehow remove the q[O] from the equation and then assign but how to do that!? I might just try to build the piecewise anew via op() and rhs() etc., but this piecewise is only one example for a couple of such piecewise´s...

By working on I meant that I still need to handle q[O] as a variable in other equations. With this I would think your first suggestion would be more useful in this case but I don´t exactly know how to implement this.

What I said (or wanted to express, anyway) is, that as a solution of a maximization (diff(f,q[O]), then solve({f´, 0<q[O]}, q[O]) I got a piecewise. This would look like:

piecewise(x<1, q[O]=x, x^2)

One of my problems here is that I can´t assign q[O] as the piecewise, all I would get is "error, recursive argument". I don´t know - again - how to avoid this error. One idea was to somehow remove the q[O] from the equation and then assign but how to do that!? I might just try to build the piecewise anew via op() and rhs() etc., but this piecewise is only one example for a couple of such piecewise´s...

I´m sorry, your suggestion does work.

I just didn´t look through the eval() help file thoroughly enough and didn´t add the []...  But that´s my fault again, I didn´t mention before that I had several variables with assumptions. Now I´ve added the [] I get the solution I needed.

 

Thanks again.

Dryan

I´m sorry, your suggestion does work.

I just didn´t look through the eval() help file thoroughly enough and didn´t add the []...  But that´s my fault again, I didn´t mention before that I had several variables with assumptions. Now I´ve added the [] I get the solution I needed.

 

Thanks again.

Dryan

First, I unassigned them because after filling in values I don´t need to work on them any more, so I can´t see any problems with that. Also I "only" assumed ranges for them, mostly less or greater than 0 and the values I need to fit in are of course in that range...

Now, I tried the eval command, but it didn´t quite work. There are 7 equations I need to solve in this way (which are the solution of multiple steps) and 11 variables with assumptions made on them, so one command (as I would think it should look like) would for example be:

eval(p[R1], alpha = 582, delta[LR] = -.5934818, delta[SR] = -3.69842188, c[S] = 43, c[R] = 94, c[O] = 27, d[O] = 2.51, n = 5, lambda = .5);

But as I have already mentioned, this doesn´t quite work out. Maple will give the equation but doesn´t fill in the values to the variables.

I haven´t tried the assuming command instead of assume, because there are multiple steps to be done up front with the equations and almost all of them include all 11 assumed variables (plus several that have no assumptions).

 

Is there  some other way to fill in these variables or have I misinterpreted something on my way?

First, I unassigned them because after filling in values I don´t need to work on them any more, so I can´t see any problems with that. Also I "only" assumed ranges for them, mostly less or greater than 0 and the values I need to fit in are of course in that range...

Now, I tried the eval command, but it didn´t quite work. There are 7 equations I need to solve in this way (which are the solution of multiple steps) and 11 variables with assumptions made on them, so one command (as I would think it should look like) would for example be:

eval(p[R1], alpha = 582, delta[LR] = -.5934818, delta[SR] = -3.69842188, c[S] = 43, c[R] = 94, c[O] = 27, d[O] = 2.51, n = 5, lambda = .5);

But as I have already mentioned, this doesn´t quite work out. Maple will give the equation but doesn´t fill in the values to the variables.

I haven´t tried the assuming command instead of assume, because there are multiple steps to be done up front with the equations and almost all of them include all 11 assumed variables (plus several that have no assumptions).

 

Is there  some other way to fill in these variables or have I misinterpreted something on my way?

@acer 

Thanks for taking interest in my problem.

Now, the Maple program used to crash when constants were just set as names and not defined. I had some other issues, too, and had to go and upgrade my computer two weeks ago (Maple was using up that much RAM and still didn´t get enough that it just hung up after a while...). I just checked again and this time it almost went through.

This time it isn´t for lack of memory but rather that I defined a couple of solve(); commands with nonnegativity constraints. For example:

> solve({q[O] >= 0, q[S] >= 0, dECSq[O] = 0}, q[O]);

     Error, (in simplify/power) unable to evaluate sign

The resulting Error is shown above. I don´t see a way around defining these constraints here.

(I have no idea, it may work if I would be able to define those constants as positive or negative constants if I knew whether that was possible at all and how!?)

Dryan

@acer 

Thanks for taking interest in my problem.

Now, the Maple program used to crash when constants were just set as names and not defined. I had some other issues, too, and had to go and upgrade my computer two weeks ago (Maple was using up that much RAM and still didn´t get enough that it just hung up after a while...). I just checked again and this time it almost went through.

This time it isn´t for lack of memory but rather that I defined a couple of solve(); commands with nonnegativity constraints. For example:

> solve({q[O] >= 0, q[S] >= 0, dECSq[O] = 0}, q[O]);

     Error, (in simplify/power) unable to evaluate sign

The resulting Error is shown above. I don´t see a way around defining these constraints here.

(I have no idea, it may work if I would be able to define those constants as positive or negative constants if I knew whether that was possible at all and how!?)

Dryan

What I did in checking for equality of the two results was simply dividing them by each other for one or subtracted them. My thought was, that in effect there should be either 1 or 0. Admittedly I did not think about round-off error and that the result might not be the expected because of different errors.

But I still am at a bit of a loss about what to do. Should I then convert all variables to rationals? The floats (Sorry for being a "noob", but I suppose by that you mean the plain numbers!? *lol) should all be constants but I had to define all the constants because else Maple wouldn´t run through.

For now thank you for showing me that the results should at least theoretically be the same, aside from the round-off errors.

 

Dryan

What I did in checking for equality of the two results was simply dividing them by each other for one or subtracted them. My thought was, that in effect there should be either 1 or 0. Admittedly I did not think about round-off error and that the result might not be the expected because of different errors.

But I still am at a bit of a loss about what to do. Should I then convert all variables to rationals? The floats (Sorry for being a "noob", but I suppose by that you mean the plain numbers!? *lol) should all be constants but I had to define all the constants because else Maple wouldn´t run through.

For now thank you for showing me that the results should at least theoretically be the same, aside from the round-off errors.

 

Dryan

Hm, yesterday I had some trouble with uploading the function. For some reason I couldn´t post it here!?

Here it is, though.

p[R1] = (214-.7067494572*q[O]-.3533747286*q[R1]+.1766873643*q[S]^2-.1766873643*q[S]*q[R1]+5.879032258*q[S])/(1+0.7258064513e-1*q[S])

isolate((1), q[R1]); will render the solution as

q[R1] = (p[R1]*(1+0.7258064513e-1*q[S])-214+.7067494572*q[O]-.1766873643*q[S]^2-5.879032258*q[S])/(-.3533747286-.1766873643*q[S])

whereas solve((1), q[R1]); will give the solution as

5.659714287*10^(-11)*(-2.140000000*10^13+7.067494572*10^10*q[O]-1.766873643*10^10*q[S]^2-5.879032258*10^11*q[S]+1.000000000*10^11*p[R1]+7.258064513*10^9*p[R1]*q[S])/(2.+q[S])

And of course I read the Help Files on both commands but I couldn´t figure out why these different solutions are returned or which one of those is correct...

1 2 Page 1 of 2