Carl Love

Carl Love

28045 Reputation

25 Badges

12 years, 334 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

You should use userinfo instead of print: It gives you finer control over the format, and you can turn it on and off externally. Once a program is instrumented with userinfo statements for debugging, they'll never need to be removed. 

Egads, that's horrible. The command should be simply deleted ASAP until it can be replaced by a competent command. This crap serves no useful purpose in this state, and it's doing more harm than good. Not only does it give the wrong idea about limits, it also gives the wrong idea about symbolic computation. Perhaps Maplesoft should have a review panel of professional educators, and any "tutor" would need to be approved by them before being released . 

A vote up for your muck-raking efforts. 

@Kitonum The function to be plotted doesn't need to be a procedure if you nullify the true labels by including the option labels= [``$3] in the plot3d command.

@Muhammad Usman Use the three-argument form of coeff:

for i from 0 to Equation do
   C[i]:= coeff(u, x, i) = coeff(f, x, i)
end do:

@umar khan There are no real values of r such that v is also real.

@Joe Riel There's also ArrayTools:-IsZero.

The index spec in the rtable_scanblock command can be shortened to [i, ..].

@vv I modifed the code for the animation so that the memory usage is only 20M.

@Christopher2222 No, is won't work in this case. AFAIK, there are no cases where the default boolean evaluator returns a truefalse result and is returns a different result. Sometimes is can make finer distinctions in cases where the default evaluator returns an ambiguous result. That's not the case here: The default evaluator returns false because the addresses of the vectors are different; it couldn't care less about the contents of the vectors---it only checks addresses. The situation would be different if one were comparing lists rather than vectors. The evaluator still just checks addresses, but because of the way that Maple stores lists, lists that are equal are necessarily stored at the same address. How's that? When new lists (and many other structures) are created, they are compared against existing lists for matches in a part of Maple called the "simplification table." (See the "Simplification Table" section in Appendix A of the Maple Programming Guide.) That's part of the reason why it's inefficient to iteratively lenghten lists (or sequences, or sets).

@student_md You wrote:

  • limit(sum(diff(Fn,Xn)*Xn,n=1..N),N=infinity)

If this expression makes sense at all, then it's equivalent to

sum(diff(F[n], X[n])*X[n], n= 1..infinity);

But I think that having an infinite number of X's is quite odd.

@umar khan You say that you want to "iterate" P(r) to find the root. That type of low-level operation is usually not necessary in Maple. The main command for finding roots is fsolve. It does the iterating in the background.

@Preben Alsholm I'm using Digits = 15. Is that perhaps the cause of the difference?

@Axel Vogt Symbolic dsolve automatically converts floats to fractions unless you explicitly tell it not to by using option convert_to_exact= false.

There is no attachment to your Question.

@Christian Wolinski In modern Maple, the above procedure can be simplified to

H:= proc() try args[[op](procname)] catch: 'procname'(args) end try end proc:

That's about as close to builtin as you can get. I think that that'll work in any version after and including Maple 6.

@brian bovril It's pretty trivial: Just a one-line for loop is needed. Here's the whole worksheet again, with the additional information at the end.
 

restart:

#Adjustment factors:
AdjFact:= Record(
   ':-Wmu'= 5,    ':-Wsigma'= -7, #winner's factors
   ':-Lmu'= -100, ':-Lsigma'= -60 #loser's factors
):

RC:= proc(W::record(mu,sigma), L::record(mu,sigma))
local
   t,
   dist:= evalf@unapply(Statistics:-CDF(Normal(W:-mu, W:-sigma), t), t),
   postW:= Record(
      ':-mu'= W:-mu + AdjFact:-Wmu*dist(W:-mu),
      ':-sigma'= W:-sigma + AdjFact:-Wsigma*dist(W:-mu)
   ),
   postL:= Record(
      ':-mu'= L:-mu + AdjFact:-Lmu*dist(L:-mu),
      ':-sigma'= L:-sigma + AdjFact:-Lsigma*dist(L:-mu)
   )
;
   userinfo(
      1, RC,
      sprintf(
         "Winner = %d +- %d; Loser = %d +- %d.",
         round~([postW:-mu, postW:-sigma, postL:-mu, postL:-sigma])[]
      )
   );
   postW, postL
end proc:

Update:= proc(
   Standings::table,
   Games::list([{name,string}, {name,string}]),
   {inplace::truefalse:= true}
)
local
   R:= `if`(inplace, Standings, copy(Standings)),
   G
;
   for G in Games do
      if assigned(R[G[1]]) and assigned(R[G[2]]) then
         (R[G[1]], R[G[2]]):= RC(R[G[1]], R[G[2]])
      else
         error "Player %1 or %2 not found in Standings", G[]
      end if
   end do;
   `if`(inplace, [][], eval(R))
end proc:
      

#Example usage (using exactly the same scenario as you did):

#Initial standings ("laws"):
Standings:= table([
   A1= Record(mu= 1007, sigma= 47),
   A2= Record(mu= 806,  sigma= 42),
   B1= Record(mu= 1163, sigma= 81),
   B2= Record(mu= 816,  sigma= 44)
]):

#Account of wins\losses (in each pair, the first member defeats the second):
Games:= [[B1,A1], [A1,B2], [B1,A2], [A2,B2]]:

#infolevel[RC]:= 1:

NewStandings:= Update(Standings, Games, inplace= false):

<op(eval(NewStandings))>;

Vector[column]([[A2 = Record(mu = 808.499824704434, sigma = 38.4998948226602)], [A1 = Record(mu = 1006.79431881513, sigma = 41.8765912890772)], [B1 = Record(mu = 1168.00000000000, sigma = 74.0000000000000)], [B2 = Record(mu = 756.590048730233, sigma = 8.3540292381394)]])

#Calculate change in means:
for P in indices(Standings, nolist) do
   printf("%a: %+d\n", P, round(NewStandings[P]:-mu - Standings[P]:-mu))
end do:

A2: +2

A1: +0
B1: +5
B2: -59

NULL


 

Download UpdateStandings.mw

First 369 370 371 372 373 374 375 Last Page 371 of 709