# Items tagged with assignassign Tagged Items Feed

### A matter of notation...

June 13 2015
0 7

Dear Maple users

I am unsure how to handle events and their probabilities in Maple. Let's say I know that an event A has the probability say 0.3 and another event B has probability 0.8. I would like to make the following assignments:

P(A):=0.3:

P(B):=0.8

and maybe defining the conditional probability:

P(A|B):=0.55

but I am not allowed to do so in Maple because if will regarded as a function definition. My purpose is to make simple calculations with those probabilities for example:

P(C):=P(A)*P(B)  etc.

My problem is therefore more of a notational problem than a mathematical one. I hope someone can advice me on a proper setup. I am using 2D math notation, by the way. I could of course name the variables containing the probability using simple names like X1, X2, etc., but then I need constantly to remember what they really mean. The above assignments would be much better, because they are easier to handle mentally.

Regards,Erik

### Error, invalid left hand side in assignment...

April 06 2015
0 2

Here is my code

ma[1] := [-885.880598855072776, [bh = 0., g0h = 0., g1h = 0.825946224722250e-4]]

ma[2] := [-877.957885609114328, [bh = 347.116836805625, g0h = 0., g1h = 0.164861392564e-3]]

ma[3] := [-863.445203144006655, [bh = 0., g0h = 0., g1h = 0.787090377403668e-4]]

avb := 90.5276611129000; avg0 := 0; avg1 := 0.92225359e-4;

for j from 1 to 3 do

assign(ma[j][2]);

A[j] := [(avb-bh)^2, (avg0-g0h)^2, (avg1-g1h)^2]

end do;

Result is that

A[1] := [4763.19965962732, 0., 1.13103562500664*10^(-10)]

Error, invalid left hand side in assignment

it only shows A[1], but no A[2] and A[3]

### there is a way to use assignments in another Maple...

March 19 2015
0 4

I'd like to tell a new worksheet to use assignments created in another document. This is to save time retyping equations.

And, is this something that others like to do ?

Thanks.

Cheers !

### how to select terms from one expression into 2 dif...

January 11 2015
2 3

I am trying separation of variables in Maple. I get an equation that has the form

And now I want to tell Maple to assign the terms with 1/R in them to one variable, say eq21, and the term with 1/Z to second variable, say eq22 The idea is that I can later more easily work with each separate ode.

I do not know to separate those apart. I could offcourse copy and paste by hand, but I want to automate this.

I tried match() and patmatch() but I am not seeing the way. Here is the code:

restart;
T:=  (r,z)-> Z(z)*R(r);
eq1:= diff(T(r,z),r\$2)+1/r*diff(T(r,z),r)+diff(T(r,z),z\$2);
eq2:=expand(eq1/(Z(z)*R(r)));

#need now way to break the above into 2 different variables.

ps. I know I can do this:

restart;
T:=  (r,z)-> Z(z)*R(r);
eq1:= diff(T(r,z),r\$2)+1/r*diff(T(r,z),r)+diff(T(r,z),z\$2);
eq2:=expand(eq1/(Z(z)*R(r)));
eq3:=collect(eq2,1/R(r));
eq21:=op(1,eq3);
eq22:=op(2,eq3);

But this for me is not the right way to do it. I think there should be more algebraic way.

### about codes in the help of assign ...

January 08 2015
1 5

Hello People in Mapleprimes,

I have a question about the codes in the help page of assign.

The folliowing codes were written there:

code (A)

assign(a,c):

assign(a=d,b=2):

a,b,c;

The output of these was

d,2,d

I think that assign(a,c) means assign(a=c) or a:=c, not c:=a.

If what I wrote was true, the output of the above code should be

d,2,c.

And, if I changed assign(a,c) to assign(c,a), the output was d,2,d, which is the output written on the helppage

of the assign. On the other hand, the output of code A was surely d,2,d.

Why does assign(a,c) have the same meaning as assign(c,a)?

Best wishes

taro

### Is there access to the name of an assignee in a pr...

December 13 2014
0 0

I have the following situation:

HB:=Bend(L,a,n);

Bend is a proc, that returns a Record with info based on its parameters. I would like to get access to the name I assign to (i.e. HB) in the proc. Any chance?

Mac Dude

PS: I can of course kludge things by adding an argument to the proc Bend. But I'd like to avoid that.

### remember table assignment vs function definition...

December 09 2014
1 2

I have written a program and at one point I have an assignment statement like BG(i, j) :=1    When ever I run the program, I get a dialog box which asks me to choose between "function definition" and "remember table assignment."  Is there a way to tell the program that I want this to be a table assignment in the code so that I don't always have to answer the question?

### Problem with assign...

December 08 2014
0 1

Today I have a problem with assign that never arised before. I solved a system of equations with two solutions and wanted to assign, e.g. the second one. Does anybody know why "assign" here does not work, even though I often used it before in the same way. (I also tried it with the array-solution, but I received the same problem.

Output:

{rH = 0., rL = 0., xH = 0.2289428485, xL = 0.2289428485}, {

rH = 22.70954353, rL = 32.28670872, xH = 0.4250775404,

xL = 0.4393791233}
{rH = 0., rL = 0., xH = 0.2289428485, xL = 0.2289428485}, {

rH = 22.70954353, rL = 32.28670872, xH = 0.4250775404,

xL = 0.4393791233}
assign {rH = 22.70954353, rL = 32.28670872, xH = 0.4250775404,

xL = 0.4393791233}
rL, rH, xL, xH

I would be very glad, if anybody could help me.

And here is the whole algorithm:

### Solution for a given set of parameters...

November 02 2014
1 4

Is it possible in Maple 15 to solve an equation with a parameter for a given set of parameters? How can this be passed to the solve function, should I use some kind of list?  After obtaining the solution how can I assign the solutions to variables such as x1 for the first value of the parameter, x2 for the second value of the parameters and so on. Furthermore, is this possible with the fsolve command?

Thanks

### assign small angel assumptions...

September 17 2014
1 7

Hi,

I was wondering how I could assign small angel assumptions so that I could simplify an equation of motion to solve for theta double dot. Thank you for your help.

Equation Manipulation

-assumptions- small angel

 (1)

 (2)

### founding the error in program...

July 13 2014
0 2

hi all.

I have wrore the following program for optimization with bernstein and block pulse hybrid functions.

the program have some errors which i can't understand.

Bernestien1.mws

 > restart:
 > alias(C=binomial): with(LinearAlgebra): macro(LA= LinearAlgebra):
 > HybrFunc:=proc(N, M,  tj)               # N=Number of subintervals,  M=Number of functions in subintervals   local B, n, m; global b; for n from 1 to N do for m from 0 to M-1 do B := (i,m,t) -> C(m,i)*(1-t)^(m-i)*t^i: b[n,m]:=unapply(piecewise(t>=(n-1)*tj/N and tb[n,m](t)): #convert(%,vector); end proc: HybrFunc(3, 3, 1);                                        # End Of Definition   g2(t):=t;            #*exp(t-1):                      # Any other function can be replaced here      g1(t):=add(add(c[n,m]*b[n,m](t), m=0..2), n=1..3); Optimization[Minimize](sqrt(int((g2(t)-g1(t))^2, t=0.. 1))); assign(op(%[2])); plot([g2(t),g1(t)], t=0..1, 0..5, color=[blue,red],thickness=[1,3],discont, scaling=constrained);
 Error, (in Optimization:-NLPSolve) complex value encountered Error, invalid left hand side in assignment (1)

I'll be so grateful if any one can help me.

Ph.D Candidate

Applied Mathematics Department

### Warning, cannot evaluate the solution further righ...

July 09 2014
0 1

Pleaz i nees help i have probleme withe singularity

 >

Paramétres

 >
 (1.1)

Equation suivant x :

 >
 (2.1)

Equation suivant z :

 >
 (3.1)

Equation suivant y :

 >
 (4.1)

Equation suivant y

 >
 (5.1)

Résolution :

 > CI:= x(0)=0,z(0)=0,theta(0)=0,alpha(0)=0,D(x)(0)=0,D(alpha)(0)=0,D(z)(0)=0,D(theta)(0)=0;
 (6.1)
 > if theta(t) <> 0 then  solution:=dsolve([eq1,eq2,eq3,eq4,CI],numeric,maxfun=0):  odeplot(solution, [[t, x(t)]], t = 0 .. 100, thickness = 2);  odeplot(solution, [[t, z(t)]], t = 0 .. 100, thickness = 2);  odeplot(solution, [[t, theta(t)]], t = 0 .. 100, thickness = 2);  odeplot(solution, [[t, alpha(t)]], t = 0 .. 100, thickness = 2);  #odeplot(solution,[[t,x(t)],[t,alpha(t)],[t,z(t)],[t,theta(t)]], t=0..100, thickness=2);  end ;

thank you !

### how to refresh a variable back to a variable after...

June 29 2014
0 1

x: =Matrix([[a1,a2],[a3,a4]])

after some calculation,

assign(%)

a1 etc have value,

how to make a1,a2,a3,a4 back to variable in maple 12?

### Assigning characteristics to each member of an arr...

March 18 2014
1 5

I know how to create arrays, but I want to assign characteristics to each position in the array; the array being a population with each member having a set of characteistics like height, weight etc. I want to be able to have some of the characteristics able to change with time, and some remain constant (those that change with time will be defined by generic equations)

I have tried looking on maplesoft for answers, and the help within maple 16, but have been unable to make any progress.

Sorry if the question is not specific enough.

### question on single level evaluation for variables ...

March 13 2014
2 3

I need a small help again. I have a basic question. Not able to figure how to do this.
(I am a newbie in Maple)

Maple handles things little different inside a proc() vs. global. http://www.maplesoft.com/support/help/Maple/view.aspx?path=procedure

And I could not understand what this below means in plain English:

Within a procedure, during the execution of its statementSequence, local
variables have
single level evaluation. This means that using a variable
in an expression will yield the current value of that variable, rather than
first evaluating that value. This is in contrast to how variables are evaluated
outside of a procedure, but is similar to how variables work in other programming languages.

But here is my question. In global name space, A variable inside an expression will automaticaly
update to the current value of the the variable. So one can do this:

x:='x';z:='z';
expr:=3*z;
z:=solve(x-1=0,x);
expr;

and now expr will have value "3" and not "3 z" since "z" was assigned a new numerical value in between
as one can see. The same code inside a proc()  behave differently

f:=proc()
local z,x,expr;
expr:=3*z;
z:=solve(x-1=0,x);
expr;
end proc:

f();

return "3 z" and not "3" as the case with global scope. I tried subs() insid the proc,
but still it did not work. What is the recommded way to handle this? I want "expr" to
use the most recent value of any variables inside it. I can't do sub(z=z,expr) ofcourse
since this makes no sense. I need the value of z inside expr to be updated.i.e. I need
to refresh "expr" somehow.

thank you,

 1 2 3 4 5 6 7 Last Page 1 of 24
﻿