Preben Alsholm

13728 Reputation

22 Badges

20 years, 243 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@tsunamiBTP No, the problem lies with constants (like Pi, sqrt(2) or sin(2)) that are not of type numeric. The fraction 1/3 is of type numeric; Pi, sqrt(2), and sin(2) are not.
Actually I mentioned 22/7 as an example for which the substitution Pi=22/7 makes is return true for the original equation. I might as well have used Pi=1/3.
##
Secondly, this "remedy" of replacing Pi with an unassigned name works here, yes, but clearly we could construct examples of equations whose validity depends on Pi being Pi and not just a name.
##
So my point was just to point at the possible cause of the bug.
Basically, I don't think that you should trust is.

 

@tsunamiBTP Your new example doesn't differ in its essence from the simpler one you started with.
The following changes (in order) will give you true:

is(subs(Pi=pi,Y));
##
is(eval(y1 = y2, {Pi = pi, n = 10}));
##
is(eval(y1 = y2, {Pi = pi, n = 10})) assuming real;
##
is(combine(subs(Pi = pi, eq)));
############
You have value in a couple of places. No need for that. You are using sum (not Sum) and sum finds a symbolic sum.
As I was pointing out in my answer, theproblem seems to be the handling of constants that are not rationals like Pi and sqrt(2). I use pi as a name, it might as well have been another unassigned name.

A quite similar question was asked on MaplePrimes here:
https://mapleprimes.com/questions/223417-Physics--Math-With-Maple-DE-Numerically#answer244152

Notice that the OP (Joey Joe) had a dimensionally incorrect version of the Einstein version at first.

@vv I agree with your first 3 lines.
About the last point: I went to the help page
?Atomic variables
and found this gibberish:

Use a literal subscript to form a name that will not be interpreted as an index of any kind. For example, if you want to use both  x  and x[0]  in a worksheet as distinct names, use a literal subscript for
#mrow(msub(mi("a",mathcolor="#AF00AF"),mi("b",mathcolor="#AF00AF"))


Quite simple, right? It made me think that somebody goofed up the help page, but I'm afraid not.

 

@Muhammad Usman Your solve command in the worksheet HELP.mw actually returns a result.
You have commented out the other attempt to find Sols, thus the graph of P is using that solve command.
But since you have a system with floating point coefficients and the determinant is found to be something like
-3.4266188236700911852*10^(-318)
then it doesn't make sense to convert to rationals.
Consider this simple example:
 

restart;
A:=Matrix([[Pi,1],[sqrt(Pi)*Pi,sqrt(Pi)]]);
LinearAlgebra:-Determinant(A); #0
A2:=evalf(A);
LinearAlgebra:-Determinant(A2); # 0.
A3:=convert(A2,fraction);
LinearAlgebra:-Determinant(A3); # NOT zero

The point is that converting a floating point matrix to rationals often results in a nonsingular matrix although the original really was singular.
##
Instead you can for your system use LeastSquares from the LinearAlgebra package to find the vector x that minimizes A.x-b in the euclidean norm.

LS:=LeastSquares(A,b);
Norm(A.LS-b,2); #Roughly 0.3

and then do
 

res:=eval(theta,var =~convert(LS,list));
P2 := eval(res, t = 0.1e-2);
plot(P2, x = 0 .. R);

 

@tomleslie Yes, I have the same problem (in Maple 2017.3, Windows 10, 64 bit) that you refer to.
I get

Warning, problem appears to be unbounded
           [0, [xifp = 0, xifq = 0, xp = 0, xq = 0]]

but setting UseHardwareFloats:=false gives me the answer you get.

 

Since this problem must be solved numerically we need to know the parameters M, R, and alpha, or at least in which ranges they lie.
Even so there is no guarantee of success.

@acer The OP's original code works for me on Windows 10, 64 bit, Maple 2017.3 when using method=interiorpoint.
It doesn't work correctly when using method=activeset.

kernelopts(version);
  Maple 2017.3, X86 64 WINDOWS, Sep 27 2017, Build ID 1265877

interface(version);
    Standard Worksheet Interface, Maple 2017.3, Windows 10, September 27 2017 Build ID 1265877

 

@tomleslie You wrote:
" My original post, and all of my subsequent posts correctly solve the problem on 64-bit Windows (as it happen WIndows 7), using LPSolve(). These correct solutions are obtained for Maple 18.02, Maple2015.2, Maple2016.2 and Maple 2017.3. "

Since I understand that the OP (andreasks) works at a university and has to deal with students having different kinds of computers, he must have a solution that works for all types of computers.

As I have posted (and with the default setting of Digits=10 and UseHardwareFloats), your code:

restart;
Optimization:-LPSolve( 3*x__1+14*x__2+18*x__3+6*x__4+2*x__5,
                       {3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10},
                       binaryvariables=[x__1, x__2, x__3, x__4, x__5],
                       maximize = true
                      );
#######

does not work on my Windows 10, 64 bit computer in Maple 18.02, 2015.2, 2016.2, and 2017.3.
But it does work (thanks to Markiyan Hirnyk for pointing this out) if Digits is set to 16, thus forcing Maple to use software floats.
Your code as well as the OP's original code also works with default setting of Digits, if we make the assignment UseHardwareFloats:=false: as in
 

restart;
UseHardwareFloats:=false;
Optimization:-LPSolve( 3*x__1+14*x__2+18*x__3+6*x__4+2*x__5,
                       {3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10},
                       binaryvariables=[x__1, x__2, x__3, x__4, x__5],
                       maximize = true
                      );
################
restart;
UseHardwareFloats:=false;
Optimization:-LPSolve( 3*x__1+14*x__2+18*x__3+6*x__4+2*x__5,
                       {3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10},
                       x__1=0..1, x__2=0..1, x__3=0..1, x__4= 0..1, x__5=0..1,
                       maximize = true
                      );

##############
NOTE 1: I'm not saying that this problem exists on all computers with recent Maple versions (since 18.02) and with Windows 10, 64 bit. Had this been true, my guess is that acer wouldn't have replied as he did in his "specifics" reply.
NOTE 2: The OP's original code works for me with the option method=interiorpoint and with default settings of Digits and UseHardwareFloats (see acer's first reply).

@faisal We need to know what X is, specifically how it is related to f(eta).
Also we must know the values of A and epsilon[1] .
I'm assuming that S = s?

@Markiyan Hirnyk Thanks for the reference.
You wrote in a reply in that link:
 
"I am glad of the workaround by Mariusz. Every big soft includes bugs. In particular, both Maple and Mathematica are not any exception. However, I don't remember a Mathematica's bug which appears in 32-Bit version of OS only."

Actually my system is 64 bit (Windows 10) and raising Digits to 16 works for me:

 

restart;
Digits := 16: 
Optimization:-LPSolve(2*x+5*y, {3*x-y = 1, x-y <= 5}, assume = {integer, nonnegative});

Futhermore, the OP's original code works too:
 

restart;
Digits:=16:
Optimization:-LPSolve(3*x__1+14*x__2+18*x__3+6*x__4+2*x__5, {3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10}, x__1 = 0 .. 1, x__2 = 0 .. 1, x__3 = 0 .. 1, x__4 = 0 .. 1, x__5 = 0 .. 1, maximize = true);

Answer:
[29.59999998353600, [x__1 = 0., x__2 = .3999999988240001, x__3 = 1., x__4 = 1., x__5 = 0.]]

@tomleslie A few hours ago I filed a bug report about the following example from the help page for LPSolve:
 

restart;
Optimization:-LPSolve(2*x+5*y, {3*x-y=1, x-y<=5}, assume={nonnegative, integer});

It produces a crash (loss of kernel connection) on my computer in Maple 18.02, 2015.2, 2016.2, and 2017.3, but NOT in Maple 17.02 where it gives a correct result: [12, [x = 1, y = 2]]

Do you get a the crash on your computer in the Maple versions you have?

@tomleslie For Maple 2015.2 I get

restart;
kernelopts(version);
Optimization:-LPSolve( 3*x__1+14*x__2+18*x__3+6*x__4+2*x__5,
                       {3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10},
                       binaryvariables=[x__1, x__2, x__3, x__4, x__5],
                       maximize = true
                      );
  Maple 2015.2, X86 64 WINDOWS, Dec 20 2015, Build ID 1097895
Warning, problem appears to be unbounded
    [0, [x__1 = 0, x__2 = 0, x__3 = 0, x__4 = 0, x__5 = 0]]

#########
Maple 18.02:

restart;
kernelopts(version);
Optimization:-LPSolve( 3*x__1+14*x__2+18*x__3+6*x__4+2*x__5,
                       {3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10},
                       binaryvariables=[x__1, x__2, x__3, x__4, x__5],
                       maximize = true
                      );
   Maple 18.02, X86 64 WINDOWS, Oct 20 2014, Build ID 991181
Warning, problem appears to be unbounded
    [0, [x__1 = 0, x__2 = 0, x__3 = 0, x__4 = 0, x__5 = 0]]

#############
But in Maple 17.02:

restart;
kernelopts(version);
Optimization:-LPSolve( 3*x__1+14*x__2+18*x__3+6*x__4+2*x__5,
                       {3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10},
                       binaryvariables=[x__1, x__2, x__3, x__4, x__5],
                       maximize = true
                      );
    Maple 17.02, X86 64 WINDOWS, Sep 5 2013, Build ID 872941
    [26, [x__1 = 0, x__2 = 0, x__3 = 1, x__4 = 1, x__5 = 1]]

##########################################
NOTE ADDED:
I thought that the build ID number would be the same for the same final release for (say) Windows 64 bit. By "final" I exclude beta versions.

@tomleslie I tried your code in Maple 2017.3 and in Maple 2016.2 and got the warning about unboundedness and the result
[0, [x__1 = 0, x__2 = 0, x__3 = 0, x__4 = 0, x__5 = 0]]

For Maple 2017.3:

kernelopts(version);
  Maple 2017.3, X86 64 WINDOWS, Sep 27 2017, Build ID 1265877

For Maple 2016.2:

kernelopts(version);
  Maple 2016.2, X86 64 WINDOWS, Oct 21 2016, Build ID 1174570

###############

But in Maple 17.02 I got the result you report.
The same goes for Maple 12, 15, and 16.

################
In Maple 18 and Maple 2015 it is the same as in Maple 2017.3.

The problem as formulated can be solved by NLPSolve.
 

f:=3*x__1+14*x__2+18*x__3+6*x__4+2*x__5;
cstr:={3*x__1+5*x__2+6*x__3+2*x__4+x__5 <= 10};
res:=Optimization:-NLPSolve(f,cstr, x__1 = 0 .. 1, x__2 = 0 .. 1, x__3 = 0 .. 1, x__4 = 0 .. 1, x__5 = 0 .. 1, maximize = true);
eval([f,cstr],res[2]); #Check

This doesn't solve the binary problem, but neither would the command you are using (if it had worked).

First 52 53 54 55 56 57 58 Last Page 54 of 230