Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 32 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

You'll need to show an example of it not producing printout.

@brian bovril With the same initial error: error (in ModuleApply) index must evaluate to a name when indexing a module? Sorry, but I have no way of testing this; I'll need your help to debug it.

I don't have an idea yet how to do it, and this wouldn't make it any easier or harder, but I noticed that your code doesn't use the d3 that you defined. So, do you need to change the plot to include d3?

@Ramakrishnan There are some differences between `if` and if:

  • `if` is a builtin procedure. It always takes exactly 3 arguments and (like any procedure) it always returns a value. It's name is in quotes because if is a reserved word. In the call `if`(BC, TV, FV)BC is a boolean condition: something that will evaluate to true or falseTV is the expression which will be evaluated and returned if BC is trueFV will be returned if BC is false. You may use ifelse in place of `if` in case you don't like quotes.
  •  if ... then ... is a statement. It may or may not return a value. It may or may not have an else clause.

Yes, you can make an assignment using `if` (or any other procedure call) before the call to SetProperty.

@brian bovril Odd. Do you have Maple 2018 initial release, or release 1? I have release 1, and the code still works for me. I thought that my use of thismodule with an abstract index was too good to be true! I'll post corrected code in a few minutes. 

And here it is: FoxesAndRabbits.mw

@vv Re "undefined": I was just giving an example, not trying to cover every case. To me more complete, I'll change "undefined function symbol" to "unevaluated function[*1] or function whose zeroth operand is undefined." Your Beta(...is an unevaluated function, and your `&+`(...is a function whose 0th operand is undefined. Your other 4 examples

['''f''', A](x), `[]`('''f''', A)(x), `+` ('''f''', A)(x), `or`('''f''', A)(x);

are not functions (because they get evaluated immediately).

Re (builtin) evalapply: No, it's the actions of evalapply on non-functions that are builtin. These are mostly trivial and documented minimally at ?evalapply. It's just that we can't see the code. I think that in all cases where a function is used as the 0th operand of another function, the expression is evaluated by a Maple-coded `evalapply/...procedure. For example, see `evalapply/D`.

Re `evalapply/[]`: It's ignored because neither [a,b] nor `[]`(a,b) (after its immediate evaluation) are functions. But if you force `[]` to return unevaluated, then it is a function, and `evalapply/[]` applies; as shown in this example:

restart:
ListDeconstruct:= L-> '`[]`'(L[]):
ListDeconstruct([a,b])(x);
                          [](a, b)(x)
`evalapply/[]`:= (`[](...)`, X)-> map(`?()`, `[](...)`, X):
ListDeconstruct([a,b])(x);
                         [](a(x), b(x))

[*1]When I type anything in inline boldface in MaplePrimes, it is either actual Maple code, or a term that is being used strictly as it is literally used in Maple code (as opposed to, for example, Maple documentation or common CompSci or mathematical English). So, when I type function, I'm strictly referring objects f such that type(f, function) is true

@mmcdara I would agree with you about that in general, but that situation does not occur in this problem. That minimum cell-size restriction of 5 applies to the expected cells, not to the observed cells. In this problem, the expected cell sizes are 

< 16, 10, 24;
      8,  5, 12 >
.

I've also implemented Yates's continuity correction to Pearson's test and Fisher's exact test. I'll be posting those shortly.

@phbmc I know that it's probably the principle of the thing, but I would guess that checking all 55 candidates could be done faster than solving even 1 equation, let alone 26.

I don't understand this statement: 

  • Solving L[4] = R[2] in the equations I gave above yields the solutions a1 = 3b/5 and a2 = (4b-5)/5

How can solving 1 equation provide solutions for 2 variables?

@Christian Wolinski What you have is an obfuscated example where you're doing some crazy type of recursion with unevalution quotes and partial evals. You could do the same type of thing in Maple V[*1]; maybe the syntax required for it was slightly different then. Unevaluation quotes were then and are now the most awkward part of the language.

What kind of practical thing do you want to do that this behavior is preventing?

Symbolics is alive and strong is Maple, and new symbolic features are added nearly every release. Great recent additions include subsindets and evalindets, inert operators and the InertForm package, objects, and overloadable operators.

[*1]My first Maple version was Maple V r4. Perhaps there existed r1, r2, and/or r3 where unevaluation quotes behaved substantially differently.

@vv I didn't say that the behavior of `or` was a natural and logical result of the overall design! I didn't say anything at all about `or`. We already know that `or` and `and` evaluate weirdly from another recent thread. It's the application of a list as a function that I was referring to as natural and logical.

Regarding `&+`: It's just an undefined function symbol; you might as well replace it with foo; the behavior is the same. In order for an undefined function to have any behavior when it itself is applied as a function, you must define a procedure `evalapply/foo` to describe the behavior.

@Zeineb You must be using a Maple version from before when one-argument add was introduced. In the future, please put your Maple version in your Question headers using the pull-down provided for that purpose. Here's a retrofit for the add error:

ChiSqIndTest:= proc(O::Matrix, {method::identical(Pearson, G):= 'Pearson'})
description "Returns p-value for Pearson's or G chi-squared independence test.";
option
   author= "Carl Love <carl.j.love@gmail.com>, 25-Oct-2018",
   reference= (
      "https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test",
      "https://en.wikipedia.org/wiki/G-test"
   )
;
uses AT= ArrayTools, St= Statistics;
local 
   C:= AT:-AddAlongDimension(O,1), R:= AT:-AddAlongDimension(O,2), #column & row sums
   r:= numelems(R), c:= numelems(C), #count of rows & columns
   x, 
   #matrix of expected values under null hypothesis (independence):
   T:= Matrix((r,c), (i,j)-> R[i]*C[j], datatype= float) / add(x, x= R)
;
   #p-value by either method:
   1 - St:-CDF(
      ChiSquare((r-1)*(c-1)), 
      add(x, x= `if`(method='G', 2*O*~ln~(O/~T), (O-T)^~2 /~ T))
   )
end proc:

 

@Rohith 

As I've mentioned before, the whole point of making expressions into strings is to avoid automatic simplification. If an expression already exists as a mathematical expression (rather than as a string) in Maple's memory, then it's certain that automatic simplification has already occurred. If you must work with expressions that are already in Maple's memory, then it's impossible for this entire project to work exactly to your specifications. I'm sorry that this point was not made more clear to you earlier, but I did try.

It is not the module that changes a - c*d to -c*d + a; it's the automatic simplification.

To summarize and re-emphasize the key points:

  1. When you enter an expression into Maple other than as a string, that expression will very often be altered into a form that Maple views as mathematically equivalent but more convenient for it to store.
  2. Some automatic simplifications (such as rational-number arithmetic) will always happen and are easily predictable; others (such as ordering of polynomial terms or ordering of factors within terms) depend on what Maple already has stored for that session, and are more difficult to predict.
  3. You cannot stop or control this process: It is a fundamental part of how Maple works, and it always has been.

@Zeineb Yes, you are right about the denominator. Thank you for correcting. I have corrected the original.

@DEBA I can see a little link like a postage stamp in the lower left corner of your most-recent Reply, but it doesn't take me anywhere.

For part (d), you'll need a pair of differential equations, one for the sum of the signed horizontal (or x) forces (propulsion and drag) and one for the sum of the signed vertical (or y) forces (lift and weight). After you have these, getting Maple to do the Euler-method part is trivial (so don't worry about that part, I'll show you everything). So, can you enter those differential equations? If not, I can give some hints for that.

First 298 299 300 301 302 303 304 Last Page 300 of 709