Mac Dude

1556 Reputation

17 Badges

13 years, 250 days

MaplePrimes Activity


These are replies submitted by Mac Dude

@Preben Alsholm and PatrickT

I4xx:=

(sorry, is messy & I don't know how to make this clean...).

collect(I4xx,sqrt) does nothing, as expected.

collect(I4xx,sqrt(2-2*cos(mux)));

gives

Error, (in collect) cannot collect (2-2*cos(mux))^(1/2)

factor() is not liked either.

The difference to your examples is of course that under the root I have an expression rather than a simple name. I can see that maybe I could write a wrapper replacing the argument under the root with a temporary name and then reverting that after the manipulation is done, but that seems unnecessarily clumsy for an operation that must be an often-performed one.

M.D.

@Alejandro Jakubi 

Well, inttrans is for integral transformations like Laplace or Fourier transforms. So I do not see that work for general integrals, though maybe for integrals that are best solved using these transformations anyway. I was looking at compiletable, but using that may require a significant amount of "glue code" to prepend it to the general integrator.

So I guess I was probably in error and no easy way to extend the Maple integrator exists.

M.D.

@Carl Love Yes, your 2nd example demonstrates what I have already seen in a different context: changing field-contents of a record by assignment is a bit dangerous, leading in my case to the whole thing getting out of sync as the fields in my records are interrelated. The moral here is to only use setter routines to change the content of any field, and then making sure it is all done right. Presumably I can then use forget (in the setter routine) to clear the remember table or maybe even just the relevant entries.

More work is needed but I go the basic structure to work, and the remember option definitely speeds things up.

Thanks for an illuminating discussion of this topic,

M. D.

@Carl Love Yes, your 2nd example demonstrates what I have already seen in a different context: changing field-contents of a record by assignment is a bit dangerous, leading in my case to the whole thing getting out of sync as the fields in my records are interrelated. The moral here is to only use setter routines to change the content of any field, and then making sure it is all done right. Presumably I can then use forget (in the setter routine) to clear the remember table or maybe even just the relevant entries.

More work is needed but I go the basic structure to work, and the remember option definitely speeds things up.

Thanks for an illuminating discussion of this topic,

M. D.

@Alejandro Jakubi 

Isn't there a way to manually add an entry to the lookup table of the integrator? I seem to recall such a mechanism being mentioned somewhere (either in Primes or in the Maple docs or in ??) but cannot recall where I saw it.

Mac Dude

As others said, you definitely want 1-d mode to enter your commands. I have set my Maple up so it does that by default: set "Input Display" to "Maple Notation" in the Display tab of the Preferences. You learned already about <cmd>J and <cmd>K to add execution groups, which are most important; another one is <shift>Return to add code to an eecution group.

<option><cursor keys> jump to the ends within one execution group (why, oh why, don't <ctrl>E, <ctrl>V and friends not work in the standard worksheet??)

My pet peeve: There does not seem to be anyway to execute the entire sheet by a keyboard shortcut (I want <cmd>R to do that!). Highly annoying.

Mac Dude

@hossayni Ah, so you do not want to add vectors but rather find a more compact way of doing multiple assignments? At least that is how I understand your latest reply. For that I would look into the assign function together with seq.

assign allows you to construct names in an algebraic fashion (I usually use cat to concatenate a base name and a running number). seq alows you to build a list of such assignments.

I hesitate giving a complete example since I am not terribly fluent with assign and seq and do not have the time to create and debug a full example. But I have used before constructs like this:

assign(seq(cat("basename",index)=expression(index),index=1..maxindex));

which would create variables basename1, basename2 etc. with their respective assignments. Again, this is not a checked and verified example. Please consult the help pages for assign and seq; also I find the Maple Programming guide a very helpful document.

HTH,

 

M. D.

@hossayni Ah, so you do not want to add vectors but rather find a more compact way of doing multiple assignments? At least that is how I understand your latest reply. For that I would look into the assign function together with seq.

assign allows you to construct names in an algebraic fashion (I usually use cat to concatenate a base name and a running number). seq alows you to build a list of such assignments.

I hesitate giving a complete example since I am not terribly fluent with assign and seq and do not have the time to create and debug a full example. But I have used before constructs like this:

assign(seq(cat("basename",index)=expression(index),index=1..maxindex));

which would create variables basename1, basename2 etc. with their respective assignments. Again, this is not a checked and verified example. Please consult the help pages for assign and seq; also I find the Maple Programming guide a very helpful document.

HTH,

 

M. D.

@acer I'd like to second your advise about late assignment of (floating-point-) numbers to variables. Sometimes it is a little awkward to do it late, however, e.g. when modules are involved one loads by menas of "with()". In such cases I have been experimenting with a scheme where I include a list of replacements in the module, like rlist:=[p1=...,p2=...] and so on and then apply a simple subs(rlist,...) when the time comes to get to numbers. Doing this I find takes some of the tedium out of switching to numbers at a late stage.

M.D.

@acer I'd like to second your advise about late assignment of (floating-point-) numbers to variables. Sometimes it is a little awkward to do it late, however, e.g. when modules are involved one loads by menas of "with()". In such cases I have been experimenting with a scheme where I include a list of replacements in the module, like rlist:=[p1=...,p2=...] and so on and then apply a simple subs(rlist,...) when the time comes to get to numbers. Doing this I find takes some of the tedium out of switching to numbers at a late stage.

M.D.

Can you fix this up so it can actually be pasted into Maple?

Well, you know the formula for the area of a circle, right? Here you have two circles, so the total area is the sum of the two. Then get rid of one of the diameters by means of the condition that the sum  is 20 cm (or whatever it is). So now you have a formula for the total area as function of one of the diameters. This is the function you want to minimize.

Your question really is not a Maple question per se but more like one about how to solve minimax problems. You may need to consult other resources.

M.D.

Well, you know the formula for the area of a circle, right? Here you have two circles, so the total area is the sum of the two. Then get rid of one of the diameters by means of the condition that the sum  is 20 cm (or whatever it is). So now you have a formula for the total area as function of one of the diameters. This is the function you want to minimize.

Your question really is not a Maple question per se but more like one about how to solve minimax problems. You may need to consult other resources.

M.D.

Actually, you need the minimum of the sum of the areas per the wording of your problem.

This is a classical minimax problem and as such of great relevance in many applications. The trick here is to find the expression to minimize (the sum of the circular areas) as an >explicit< function of the parameter to be varied (d) without other implicit dependencies (like the radius of the other circle). Preben has outlined the approach. Once this expression is found find the derivative wrt. d and the value of d that makes this derivative zero. This is an extremum. Then you need to find the value of the 2nd derivative (=curvature) at this point to verify it is a minimum (2nd deriv >0).

Mac Dude

Actually, you need the minimum of the sum of the areas per the wording of your problem.

This is a classical minimax problem and as such of great relevance in many applications. The trick here is to find the expression to minimize (the sum of the circular areas) as an >explicit< function of the parameter to be varied (d) without other implicit dependencies (like the radius of the other circle). Preben has outlined the approach. Once this expression is found find the derivative wrt. d and the value of d that makes this derivative zero. This is an extremum. Then you need to find the value of the 2nd derivative (=curvature) at this point to verify it is a minimum (2nd deriv >0).

Mac Dude

First 35 36 37 38 39 40 41 Page 37 of 42