Items tagged with define define Tagged Items Feed

This one really has me baffled.

What the proc does is not important. This is just about as simple an example as I could write. Maple 2015 is complaining anytime I try to declare a local variable. The second example shows that the local declaration is needed - Maple even introduces it into the procedure that it defines.

restart;
test := proc(  )
local a;
a := 3
end proc;
Error, unexpected `local` declaration in procedure body
test := proc(  )
# local a;
a := 3
end proc;
Warning, `a` is implicitly declared local to procedure `test`
test := proc(x) local a; a := x end proc

Here's the version information for my current Maple.

interface( version );
Standard Worksheet Interface, Maple 2015.0, Windows 7, February 17 2015 Build ID 1022128

Can someone explain what is happening, and why I'm just now seeing this?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

I ran into a problem with define that I traced to the 'linear' option in the define statement, and I would like to know whether this is my lack of understanding define, or a bug.

I want to define a function called avg(parm) (which I never will need to use explicitly but  I need to be able to manipulate). This function has the property of being linear, and terms not depending on x can be pulled out. Also, avg(parm)=parm unless parm depends on x. (Yes, it stands for a kind of averaging, but that is not relevant here).

So I programmed it in this way:

define(avg,'linear','conditional'(avg(a::algebraic) = a, _type(a, freeof(x))),\
'conditional'(avg(a::(nonunit(algebraic))*b::(nonunit(algebraic))) = a*avg(b), _type(a, freeof(x))));

For the heck of it I could not get it to work. Basically, none of the equations in the definition were ever used, except that constant numeric factors were pulled out, as they should.

Eventually I found that the 'linear' option was the culprit. Once I got rid of that, the definition of avg did what I wanted it to do (like avg(a*x) => a*avg(x); avg(a) => a). The reason a constant numeric factor was pulled out before is because the 'linear' option does that; it never gets to my definitions (one can see that when printing avg).

Am I missing something fundamental here, or is define not working right?

For the record, I did this in Maple 15 on a PPC Mac. I don't have my Maple 2015 handy to test on that version.

Any insights?

Mac Dude

Hello,

I have a two variable function d(a,b) which i don't want to substitute for the result. How can I make this product distributive,e.g. d(a+b,c)=d(a,c)+d(b,c) with independece of the variables I introduce in the function?

Thank you for the help!

 

I am trying to use the Define() funtion for the tetrad form of the Ricci Tensor. I use the Setup() function to define the tetradmetric and the tetrad labels. However, the function continues do some strange things with the d_ . It should be just a simple sum over the repeated indices, but I am getting imaginary terms.

 

  restart; with(Physics); with(Tetrads)

0, "%1 is not a command in the %2 package", Tetrads, Physics

(1)

Physics:-Setup(coordinatesystems = {X}, spacetimeindices = greek, tetradindices = lowercaselatin, tetradmetric = Matrix([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]], shape = symmetric), mathematicalnotation = true)

[coordinatesystems = {X}, mathematicalnotation = true, spacetimeindices = greek, tetradindices = lowercaselatin, tetradmetric = {(1, 2) = 1, (3, 4) = 1}]

(2)

Physics:-Define(GammaT[a, b, c], RicciT[b, c] = -%d_[c](GammaT[`~a`, b, a])+%d_[a](GammaT[`~a`, b, c])-Physics:-`*`(GammaT[`~m`, b, a], GammaT[`~a`, m, c])+Physics:-`*`(GammaT[`~m`, b, c], GammaT[`~a`, m, a])-Physics:-`*`(GammaT[`~a`, b, m], GammaT[`~m`, c, a]-GammaT[`~m`, a, c]))

{Physics:-Dgamma[mu], GammaT[a, b, c], Physics:-Psigma[mu], RicciT[b, c], Physics:-d_[mu], Physics:-Tetrads:-eta_[a, b], Physics:-g_[mu, nu], Physics:-Tetrads:-l_[mu], Physics:-Tetrads:-m_[mu], Physics:-Tetrads:-mb_[mu], Physics:-Tetrads:-n_[mu], Physics:-KroneckerDelta[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(3)

RicciT[1, 2]

-%d_[2](GammaT[`~1`, 1, 1]+GammaT[`~2`, 1, 2]+GammaT[`~3`, 1, 3]+GammaT[`~4`, 1, 4])-GammaT[`~1`, 1, 3]*GammaT[`~3`, 2, 1]-GammaT[`~3`, 1, 3]*GammaT[`~3`, 2, 3]-GammaT[`~4`, 1, 3]*GammaT[`~3`, 2, 4]+GammaT[`~4`, 1, 2]*GammaT[`~1`, 4, 1]+GammaT[`~4`, 1, 2]*GammaT[`~3`, 4, 3]+GammaT[`~4`, 1, 2]*GammaT[`~4`, 4, 4]+GammaT[`~1`, 1, 2]*GammaT[`~3`, 1, 3]+GammaT[`~1`, 1, 2]*GammaT[`~4`, 1, 4]+GammaT[`~2`, 1, 2]*GammaT[`~1`, 2, 1]+GammaT[`~2`, 1, 2]*GammaT[`~3`, 2, 3]+GammaT[`~2`, 1, 2]*GammaT[`~4`, 2, 4]+GammaT[`~3`, 1, 2]*GammaT[`~1`, 3, 1]+GammaT[`~3`, 1, 2]*GammaT[`~3`, 3, 3]+GammaT[`~3`, 1, 2]*GammaT[`~4`, 3, 4]-GammaT[`~1`, 1, 4]*GammaT[`~4`, 2, 1]-GammaT[`~3`, 1, 4]*GammaT[`~4`, 2, 3]-GammaT[`~4`, 1, 4]*GammaT[`~4`, 2, 4]-GammaT[`~1`, 1, 1]*GammaT[`~1`, 2, 1]-GammaT[`~3`, 1, 1]*GammaT[`~1`, 2, 3]-GammaT[`~4`, 1, 1]*GammaT[`~1`, 2, 4]-GammaT[`~1`, 1, 2]*GammaT[`~2`, 2, 1]-GammaT[`~3`, 1, 2]*GammaT[`~2`, 2, 3]-GammaT[`~4`, 1, 2]*GammaT[`~2`, 2, 4]-(1/2)*2^(1/2)*%d_[3](GammaT[`~2`, 1, 2])+(1/2)*2^(1/2)*%d_[3](GammaT[`~1`, 1, 2])+GammaT[`~2`, 3, 2]*GammaT[`~3`, 1, 2]+GammaT[`~2`, 4, 2]*GammaT[`~4`, 1, 2]+GammaT[`~1`, 1, 1]*GammaT[`~1`, 1, 2]+GammaT[`~1`, 1, 2]*GammaT[`~2`, 1, 2]-GammaT[`~1`, 2, 2]*GammaT[`~2`, 1, 1]-GammaT[`~2`, 1, 3]*GammaT[`~3`, 2, 2]-GammaT[`~2`, 1, 4]*GammaT[`~4`, 2, 2]+((1/2)*I)*2^(1/2)*%d_[1](GammaT[`~4`, 1, 2])-((1/2)*I)*2^(1/2)*%d_[4](GammaT[`~4`, 1, 2])+((1/2)*I)*2^(1/2)*%d_[1](GammaT[`~3`, 1, 2])+((1/2)*I)*2^(1/2)*%d_[4](GammaT[`~3`, 1, 2])+((1/2)*I)*2^(1/2)*%d_[2](GammaT[`~2`, 1, 2])+((1/2)*I)*2^(1/2)*%d_[2](GammaT[`~1`, 1, 2])

(4)

 

``

 

Download Problem_with_Defined_Tetrad_Function.mw

 

restart; with(Physics); with(Tetrads)

0, "%1 is not a command in the %2 package", Tetrads, Physics

(1)

Physics:-Setup(coordinatesystems = {X}, mathematicalnotation = true)

[coordinatesystems = {X}, mathematicalnotation = true]

(2)

Physics:-Define(Ybar[a], Y[a], GammaT[a, b, c], RicciT[b, c] = %d_[c](GammaT[`~a`, b, a])-%d_[a](GammaT[`~a`, b, c])+Physics:-`*`(GammaT[`~m`, b, a], GammaT[`~a`, m, c])-Physics:-`*`(GammaT[`~m`, b, c], GammaT[`~a`, m, a])+Physics:-`*`(GammaT[`~a`, b, m], GammaT[`~m`, c, a]-GammaT[`~m`, a, c]), RiemannT[k, l, m, n] = %d_[k](GammaT[m, n, l])-%d_[l](GammaT[m, n, k])+Physics:-`*`(GammaT[`~a`, m, l], GammaT[a, n, k])-Physics:-`*`(GammaT[`~a`, m, k], GammaT[a, n, l])+Physics:-`*`(GammaT[m, n, a], GammaT[`~a`, k, l]-GammaT[`~a`, l, k]))

RicciT[1, 3]

%d_[3](GammaT[`~1`, 1, 1]+GammaT[`~2`, 1, 2]+GammaT[`~3`, 1, 3]+GammaT[`~4`, 1, 4])+GammaT[`~4`, 1, 2]*GammaT[`~2`, 3, 4]+GammaT[`~1`, 1, 3]*GammaT[`~3`, 3, 1]+GammaT[`~2`, 1, 3]*GammaT[`~3`, 3, 2]+GammaT[`~4`, 1, 3]*GammaT[`~3`, 3, 4]-GammaT[`~2`, 1, 3]*GammaT[`~1`, 2, 1]-GammaT[`~2`, 1, 3]*GammaT[`~2`, 2, 2]-GammaT[`~2`, 1, 3]*GammaT[`~4`, 2, 4]-GammaT[`~3`, 1, 3]*GammaT[`~1`, 3, 1]-GammaT[`~3`, 1, 3]*GammaT[`~2`, 3, 2]-GammaT[`~3`, 1, 3]*GammaT[`~4`, 3, 4]-GammaT[`~4`, 1, 3]*GammaT[`~1`, 4, 1]-GammaT[`~4`, 1, 3]*GammaT[`~2`, 4, 2]-GammaT[`~4`, 1, 3]*GammaT[`~4`, 4, 4]-GammaT[`~1`, 1, 3]*GammaT[`~2`, 1, 2]-GammaT[`~1`, 1, 3]*GammaT[`~4`, 1, 4]+GammaT[`~1`, 1, 4]*GammaT[`~4`, 3, 1]+GammaT[`~2`, 1, 4]*GammaT[`~4`, 3, 2]+GammaT[`~4`, 1, 4]*GammaT[`~4`, 3, 4]+GammaT[`~1`, 1, 1]*GammaT[`~1`, 3, 1]+GammaT[`~2`, 1, 1]*GammaT[`~1`, 3, 2]+GammaT[`~4`, 1, 1]*GammaT[`~1`, 3, 4]+GammaT[`~1`, 1, 2]*GammaT[`~2`, 3, 1]+GammaT[`~2`, 1, 2]*GammaT[`~2`, 3, 2]+GammaT[`~1`, 3, 3]*GammaT[`~3`, 1, 1]+GammaT[`~2`, 3, 3]*GammaT[`~3`, 1, 2]+GammaT[`~3`, 1, 4]*GammaT[`~4`, 3, 3]-GammaT[`~3`, 4, 3]*GammaT[`~4`, 1, 3]-GammaT[`~1`, 1, 1]*GammaT[`~1`, 1, 3]-GammaT[`~1`, 1, 3]*GammaT[`~3`, 1, 3]-GammaT[`~2`, 1, 3]*GammaT[`~3`, 2, 3]-%d_[4](GammaT[`~4`, 1, 3])+%d_[1](GammaT[`~1`, 1, 3])+%d_[3](GammaT[`~3`, 1, 3])+%d_[2](GammaT[`~2`, 1, 3])

(3)

for a to 4 do for b to 4 do RicciT[a, b] end do end do

Error, (in index/PhysicsTensor) expected summation indices of type symbol, received: 1

 

 

Now, if I type the RicciT from (3) it displays the same result. However,......

 

RicciT[1, 3]

%d_[3](GammaT[`~1`, 1, 1]+GammaT[`~2`, 1, 2]+GammaT[`~3`, 1, 3]+GammaT[`~4`, 1, 4])+GammaT[`~4`, 1, 2]*GammaT[`~2`, 3, 4]+GammaT[`~1`, 1, 3]*GammaT[`~3`, 3, 1]+GammaT[`~2`, 1, 3]*GammaT[`~3`, 3, 2]+GammaT[`~4`, 1, 3]*GammaT[`~3`, 3, 4]-GammaT[`~2`, 1, 3]*GammaT[`~1`, 2, 1]-GammaT[`~2`, 1, 3]*GammaT[`~2`, 2, 2]-GammaT[`~2`, 1, 3]*GammaT[`~4`, 2, 4]-GammaT[`~3`, 1, 3]*GammaT[`~1`, 3, 1]-GammaT[`~3`, 1, 3]*GammaT[`~2`, 3, 2]-GammaT[`~3`, 1, 3]*GammaT[`~4`, 3, 4]-GammaT[`~4`, 1, 3]*GammaT[`~1`, 4, 1]-GammaT[`~4`, 1, 3]*GammaT[`~2`, 4, 2]-GammaT[`~4`, 1, 3]*GammaT[`~4`, 4, 4]-GammaT[`~1`, 1, 3]*GammaT[`~2`, 1, 2]-GammaT[`~1`, 1, 3]*GammaT[`~4`, 1, 4]+GammaT[`~1`, 1, 4]*GammaT[`~4`, 3, 1]+GammaT[`~2`, 1, 4]*GammaT[`~4`, 3, 2]+GammaT[`~4`, 1, 4]*GammaT[`~4`, 3, 4]+GammaT[`~1`, 1, 1]*GammaT[`~1`, 3, 1]+GammaT[`~2`, 1, 1]*GammaT[`~1`, 3, 2]+GammaT[`~4`, 1, 1]*GammaT[`~1`, 3, 4]+GammaT[`~1`, 1, 2]*GammaT[`~2`, 3, 1]+GammaT[`~2`, 1, 2]*GammaT[`~2`, 3, 2]+GammaT[`~1`, 3, 3]*GammaT[`~3`, 1, 1]+GammaT[`~2`, 3, 3]*GammaT[`~3`, 1, 2]+GammaT[`~3`, 1, 4]*GammaT[`~4`, 3, 3]-GammaT[`~3`, 4, 3]*GammaT[`~4`, 1, 3]-GammaT[`~1`, 1, 1]*GammaT[`~1`, 1, 3]-GammaT[`~1`, 1, 3]*GammaT[`~3`, 1, 3]-GammaT[`~2`, 1, 3]*GammaT[`~3`, 2, 3]-%d_[4](GammaT[`~4`, 1, 3])+%d_[1](GammaT[`~1`, 1, 3])+%d_[3](GammaT[`~3`, 1, 3])+%d_[2](GammaT[`~2`, 1, 3])

(4)

 

If I type a different RicciT, then ...

 

RicciT[2, 3]

Error, (in index/PhysicsTensor) expected summation indices of type symbol, received: 1

 

 

The for loop is changing the tetrad definition of RicciT.

 

NULL

 

Download Question_about_tetrads_in_for_loop.mw

I know how we can add a member to a mathematical set ,for example :

C := NULL;

C := C, V, B, X;

print(C)

V, B, X

but, my problem is that how we can subtract a member from the defined set ?

 

 

Thanks,

 

Hello, i got the following problem. I have a function, say u(h,e) whith multiple exponents ((u(h,e))^(1/a))^a. As long as Maple does not know that u(h,e) is positiv it won't make the simplification and return u(h,e) as expected. From my view i have two possibilites to solve this problem:

1) Define u(h,e) to be positive. Sounds intuitive, but i didn't manage to find the right definition

2) Give maple the function e.g. u:=e+h^2 and simplify the epression in uneval quotes with assumption positive for e and h.

Whereas I have solution 2, the problem is that i would need excessive amounts of uneval quotes '' at the start of my worksheet, not to run out of them.

 

I definitly need my epressions in unevaluated forms and would be happy to hear any ideas.

Greetings, Fabian

 

Hello,

I'm trying to define a matrix that will have all the possible game results in a 9 team competition in one round. The results are a column in the form [game 1 home team, game 1 away team, game 2 home team, ... , game 9 away team]

This should give me a matrix with 18 rows, and 512 columns, where each column is a possible game result.

In essense, to continue the pattern of this matrix on for all 512 columns.

I've fiddled with for statements, but it ends up getting very messy given the number of nests that are required.

Thoughts? Any help would be much appreciated,

Thanks, Alex, Australia.

 

 

 

 

 

 

Is it possible to define and use an abstract linear operator L which is a function of y(x) and z(x)? 

For example, Maple should be able to recognise that L(y(x),z(x)) = L(z(x),y(x)) and simplify expressions such as 

L(c*y(x),d*z(x)) = c*d*L(y(x),z(x)) where c and d are constants or numbers.

It should also be able to expand things like L(c*y1(x)+d*y2(x),e*z1(x)+f*z2(x)).

Thanks.

Let a be som expression like
a:=t^2

Now how do I define a function using a.

f:=t->a
doesnt work

Hey!

I have this MATLAB script, but as I work in Maple, I'll need to translate it to Maple. 
I know how to define symbols and functions, but I don't know which Maple commands to use, of if it needs to be done in another way, so the problem is translating from " dZ = [dx; dy; ax; ay; dm];" and down.

Any help would truly be greatly appreciated! Thank you!  



This is the script:

function dZ = meteor_step(~, Z)

  P = 1.2; % initial atmospheric pressure
  H = 1.39E-4; % scale height of atm pressure
  E = 8.11131859E6; % evaporation energy
  D = 1; % drag constant
  G = 9.814; % acceleration due to gravity
  PM = 3.3E3; % density of the meteor
  
  S = 3.986E14; % standard gravitational parameter of Earth (G*M)
  R = 6.3674447E6; % radius of the Earth (meters)

  x = Z(1);  
  y = Z(2);
  dx = Z(3);
  dy = Z(4);
  m = Z(5);
  
  atm = P*exp(-y*H);

  v = sqrt(dx^2+dy^2);

  area = pi * ( (3*m)/(4*PM) )^(2/3);

  dist = sqrt(x^2+y^2);
  Gv = -9.8;

  accel = -(D*atm*area)/m*v;
  ax = accel * dx;
  ay = accel * dy + Gv;
  

  dm = -(atm*v^3*area)/(2*E);
  
  dZ = [dx; dy; ax; ay; dm];
  
end

 

 

 

 

[t, R] = ode45(@meteor_step, [0 250], [0, 100000, 100, -300, 25]);

x = R(:,1);
y = R(:,2);

dx = R(:,3);
dy = R(:,4);

v = (dx.^2+dy.^2).^(1/2);

m = R(:,5);

figure(1);
plot(t, y);
  title('Meteor Kinematics: Height vs Time');
  xlabel('Time elapsed (s)');
  ylabel('Height (m)');

figure(2);
plot(x, y);
  title('Meteor Kinematics: Horizontal vs Vertical Position');
  xlabel('Horizontal (m)');
  ylabel('Vertical (m)');

figure(3);
plot(t, v);
  title('Meteor Kinematics: Speed vs Time');
  xlabel('Time elapsed (s)');
  ylabel('Absolute speed (m/s)');

figure(4);
plot(t, m);
  title('Meteor Kinematics: Mass vs Time');
  xlabel('Time elapsed (s)');
  ylabel('Mass (kg)');

  
figure(5);
plot(t, dy);
  title('Vertical Velocity vs Time');
  xlabel('Time elapsed (s)');
  ylabel('Vertical velocity (m/s)');

temp = abs(y - 52900);
[~, index] = min(temp);
  
t(index)
dx(index)/1000
dy(index)/1000

Dear people in mapleprimes,

 

>define(INT, linear, conditional(INT(a::algebraic, X::name) = a*X, _type(a, freeof(X))), INT(X::name, X::name) = (1/2)*X^2);

>INT(2*x+4, x);

x^2 + 4*x

>INT(z+x, z);

(1/2)* z ^2+ x*z

is written in the help page of maple.

This code is to make a function INT.

What it means is that if INT(a::algebraic, x::name) then this is transformed into a*X, where a is independent from x.

And, INT(X::name,X::name) is transformed into (1/2)*X^2.

 

The first of what I want to ask you is the way of use of "_type", which is not in the help page, and as for names with "_" ahead, 

it is written that "_" means internal command for Maple, so not to use it. Is it right to use a name with "_" ahead of it here?

The second of what I want to know is the way to use "conditional."

Please teach me the meaning of this.

Thanks in advance.

 

I hope you will teach me the above questions.

 

Best wishes.

 

taro

 

 

Hi every Body?

I will define the function f(t) in maple,how?

f(t)=1-t for 0<t<10 and t for t>10

Hi everyone,

I have a question regarding the derivation of tensors/matrices.
Let's assume for simplicity, that I have a vector (6x1) s and a matrix A (6x6)defining Transpose(s)*Inverse(A)*s. From this function I want to calculate the derivative w.r.t. s. My approach would be

restartwith(Physics):
with(LinearAlgebra):
Define(s,A)

Diff(
Transpose(s)*Inverse(A)*s, s)

As a result I get

though I'd rather expect something like Inverse(A)*s + Transpose(s)*Inverse(A)

Now as I'm pretty new to Maple, I can imagine that my approach is wrong, but I don't know any better and can't seem to get any information out of the help documents.

Thanks in advance for any of your suggestions!

1 2 3 4 Page 1 of 4