Ronan

1381 Reputation

16 Badges

13 years, 331 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@Christian Wolinski Thank you. That produces the lists nicely. I admit I don't understand the ListTools part of the code. Could you please explain it? I did look in the Help on it but right now don't quite get it.
  There is some error  in the last line of the code.  I presume it is intended to maintain the order of the lists under addition.


 

restart

pn := expand((a[1]+a[2]+a[3]+a[4])^5)

a[1]^5+5*a[1]^4*a[2]+5*a[1]^4*a[3]+5*a[1]^4*a[4]+10*a[1]^3*a[2]^2+20*a[1]^3*a[2]*a[3]+20*a[1]^3*a[2]*a[4]+10*a[1]^3*a[3]^2+20*a[1]^3*a[3]*a[4]+10*a[1]^3*a[4]^2+10*a[1]^2*a[2]^3+30*a[1]^2*a[2]^2*a[3]+30*a[1]^2*a[2]^2*a[4]+30*a[1]^2*a[2]*a[3]^2+60*a[1]^2*a[2]*a[3]*a[4]+30*a[1]^2*a[2]*a[4]^2+10*a[1]^2*a[3]^3+30*a[1]^2*a[3]^2*a[4]+30*a[1]^2*a[3]*a[4]^2+10*a[1]^2*a[4]^3+5*a[1]*a[2]^4+20*a[1]*a[2]^3*a[3]+20*a[1]*a[2]^3*a[4]+30*a[1]*a[2]^2*a[3]^2+60*a[1]*a[2]^2*a[3]*a[4]+30*a[1]*a[2]^2*a[4]^2+20*a[1]*a[2]*a[3]^3+60*a[1]*a[2]*a[3]^2*a[4]+60*a[1]*a[2]*a[3]*a[4]^2+20*a[1]*a[2]*a[4]^3+5*a[1]*a[3]^4+20*a[1]*a[3]^3*a[4]+30*a[1]*a[3]^2*a[4]^2+20*a[1]*a[3]*a[4]^3+5*a[1]*a[4]^4+a[2]^5+5*a[2]^4*a[3]+5*a[2]^4*a[4]+10*a[2]^3*a[3]^2+20*a[2]^3*a[3]*a[4]+10*a[2]^3*a[4]^2+10*a[2]^2*a[3]^3+30*a[2]^2*a[3]^2*a[4]+30*a[2]^2*a[3]*a[4]^2+10*a[2]^2*a[4]^3+5*a[2]*a[3]^4+20*a[2]*a[3]^3*a[4]+30*a[2]*a[3]^2*a[4]^2+20*a[2]*a[3]*a[4]^3+5*a[2]*a[4]^4+a[3]^5+5*a[3]^4*a[4]+10*a[3]^3*a[4]^2+10*a[3]^2*a[4]^3+5*a[3]*a[4]^4+a[4]^5

Q := proc (E) local X; if type(E, `+`) then X := ([op])('E') else X := ['E'] end if; ListTools:-Categorize(proc (x, y) lcoeff(x) = lcoeff(y) end proc, X) end proc

proc (E) local X; if type(E, `+`) then X := ([op])('E') else X := ['E'] end if; ListTools:-Categorize(proc (x, y) lcoeff(x) = lcoeff(y) end proc, X) end proc

Q(pn)

[a[1]^5, a[2]^5, a[3]^5, a[4]^5], [5*a[1]^4*a[2], 5*a[1]^4*a[3], 5*a[1]^4*a[4], 5*a[1]*a[2]^4, 5*a[1]*a[3]^4, 5*a[1]*a[4]^4, 5*a[2]^4*a[3], 5*a[2]^4*a[4], 5*a[2]*a[3]^4, 5*a[2]*a[4]^4, 5*a[3]^4*a[4], 5*a[3]*a[4]^4], [10*a[1]^3*a[2]^2, 10*a[1]^3*a[3]^2, 10*a[1]^3*a[4]^2, 10*a[1]^2*a[2]^3, 10*a[1]^2*a[3]^3, 10*a[1]^2*a[4]^3, 10*a[2]^3*a[3]^2, 10*a[2]^3*a[4]^2, 10*a[2]^2*a[3]^3, 10*a[2]^2*a[4]^3, 10*a[3]^3*a[4]^2, 10*a[3]^2*a[4]^3], [20*a[1]^3*a[2]*a[3], 20*a[1]^3*a[2]*a[4], 20*a[1]^3*a[3]*a[4], 20*a[1]*a[2]^3*a[3], 20*a[1]*a[2]^3*a[4], 20*a[1]*a[2]*a[3]^3, 20*a[1]*a[2]*a[4]^3, 20*a[1]*a[3]^3*a[4], 20*a[1]*a[3]*a[4]^3, 20*a[2]^3*a[3]*a[4], 20*a[2]*a[3]^3*a[4], 20*a[2]*a[3]*a[4]^3], [30*a[1]^2*a[2]^2*a[3], 30*a[1]^2*a[2]^2*a[4], 30*a[1]^2*a[2]*a[3]^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]^3+30*a[2]^2*a[3]^2*a[4]+30*a[2]^2*a[3]*a[4]^2+10*a[2]^2*a[4]^3+5*a[2]*a[3]^4+20*a[2]*a[3]^3*a[4]+30*a[2]*a[3]^2*a[4]^2+20*a[2]*a[3]*a[4]^3+5*a[2]*a[4]^4+a[3]^5+5*a[3]^4*a[4]+10*a[3]^3*a[4]^2+10*a[3]^2*a[4]^3+5*a[3]*a[4]^4+a[4]^5

"  (add@map)(proc(E) (lcoeff(E))*normal(E/lcoeff(E)) end@add, [Q(expand(pn))]);  #`some typo here end@add, Don't know how to correct at present`"

Error, invalid proc termination

"  (add@map)(proc(E) (lcoeff(E))*normal(E/lcoeff(E)) end@add, [Q(expand(pn))]);  #`some typo here end@add, Don't know how to correct at present`"

Just my experimentation

([op])(pn)

[a[1]^5, 5*a[1]^4*a[2], 5*a[1]^4*a[3], 5*a[1]^4*a[4], 10*a[1]^3*a[2]^2, 20*a[1]^3*a[2]*a[3], 20*a[1]^3*a[2]*a[4], 10*a[1]^3*a[3]^2, 20*a[1]^3*a[3]*a[4], 10*a[1]^3*a[4]^2, 10*a[1]^2*a[2]^3, 30*a[1]^2*a[2]^2*a[3], 30*a[1]^2*a[2]^2*a[4], 30*a[1]^2*a[2]*a[3]^2, 60*a[1]^2*a[2]*a[3]*a[4], 30*a[1]^2*a[2]*a[4]^2, 10*a[1]^2*a[3]^3, 30*a[1]^2*a[3]^2*a[4], 30*a[1]^2*a[3]*a[4]^2, 10*a[1]^2*a[4]^3, 5*a[1]*a[2]^4, 20*a[1]*a[2]^3*a[3], 20*a[1]*a[2]^3*a[4], 30*a[1]*a[2]^2*a[3]^2, 60*a[1]*a[2]^2*a[3]*a[4], 30*a[1]*a[2]^2*a[4]^2, 20*a[1]*a[2]*a[3]^3, 60*a[1]*a[2]*a[3]^2*a[4], 60*a[1]*a[2]*a[3]*a[4]^2, 20*a[1]*a[2]*a[4]^3, 5*a[1]*a[3]^4, 20*a[1]*a[3]^3*a[4], 30*a[1]*a[3]^2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a[1]^2*a[2]^2*a[4], 30*a[1]^2*a[3]*a[4]^2, 30*a[1]^2*a[3]^2*a[4], 20*a[1]^3*a[2]*a[3], 20*a[1]^3*a[2]*a[4], 20*a[1]^3*a[3]*a[4], 20*a[2]*a[3]*a[4]^3, 30*a[2]*a[3]^2*a[4]^2, 20*a[2]*a[3]^3*a[4], 30*a[2]^2*a[3]*a[4]^2, 30*a[2]^2*a[3]^2*a[4], 20*a[2]^3*a[3]*a[4], 60*a[1]*a[2]*a[3]*a[4]^2, 60*a[1]*a[2]*a[3]^2*a[4], 60*a[1]*a[2]^2*a[3]*a[4], 60*a[1]^2*a[2]*a[3]*a[4]}

NULL


 

Download 30-7-22_Q_sort_equation_by_numerical_coeffs_ver_2.mw

@Ronan Sorry about that! 

@Carl Love Ok so I see now.  Just tested it this way

(f, (E, V) -> V)(expand(A), exp(T))  gives  f(A, exp(T)), exp(T)

 

@Christian Wolinski Very nice solution. I don't quite get the technicality of the (E,V)->V So E=expand(A) and V =exp(T) in this case and somehow (solve,((E,V)->V))(expand(A),exp(T))  includes exp(T) in the answer.   I notice the " " after solve and the enclosing (....) are necessary.  I did check through help but didn't see an explination. Of course maybe I missed that.

Edit:- I see that (E,V)->V))(expand(A),exp(T)   is eqivalent to 

f := (E, V) -> V;

f(expand(A), exp(T));

@Carl Love Can you explain what index means in relation to solve? 

@Carl Love You are correct.  It took me a while to remenber the syntax to use.

 Interesting problem.  So I gather there are "s" nested summation loops. I asked a question a few months ago that required with a variable number of summation loops. @Carl Love answered it.

Is it possible to Add/sum by mapping multiple values from a list - MaplePrimes

So just to clarify can t[j] and t[i]  be replaced with T[j] , T[i] to totaly distinguish them from t?

I presume the inputs are M and s.

 Edit:-On problems like this a I start with small values for s and M and build the nested summations/products to handle them before trying for the total solution. I attach  document to see if my begining intrepertations are correct.


 

restart

NULL

`#mover(mi("l"),mo("˜"))` := proc (t) options operator, arrow; sum(beta[j, s]*t^(M-1-s), s = 0 .. M-1) end proc

proc (t) options operator, arrow; sum(beta[j, s]*t^(M-1-s), s = 0 .. M-1) end proc

(1)

eval(`#mover(mi("l"),mo("˜"))`(t), M = 5)

t^4*beta[j, 0]+t^3*beta[j, 1]+t^2*beta[j, 2]+t*beta[j, 3]+beta[j, 4]

(2)

T[j], T[i] := j/(M-1), i/(M-1)

j/(M-1), i/(M-1)

(3)

beta[j, 0] := 1/((product(T[j]-T[i], i = 0 .. j-1))*(product(T[j]-T[i], i = j+1 .. M-1)))

(-1)^(j+1)*(1/(M-1))^(j+1)/(GAMMA(j+1)*(M-1)^(-j)*(-1)^M*GAMMA(-j+M)*(1/(M-1))^M)

(4)

eval(beta[j, 0], [M = 5, j = 3])

-128/3

(5)

``

eval(`#mover(mi("l"),mo("˜"))`(t), [M = 5, j = 3])

t^4*beta[3, 0]+t^3*beta[3, 1]+t^2*beta[3, 2]+t*beta[3, 3]+beta[3, 4]

(6)

``


 

Download 28-3-22_A_repetative_summation.mw

 

@Ali2020 The document stated "I do not know how you achieved your resuls". As they are listed vertically they could come from a loop. That is all.

@max125 Opps.. I post my revised answer here. Makes the answer simpler.

restart

with(RealDomain)

[Im, Re, `^`, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, cos, cosh, cot, coth, csc, csch, eval, exp, expand, limit, ln, log, sec, sech, signum, simplify, sin, sinh, solve, sqrt, surd, tan, tanh]

(1)

f := proc (x) options operator, arrow; 6-sqrt(-x^2+8*x+9) end proc

proc (x) options operator, arrow; 6-RealDomain:-sqrt(-RealDomain:-`^`(x, 2)+8*x+9) end proc

(2)

g := unapply(diff(f(x), x), x)

proc (x) options operator, arrow; -(1/2)*(-2*x+8)/(-x^2+8*x+9)^(1/2) end proc

(3)

plot([f(x), g(x)])

 

``

 

 

L := int(f(x), x = 0 .. l)

-6-(25/2)*arcsin(4/5)+6*l-(1/2)*(-l^2+8*l+9)^(1/2)*l+2*(-l^2+8*l+9)^(1/2)-(25/2)*arcsin((1/5)*l-4/5)

(4)

l := fsolve(L = 10)

6.810993081

(5)

L

21.59119024-(25/2)*arcsin(4/5)

(6)

evalf(%)

10.00000002

(7)

NULL

Download 23-3-22_A1_integration.mw

@nm I would just install over it.  Only when I have a big problem do I "clean" a program out of a computer.

@dharr Oh.  I didn't realist that about view. Very simple.

@vv Yes I hit that. Couldnt fix it so I copied and pasted the answer.

@Carl Love Answer is much neater.

@dharr , @tomleslie   Thanks. I had tried Null. Forgot about the all caps.

 

@Carl Love That is good. My old attempt cripples the graphics on the computer.

@acer Excellent diagnosis That looks like what happened.  I will fix it during the week and let you know.

So, in this case ooes the "DirectSearch.mla" now contain the DirectSearch, RationalTrigonometry and RonanRoutines packages?

First 16 17 18 19 20 21 22 Last Page 18 of 33