# Items tagged with variablesvariables Tagged Items Feed

### How to query for the SIZE of a varibale in maple ?...

Yesterday at 1:45 PM
0 7

Is there any command in maple that can show us an assigned varibale how much bytes occupied on memory ?

a:=["just a string", 3.14 , 123 , x/y]

d:=array( 1 .. 2, 1 .. 2, [( 1, 1 ) = ("just a string"), ( 1, 2 ) = (3.14), ( 2, 1 ) = (123), ( 2, 2 ) = (x/y)  ] )

c:=a x^2 + b x + c

 >
 (1)
 >

It should be great for benchmarking !

### System of multivariable linear inequalities (12 va...

September 26 2014
4 30

Hi there.

I'm kind of new to Maple and i'm trying to solve a Linear Algebra problem for my class of Linear Algebra of the course of Physics. Also, my first language is portuguese so forgive for my not-so-perfect english.

I have a (solved) linear system of 7 equations and 12 variables (A, B, C, D, E, F, G, H, I, J, K, L) that is the following:

• A = 33 - K - L
• B = 1 + F - J
• C = -15 - F + J + K + L
• D = 15 + H - K
• E = 16 - F - H + J + K
• G = 34 - H - J - L
• I = 18 - J - K

Note: I'm using letters (A, B, ..., L) instead of X1X2, ..., X12 because it's easier to write it like this here and because I don't know if the Xn notation is allowed on Maple (i don't think so).

So, the system is possible but undetermined (with 5 degrees of freedom), being F, H, J, K and L the free variables.

Until here, everything's fine. The problem arises when the professor asks us for every solution of the system that satisfies the condition that all the variables (form A to L) are positive integers (A, B, C, D, E, F, G, H, I, J, K, L ϵ IN → natural numbers).

From my understanding, that gives rise to a system of linear inequalities with 12 variables and the following inequalities:

• A = 33 - K - L > 0
• B = 1 + F - J > 0
• C = -15 - F + J + K + L > 0
• D = 15 + H - K > 0
• E = 16 - F - H + J + K > 0
• G = 34 - H - J - L > 0
• I = 18 - J - K > 0
• > 0
• > 0
• > 0
• > 0
• > 0                            (and A,B,C,D,E,F,G,H,I,J,K,L ϵ IN)

After some research, i found that a possible way to solve this type of system of linear inequalities is trough a method of elimination (analog to Gauss-Jordan's elimination method for systems of linear equations) named Fourier-Motzkin. But it's hardwork and i wanted to do it on the computer. After some research, i came across with the following Maple command:

SolveTools[Inequality][LinearMultivariateSystem]

http://www.maplesoft.com/support/help/Maple/view.aspx?path=SolveTools%2fInequality%2fLinearMultivariateSystem

So, I tried to use that command to solve my system, with the following result (or non-result):

with(SolveTools[Inequality]);
LinearMultivariateSystem({F > 0, H > 0, J > 0, K > 0, L > 0, 1+F-J > 0, 15+H-K > 0, 18-J-K > 0, 33-K-L > 0, 34-H-J-L > 0, -15-F+J+K+L > 0, 16-F-H+J+K > 0}, [F, H, J, K, L]);

Error, (in SolveTools:-Inequality:-Piecewise) piecewise takes at least 2 parameters

So, i really need help solving this as the professor told us that the first one to solve would win a book, eheh. I don't know what I'm doing wrong. Maybe this Maple command is not made for 12 variables? Or maybe i'm just writing something on a wrong form. I've never used Maple before so i can be doing something really stupid without knowing it.

I would really apreciate an answer, as my only goal as a future physicist is to unveil the secrets of the Cosmos to us all.

Thank you again.

Miguel Jesus

### How do I solve a complex multi-regression problem?...

September 25 2014
1 0

Hi all.  I have researched into this problem.  But I could not find a solution to this.

Here is an example.

I have a set of independent variables, say there are 5 of them.  They are 1. Gender 2. Age group 3. Full or part time 4. First language.

I have a set of dependent variables.  Let us consider for an example 6 of them.  They are (i) Develops breast cancer (ii) Develops skin cancer (iii) Develops lung cancer (iv) develops prostate cancer (v) Lives till 50 (vi) Lives till 60 ...

How do I perform the following prediction:

(A) If a person is male and above 50, what are the chances that he is likely to develop prostate cancer?

(B) If a person is female and works part time, what are the chances that she is likely to develop breast cancer and lives till 60?

I need to develop a code and formula to do this?  Can someone please advise?

Many thanks.

Kind regards,

Kris

### Integral limits ...

September 25 2014
0 6

I have a proc as follows:

F:=proc(f,n)
L:=[f];
for j from 1 to n do;
J:=int(1/subs(t=x[j],L[j]),x[j]=2..x[j+1]);
L:=[op(L),J];
end do;
end proc;

I chose to use index variables. However when I try to apply a member of the output list as a function of the outermost limit, I do not get any output when I try to evaluate the function. I suspect maple is having trouble with the variables withing the integral. How can I make this work?

I'd like to have a function that I can evaluate:

g:=F(log(t),3)[3];
f:=unapply(g,x[3]);

f(2.1);

Thanks!

September 23 2014
1 2

### Defining a Function of a Pre-Defined Number of Var...

August 07 2014
1 7

I'm writing some code that computes a positive integer N and I'd like Maple to define a function of N variables. I've tried writing

f := (seq(t[i],i=1..N))-> MY EXPRESSION;

Error, invalid parameter; functional operators require their parameters to be of type symbol or (symbol::type)

Is there anything I can do here?

### CodeGeneration generate the variables for C code...

August 04 2014
1 3

Hi all,

I'm using MAPLE 13 and I'd like to know if someone knows how to generate the variables associated to the CodeGeneration for C code. At this moment I need to create manually the variable generated from the C code.

Example:

JJ := Jacobian(convert(Pint, Vector), [P1xenu, P1yenu, P1zenu, roll, pitch, yaw, D1xbody, D1ybody, P2xenu, P2yenu, P2zenu, ROLL, PITCH, YAW, D2xbody, D2ybody]);

CodeGeneration['C'](JJ, optimize);

Output:

t1 = cov2 * cov2;
t2 = cov1 * cov1;
t4 = 0.1e1 / (t1 + t2);
t5.......

And in the C code I need to create:

double t1, t2, t3..... manually

I can I solve this issue?

Best regards

André Dias

### Can I sum over several variables in a single loop?...

July 19 2014
2 14

I want to sum over several variables at once.

For example, something like

sums over 3 variables. But this can only be done if I know the number of variables in advance. I want to write a code that will sum over m variables, with m being supplied on demand.

Maple can do this for integrals. If I write

int(f(seq(k[i],i=1..m)),[seq(k[i]=range[i],i=1..m)]);

the integral is computed over m variables, for any m.

How can something like this be implemented for summation?

### trouble with basic linear equations...

June 11 2014
1 2

I'm having some trouble maybe someone can point out my error please. I'm using the Maple 18 worksheet to try some basic linear equations. The trouble is in the last step.

Then I put in my formula to discover the slope. I confirm it looks correct in the Variables window.

m := (y2-y1)/(x2-x1);

2.)  Next I input the values for my ordered pairs. I also confirm thru the Variables window.

x1 := 2;

y1 := 14;

x2 := 3;

y2 := 18;

3.) Now I can type m and expect to get an answer to what my slope is.

m;

4.) Now I want Slope/Intercept form of y=mx+b. When I put in the formula y-y1=m(x-x1) i get a strange result

When I execute this formula, the result is y-14=4. (or thru context menu I tell it to solve for y, then I get y=18)

y-y1=m(x-x1)

When I manually input the values, the output is y-14=4x-8 (or thru context menu I tell it to solve for y, then I get y=4x+6)

y-14 = 4*(x-2)

Why is my equation (y-y1=m(x-x1)) not executing properly?

### local variables and strings...

May 03 2014
0 2

To those who read this post.

I have a question about the property of local variables in a procedure.

Are names at the local variables in procedures, strings not names?

If so, why can strings be evalated to have Integer, which is numbers for counting for continuing repetition?

This is the code which searches for the maximum value.

**************************************************

Max2 := proc()

local i, m :: string;
if nargs = 0 then
return -infinity
end if;
m:= args[1];
for i from 2 to nargs do
if args[i] > m then
m := args[i]
end if;
end do;
m;
end proc:
Max2(1,7,5,4,6,10,35,63.5,-10,5);

************************************************

type(a,name);

type(1, string)

this answer was false, of course.

I limited the values of local variables to be string.

But, to the sequence 1,7,5,4,6,10,35,63.5,-10,5, any error messages wouldn't appear.

I hope any of you will give me an answer.

### Solve can't find analytically solution... but I ca...

April 24 2014
2 2

Hi Maple-Prime-ers!

I have a system of equations, containing 18 variables and 13 equations, making this a 5 degree of freedom (DOF) system.  I would like to analytically solve each of the equations in terms of each of these DOFs.  Normally I would use solve(system, dof_variables) to accomplish this, but it doesn't return anything.  Not even [].

I can solve this system by hand.  I've included a hand-solution involving isolate() and subs() in the attached worksheet.  I'm looking to incorporate this in an optimization algorithm with varying system, so I would like an automated way of doing this.

Does anybody have any suggestions to get solve to work as intended?

3driversys_FD_BRAKE_ICE_GEN.mw

Here is the system I am talking about:

The free variables are:  {FD_T, FD_W, ICE_T, EM2_T, BRAKE_T}

I'm looking for a solution in this form:

### How can I solve...

April 12 2014
1 5

How can I use maple and separation of variables ,solve the wave equation utt=uxx for a string of lengh 4 with u(x,0)=sin (Pi/2 x) e-x . ut(x,0)=0.u(0,t)=0 and u(4,t)=0.

### How to have maple identify dependent variable in m...

March 24 2014
0 2

I am trying to write a procedure that have the following input:  expr, xdata,ydata. [dependent variables list]

I want a procedure to calculate Rsquare following the method described in

http://www.mapleprimes.com/questions/120014-How-To-Calculate-Coefficient-Of-Determination

But I want the proc to take any abitary function and be able to identify the  dependent variable...how can I approach it? what function can I use to match [dependent variable list] in expr??

Thanks

### can one declare local variables with an inner bloc...

March 13 2014
2 6

Ok, I am not able to find about this after 30 minutes search (my limit of giving up :).

One can ofcourse make a local variables in a proc. But sometimes I need to make a temporary variable within the proc, say inside an if...fi to use for some local temporary computation. There is no need for this temporary variable to be declared at the whole proc() scope, since it is used only inside some limited scope.  I am not able to find how to do this in Maple. Here is some silly example

f:=proc()
local x;
x:=9;
if x<10 then
local z;
z:=20;
x:=z;
....
fi;
x;
end proc;

the above is illegal. I can do this:

f:=proc()
local x;
x:=9;
if x<10 then
proc()
z:=20;
x:=z;
....
end proc;
fi;
x;
end proc;
which compiles , but does not do what is expected. The body of the if statement is not called. I added a print statments there and they are not being called. (I guess since it is non-named proc(), it is not called, I thought it will fall through....

I looked for some kind of BLOCK , or DECLARE construct or such in Maple but can't find it.

is it possible to introduce a temporary local scope within a proc()? What would be the syntax? That would be really useful. Ada has this feature.

### Change of variables in differential equation...

December 03 2013
1 2

Consider the differential equation zZ'' + Z' + a2Z = 0,  where Z = Z(z).  Using the change of variables x = \sqrt{z/b}with b a constant,  obtain the differential equation Z'' + (1/x)Z' + c2Z = 0, where Z = Z(x) and c = 2a \sqrt{b}.

I tried Maple help and it offers the dchange command, and what I have tried is shown below;

with(PDEtools):

DE:= ...

tr:= {z = x2b}

dchange(tr, DE)

This did not return anything however.  I am thinking I need to specify that b is a constant, however, I am a little unsure on how to do this. Is the above the correct way to proceed?  I don't see how I have specified anywhere that in the final PDE, I require Z=Z(x).

Thanks for any help.  This is my first post here, so apologies for the typesetting. If there is inbuilt latex, I will use it next time.

 1 2 3 Page 1 of 3
﻿