Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@PunkRediska 

A list of lists of constants can't be a variable. Are you trying find the minimum value of a function over a finite set of pregenerated points? You don't need any fancy minimization software for that. Just evaluate the function at all the points and use min.

@ecterrab 

Yes, I believe that you are missing something. Zero isn't a positive integer. The examples that you've shown where you put a lower bound of on the sum j+k have indeed restricted that sum to be greater than 0, but they don't restrict the individual variables. I want both j and k individually restricted to positive integers. (And, as I said, I don't think that that's an unusual request.)

Here are two examples. The first example shows both j and k taking the value 0. The second example is weirder. It shows j restricted to positives, but k allowed to be 0. I don't know how it has made a distinction between j and k.

(The worksheet uploader is broken right now. I'll just post the input and plaintext output by cut-and-paste.)

restart:
Physics:-Setup(redefinesum= true):
Sum(f(j,k), ''1 <= j+k and j+k <= 2'');

value(%);

     f(0, 1)+f(1, 0)+f(0, 2)+f(1, 1)+f(2, 0)

Sum(f(j,k), ''1 <= j+k and j+k = 2'');

value(%);

     f(1, 1)+f(2, 0)

 

@ecterrab 

You misunderstood my question; sorry that it wasn't more clear. Yes, I've tried the command and read the help page. So I know that it works when you change the initial value of m. That is obvious. I want to change the lower limit values of and k. For example (and this seems like a fairly common situation), I want the inner sum to be done for all pairs of positive integers (j,k) such that j+k = m-1. 

Unrelated question: When you programmed this, were you able to prettyprint the sum with an inequality on the bottom using just Maple-level programming, or did it require a change in the GUI?

@ecterrab In this new form of Sum command, with index expression j+k= m-1, how does it know the initial value of j? In this case it was obvious that j needed to start at 0, but if started at 3, say, then there could be a case where the intended start for j is 1.

It looks like you're trying to supply more than one initialpoint to Optimization:-Minimize. It doesn't allow that. You may be better off using the DirectSearch optimization package (which you'd need to download from the Maple Applications Center). That package's commands allow for multiple initial points.

You can rerun Optimization:-Minimize pm times, once for each initialpoint.

There are some things confusing about your Question:

  1. The Minimize doesn't use getone; indeed, you don't give any purpose at all for getone.
  2. You use z several different ways. You have it as the objective function, the sequence of variables of the objective function, a randomly generated point, a list of randomly generated points.

You can simplify your random point generation like this:

Roll:= rand~([98.0..102., -1.0..5., .5..1.0, 0..evalf(2*Pi), 0..20.]):
['Roll()'$pm];

Do you want differentiation with respect to a particular variable, such as x, as provided by the diff command, or differentiation of an operator, as provided by the D command?

@maple fan There's no real root! If there were a real root, how would you decide if it was positive or negative? Maybe you just want to make it negative? Okay, then plot

plot(-abs((-2)^x), x= -sqrt(2)..-exp(-1));

So what's the real root of (-2)^(1/2)?

 

@acer Thank you for the corrections. I've never been able to get eval to work inside evalhf and now I have an example.

Still, is it ever actually worth it to create a Vector in evalhf code? Isn't it substantially more efficient to pass it in?

And is what I wrote true with respect to compiled code?

@charlesforgy 

I avoid any scenario that involves modifying the optimized code with a text editor. A substantial amount of modifying can be done with subs, and there's almost always some of that that I need to do after using codegen(..., tryhard).

Do you plan to call the resulting optimized procedure with evalhf?

Note that your entire procedure TestFunc can be replaced by 

Matrix((ii,jj), `*`);

@Adri van der Meer 

There is no need to use print in your procedure, and, indeed, it may make the procedure less useful.

@Markiyan Hirnyk 

Here's why the OP wants to separate the columns. Look closely at the Matrix in the original Question. It superficially appears to be eight columns. But the first two columns are actually one, each entry having two terms. The OP wants that to be visually obvious.

@Hamidreza 

I'm using Windows 8.1.

Your command works for me. Try doing a restart first; perhaps something has inadvertently been assigned to a or b.

First 460 461 462 463 464 465 466 Last Page 462 of 709