mmcdara

7891 Reputation

22 Badges

9 years, 54 days

MaplePrimes Activity


These are replies submitted by mmcdara

@janhardo 

I'd never thought of defining a new type this way. (I always use TypeTools[AddType]).
Thanks for the tip.

@nm 

Thanks for having shared your experience

@nm 

Thanks.

What do you usually use when you want to check if an expression has a given compound/structured type?

@nm 

I hadn't  thought of using the debugger.
Indeed an excellent idea, I'm going to try and see what I can get out of it.

Thank you very much.

@salim-barzani 

The "Big Sum" over i, j, ...m, n should be written as a summation over all n tuples (i, ..., n) which verify several conditions.
For whatever reason the authors of this paper have prefered not to account for these conditions to write this "Big Sum".
But the price to pay is that they have to divide its result by 2M*M! : the attached file (try to) explains where this corrective term comes from.

explanation.mw

@dharr 

Sure, you're right.
Thanks for the corrrection (and your vote)

@salim-barzani 

They did not remove it.
Just take the second term in fN

(1/2)*Sum(Bi,j) where the sum is over i=1..N and j=1..N

Then each Bi, j is counted twice, for instance B1, 2 and B2, 1 ; so, because B indices are ordered as the extended expressions of fand fshow, you have to divide the sum by 2.
The otheroption is to rewrite this sum (and all the other ones) this way

Sum(Bi,j) where the sum is over i=1..N-1 and j=i+1..N

@nm 

Thank you nm.

I have seen the  Quantities:-Dispatch  stuff but it seems impossible to go further.

I often observed that it was more efficient to assess numerically the expectation of a random variable Y by using evalf/Int instead of Mean every time it's possible

The only reference to the Grid package that can be found in ?module (open Pages That Link to This Page) refers to Grid:-Send

?Grid:-Send says "The msg parameter can be an arbitrary Maple expression including NULL and expression sequences.  Nested structures that contain expressions with last name evaluation rules, like modules, will not send the fully evaluated sub-expression."

Could it be that this restriction operates to the other Grid procedures?

@salim-barzani 

Your worksheet contains two restart commands.
I thought you would have understood that I considered only the code which follow the second restart (I wasn't clear enoughabout that). So, when I title my reply "Is this useful" this means "Is this useful to answer the question you asked AFTER the 2nd restart".

In order to avoid such confusion I strongly suggest you not to write multiple restart commans in the same worksheet in the future.

As I use only Maple 2015 some syntaxes you use are not supported and I don't have time right now to adapt them.
So there is a simple advice: did you try printing the quantity you want to plot before even trying to plot them?

I tell you that because f1(x) should be onstructed (through dsolve) after f0(x) has been.
But the boundary conditions on f0(x) depend on f1(1) and this latter is going to remain in the ode that 
 f1(x) is aimed to verify... which will probably raise some problems...

@segfault 

As a rule a trigonometric expression built with sine finctions only is not the most concise way to represent it.
Once said, here is a procedure which seems to do the job

restart

S := proc(expr)
  local T_expr, S_expr:
  if map2(op, 0, indets(expr, function)) = {sin} then
    return expr
  else
    T_expr := convert(expr, tan):
    S_expr := eval(T_expr, tan = (u -> sin(u)/sqrt(1-sin(u)^2))):
    return simplify(S_expr, size)
  end if:
end proc:

expr:=cos(x)+sin(x)+x+tan(2*x)+sec(x)+csc(x)+cot(x)+sin(x)/cos(x)+exp(2*cos(x));
S(expr);

cos(x)+sin(x)+x+tan(2*x)+sec(x)+csc(x)+cot(x)+sin(x)/cos(x)+exp(2*cos(x))

 

(-2*sin((1/2)*x)^4+3*sin((1/2)*x)^2-1)/(-1+sin((1/2)*x)^2)+(-2*sin((1/2)*x)^3+2*sin((1/2)*x))/(1-sin((1/2)*x)^2)^(1/2)+x+sin(2*x)/(1-sin(2*x)^2)^(1/2)+(1-sin((1/2)*x)^2)/(2*sin((1/2)*x)^4-3*sin((1/2)*x)^2+1)-(1-sin((1/2)*x)^2)^(1/2)/(2*sin((1/2)*x)^3-2*sin((1/2)*x))+(1-sin(x)^2)^(1/2)/sin(x)+sin(x)/(1-sin(x)^2)^(1/2)+exp((-4*sin((1/2)*x)^4+6*sin((1/2)*x)^2-2)/(-1+sin((1/2)*x)^2))

(1)

expr:=cos(x)^3+sin(x)+1/tan(2*x);
S(expr)

cos(x)^3+sin(x)+1/tan(2*x)

 

-(2*sin((1/2)*x)^2-1)^3+(-2*sin((1/2)*x)^3+2*sin((1/2)*x))/(1-sin((1/2)*x)^2)^(1/2)+(1-sin(2*x)^2)^(1/2)/sin(2*x)

(2)

S(cos(x))

-2*sin((1/2)*x)^2+1

(3)

S(sin(2*x))

sin(2*x)

(4)
 

 

Download Into_Sine.mw

TIP: map(normal, S(expr)) may give a slightly more concise expression

@FZ 

Please look to theattached files.

@salim-barzani 

those two expressions
 

normal(b12);

map(normal, b12);  # which normalises each operator in b12 and will help you 
                   # understand while the denominators vanish

 

@salim-barzani 

read carefully the last lines if this file
 

restart

``

f := 1+exp(eta[1])+b[1, 2]*exp(eta[1]+eta[2])+exp(eta[2])+b[2, 3]*exp(eta[2]+eta[3])+b[1, 2]*b[1, 3]*b[2, 3]*exp(eta[1]+eta[2]+eta[3])+b[1, 3]*exp(eta[1]+eta[3])+exp(eta[3])

1+exp(eta[1])+b[1, 2]*exp(eta[1]+eta[2])+exp(eta[2])+b[2, 3]*exp(eta[2]+eta[3])+b[1, 2]*b[1, 3]*b[2, 3]*exp(eta[1]+eta[2]+eta[3])+b[1, 3]*exp(eta[1]+eta[3])+exp(eta[3])

(1)

lprint(f)

1+exp(eta[1])+b[1, 2]*exp(eta[1]+eta[2])+exp(eta[2])+b[2, 3]*exp(eta[2]+eta[3])+b[1, 2]*b[1, 3]*b[2, 3]*exp(eta[1]+eta[2]+eta[3])+b[1, 3]*exp(eta[1]+eta[3])+exp(eta[3])

 

C := proc (i, j) options operator, arrow; b[i, j] = (k[i]-k[j]+(k[i]-k[j])^2)/(k[i]-k[j]) end proc

proc (i, j) options operator, arrow; b[i, j] = (k[i]-k[j]+(k[i]-k[j])^2)/(k[i]-k[j]) end proc

(2)

b12 := normal(eval(f, C(1, 2)));

exp(eta[1]+eta[2]+eta[3])*b[1, 3]*b[2, 3]*k[1]-exp(eta[1]+eta[2]+eta[3])*b[1, 3]*b[2, 3]*k[2]+b[1, 3]*b[2, 3]*exp(eta[1]+eta[2]+eta[3])+exp(eta[1]+eta[2])*k[1]-exp(eta[1]+eta[2])*k[2]+b[2, 3]*exp(eta[2]+eta[3])+b[1, 3]*exp(eta[1]+eta[3])+exp(eta[1])+exp(eta[1]+eta[2])+exp(eta[2])+exp(eta[3])+1

(3)

b23 := normal(eval(f, C(2, 3)));

exp(eta[1]+eta[2]+eta[3])*b[1, 2]*b[1, 3]*k[2]-exp(eta[1]+eta[2]+eta[3])*b[1, 2]*b[1, 3]*k[3]+b[1, 2]*b[1, 3]*exp(eta[1]+eta[2]+eta[3])+b[1, 2]*exp(eta[1]+eta[2])+exp(eta[2]+eta[3])*k[2]-exp(eta[2]+eta[3])*k[3]+b[1, 3]*exp(eta[1]+eta[3])+exp(eta[1])+exp(eta[2])+exp(eta[2]+eta[3])+exp(eta[3])+1

(4)

b13 := normal(eval(f, C(1, 3)));

exp(eta[1]+eta[2]+eta[3])*b[1, 2]*b[2, 3]*k[1]-exp(eta[1]+eta[2]+eta[3])*b[1, 2]*b[2, 3]*k[3]+b[1, 2]*b[2, 3]*exp(eta[1]+eta[2]+eta[3])+b[1, 2]*exp(eta[1]+eta[2])+b[2, 3]*exp(eta[2]+eta[3])+exp(eta[1]+eta[3])*k[1]-exp(eta[1]+eta[3])*k[3]+exp(eta[1])+exp(eta[2])+exp(eta[1]+eta[3])+exp(eta[3])+1

(5)

# More generally

Rewrite := (i, j) -> assign( (b||i||j), normal(eval(f, C(i,j))) ):

b12 := 'b12':
Rewrite(1, 2):
b12;

exp(eta[1]+eta[2]+eta[3])*b[1, 3]*b[2, 3]*k[1]-exp(eta[1]+eta[2]+eta[3])*b[1, 3]*b[2, 3]*k[2]+b[1, 3]*b[2, 3]*exp(eta[1]+eta[2]+eta[3])+exp(eta[1]+eta[2])*k[1]-exp(eta[1]+eta[2])*k[2]+b[2, 3]*exp(eta[2]+eta[3])+b[1, 3]*exp(eta[1]+eta[3])+exp(eta[1])+exp(eta[1]+eta[2])+exp(eta[2])+exp(eta[3])+1

(6)

simplify((3)-(6))

0

(7)

# You are wrong, k[i] terms are present, for instance:

indets(b12, name)

{b[1, 3], b[2, 3], eta[1], eta[2], eta[3], k[1], k[2]}

(8)

# with normal removed

Rewrite := (i, j) -> assign( (b||i||j), eval(f, C(i,j)) ):
b12 := 'b12':
Rewrite(1, 2):
b12

1+exp(eta[1])+(k[1]-k[2]+(k[1]-k[2])^2)*exp(eta[1]+eta[2])/(k[1]-k[2])+exp(eta[2])+b[2, 3]*exp(eta[2]+eta[3])+(k[1]-k[2]+(k[1]-k[2])^2)*b[1, 3]*b[2, 3]*exp(eta[1]+eta[2]+eta[3])/(k[1]-k[2])+b[1, 3]*exp(eta[1]+eta[3])+exp(eta[3])

(9)

 


 

Download m1_mcdara.mw

First 6 7 8 9 10 11 12 Last Page 8 of 154