Items tagged with variables variables Tagged Items Feed

A customer on Twitter recently asked why Maple gives the following result:

 

 


The issue here is that the t in f(t) is the same as the integration variable. 140 characters is not a lot to work with for a reply, so here is a longer explanation.

 

First, note that the process of integration treats the integration variable differently than the other variables, so that replacing another variable by the integration variable has a different effect depending on whether the replacement is done before or after the integration is performed. Consider this simple example:

 

a := int(t, t)

(1/2)*t^2

(4)

eval(a, t = x)

(1/2)*x^2

(5)

a := int(x, t)

x*t

(6)

   

eval(a, t = x)

x^2

(7)

 

In other words, integration does not commute with substitution. This is a fundamental property of integration and in fact, Maple's eval has special rules to take this into account when you ask it to replace the integration variable.  For example, if you evaluate the inert form of the integral at x = y, the substitution is performed explicitly:

 

 

eval(Int(x-t, t = 0 .. x), x = y)

Int(y-t, t = 0 .. y)

(8)

value(Int(y-t, t = 0 .. y))

(1/2)*y^2

(9)

 

However, if you try to evaluate at x = t, the evaluation is delayed until after the integral is evaluated:

 

eval(Int(x-t, t = 0 .. x), x = t)

eval(Int(x-t, t = 0 .. x), {x = t})

(10)

 

value(eval(Int(x-t, t = 0 .. x), {x = t}))

(1/2)*t^2

(11)

 

The eval command knows it shouldn't substitute into an integral when the substitution involves the variable of integration.

 

However, in the user's example, asking Maple for f(t) is equivalent to substitution directly before the integration is performed, like this:

 

subs(x = t, Int(x-t, t = 0 .. x))

Int(0, t = 0 .. t)

(12)

which of course gives:

 

value(%)

0

(13)

 

Another way to have the two t variables be considered distinct is to explicitly make the integration variable a dummy by declaring it local:

 

f := proc (x) local t; int(x-t, t = 0 .. x) end proc
 

Now the ts are treated differently:

 

f(t)

(1/2)*t^2

(14)

``

Austin Roche

Senior Math Developer

Maplesoft

 

Download integration_variables.mw

Hello,

I'd like to clean up my project a bit. In a chapter of a project I made lots of calculations and declared a many (30) variabeles (Table, Numeric, Formula, ..)

Is there a way to remove all variable's except specified one's? (If it is possible I don't want to use an external file to write it to and read it back after a restart)

Is there a way to do a "restart" and preserve only the one's (2) that I need for my next chapter?
Or if not, without a "restart" and remove all variables except specified one's?

Thanks for your help, 

Hi guys.

I have variables that look like C[i,j,k,l], where i,j,k,l can range between 1..3 for example. Is there a simple way to create a pattern-based assumption for something like C[i,j,k,l] = C[j,i,k,l] for all i,j,k,l ?

Kind regards,

woggy

I'm trying to solve a series of equations and then graph them. I'm trying to solve for the variables involved:

values := solve({eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9,

eq10, eq11, eq12, eq13, eq14, eq15, eq16}, {a, b, b, c, d, e, f,

g, h, i, j, k, l, m, n, o, p});

 

. . . but it gives me this:

Warning, solving for expressions other than names or functions is not recommended. 

values := 

I got a problem with a difficult ode,the commands are below.

restart;
sys := 1.*(diff(x(t), t, t)) = piecewise(b(t) = 1, 0, 1003.0-1000.*x(t)-30.*(diff(x(t), t))-25.*signum(diff(x(t), t)-.1)-.3*signum(diff(x(t), t))*exp(-2*abs(diff(x(t), t)))), x(0) = 1, (D(x))(0) = 0;
mu := 100;
stick := [diff(x(t), t) = .1, b(t) = piecewise((1000.-1000.*x(t))^2 < 10000, 1, 0)];
slip := [[0, 10000 < (1000.-1000.*x(t))^2], b(t) = 0];
sol:=dsolve({sys,b(0)=0},numeric,discrete_variables=[b(t)::float],events=[stick,slip],event_maxiter=1000000,output=listprocedure,maxfun=0,range=0..8);

any advice is appreciated.

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

b := Matrix(2, 2, {(1, 1) = "just a string", (1, 2) = 3.14, (2, 1) = 123, (2, 2) = x/y})

b := Matrix(2, 2, {(1, 1) = "just a string", (1, 2) = 3.14, (2, 1) = 123, (2, 2) = x/y})

(1)

``


It should be great for benchmarking !

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





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

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!

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;

but I receive the error

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

Is there anything I can do here?

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

I want to sum over several variables at once.

 

For example, something like

add(add(add(f(k1,k2,k3),k1=range1),k2=range2),k3=range3);

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?

 

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.

 

1.) I start with 2 ordered pairs (2, 14) and (14,18)

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?

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);

              this answer was true.

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.

Thank you in advance.

 

taro yamada

 

 

 

 

 

1 2 3 Page 1 of 3