tomleslie

13876 Reputation

20 Badges

15 years, 182 days

MaplePrimes Activity


These are replies submitted by tomleslie

It works in all versions of Maple back to Maple 18. Anything earlier than Maple 18, you are on your own

 (There are more efficient ways to do this in recent Maple versions , but since you seem to be stuck with a really old version.......)

  restart;
  F:=0.3:  L1:=0.2: d1:=0.2:
  d2:=0.2: L2:=0.3: alpha:=Pi/6:
  h:= z-> piecewise( z<=0.2,
                                  1-(delta2/2)*(1 + cos(2*(Pi/L1)*(z - d1 - L1))),
                                  z<=0.4,
                                  1-(delta2/2)*(1 + cos(2*(Pi/L2)*(z - d2 - L2))),
                                  z<=0.6,
                                 1+(delta2/2)
                              ):
  K:= ((4/h(z)^4)-(sin(alpha)/F)-h(z)^2+Nb*h(z)^4):
  lambda:= Int(K,z=0..0.6):
  plots:-dualaxisplot
             ( plot
               ( [ seq
                   ( eval( lambda, Nb=j ),
                     j in [0.1,0.2,0.3]
                   )
                 ],
                 delta2 = 0.02..0.1,
                 style = line,
                 legend = [ Nb = 0.1,
                                   Nb = 0.2,
                                   Nb = 0.3
                                ],
                 legendstyle = [ font = [ times,
                                                        bold,
                                                        20
                                                     ],
                                           location=right
                                        ],
                 view = [0.02..0.1, 0.85..1.2]
               ),
               plot
               ( [ seq
                   ( eval( lambda, Nb=j ),
                     j in [0.1,0.2,0.3]
                   )
                 ],
                delta2 = 0.02..0.1,
                style = point,
                symbolsize = 16,
                symbol = [ solidbox,
                                   soliddiamond,
                                   solidcircle
                                ],
                numpoints = 20,
                view = [0.02..0.1, 0.85..1.2 ]
             )
           );

 

The figure you supply bears no relation to the code you supply - so I have no idea what your question is.

Code I supplied works in

Maple 2017.3

Maple 2016.2

Maple 2015.2

but does not work in Maple 18!

The following will work in Maple 18.

If you are using a version prior to Maple 18, I may not be able to help, becuase I have no earlier versions installed!

  restart;
  F:=0.3: L1:=0.2: d1:=0.2:
  d2:=0.2: L2:=0.3: alpha:=Pi/6:
  h:=z->piecewise( z<=0.2,
                               1-(delta2/2)*(1 + cos(2*(Pi/L1)*(z - d1 - L1))),
                               z<=0.4,
                               1-(delta2/2)*(1 + cos(2*(Pi/L2)*(z - d2 - L2))),
                               z<=0.6,
                               1+(delta2/2)
                            ):
  K:=((4/h(z)^4)-(sin(alpha)/F)-h(z)^2+Nb*h(z)^4):
  lambda:= Int(K,z=0..0.6):
  plots:-dualaxisplot( plot( [ seq(eval(lambda, Nb=j), j in [0.1,0.2,0.3])],
                                               delta2=0.02..0.1,
                                              view=[0.02..0.1, 0.85..1.2
                                            ]
                                          ),
                                    plot( 0,
                                             delta2=0.02..0.1,
                                             view=[0.02..0.1, 0.85..1.2]
                                          )
                                 );

is designed to 'combine' two plots, with the left axis applied to the first plot and the right axis applied to the second plot. You have three curves, which cannot be easily converted for use with dualaxisplot().

So the easiest way to achieve you objective  is to construct one plot with all three curves and the second plot, with no data at all, and combine these two plot structures using dualaxisplot(), as in

  restart;
  F:=0.3: L1:=0.2: d1:=0.2:
  d2:=0.2: L2:=0.3: alpha:=Pi/6:
  h:=z->piecewise( z<=0.2,
                               1-(delta2/2)*(1 + cos(2*(Pi/L1)*(z - d1 - L1))),
                               z<=0.4,
                               1-(delta2/2)*(1 + cos(2*(Pi/L2)*(z - d2 - L2))),
                               z<=0.6,
                               1+(delta2/2)
                            ):
  K:=((4/h(z)^4)-(sin(alpha)/F)-h(z)^2+Nb*h(z)^4):
  lambda:= Int(K,z=0..0.6):
  plots:-dualaxisplot( plot( [ seq(eval(lambda, Nb=j), j in [0.1,0.2,0.3])],
                                               delta2=0.02..0.1,
                                              view=[0.02..0.1, 0.85..1.2
                                            ]
                                          ),
                                    plot( NULL,
                                             delta2=0.02..0.1,
                                             view=[0.02..0.1, 0.85..1.2]
                                          )
                                 );

 

 

How do I use evalb() to determine whether

cos(a+b)=cos(a)*cos(b)-sin(a)*sin(b)

is true?

Because evalb(cos(a+b)=cos(a)*cos(b)-sin(a)*sin(b)) returns false, which is correct if one is considering whether the expressions are "identical", but wrong if one is considering whether expressions are "equivalent"

and everything works for me in 64-bit Maple 2017.3 on Windows 7. Obvious difference between you and me is still the Win7/Win10 issue

Since you state that you are using Maple 18, the following may seem rather confusing. I see the problem in Maple 2017.3, but not in earlier versions. In particular the test works correctly in Maple 18 !!???

In Maple 2017.3

Running the code you provided in the question, I can replicate the problem in this Maple version.

The 'examples Quiz' worksheet, which can be accessed via the Maple help, contains an almost identical 'quiz' on reducing fractions (about 2/3 of the way through the worksheet).

Running this example also produces the wrong grading whenever the fraction can be reduced such that the numerator=1. Since this example was (presumably) written by someone at MapleSoft., it really ought to be correct

Earlier Maple versions

If I run the same example, from the 'examples Quiz' worksheet in Maple 2016.2, Maple 2015.2 and Maple 18  then the grading is never wrong (ie the case of numerator=1 in the reduced fraction is handled correctly). The code you provide in your question also works in these earlier releases.

 

I'm running Maple 2017.3 64-bit on Windows 7

Worksheet (with output) is attached. This computes "solutions" a couple of ways on default Digits, and does the same again with Digits:=25. No sign of any "Errors". If you attempt to re-execute, you should be aware that each of the DirectSearch:-GlobalSearch() commands takes a few minutes to run.

optiProb.mw

Tried the same worksheet on Maple 2016.2, Maple 2015.2 and Maple 18.02 and everything still executes with no errors. Actual answers from the DirectSearch() commands vary a little, but not enough to get me worried. Execution times also seem to increase with earlier versions - probably no surprise.

Can't try anything earlier than Maple 18.02, because I no longer have these available.

Major difference between us would seem to be that you have Windows 10 and I have Windows 7

Engage brain before fingers!

At least the Statistics:-NonlineaFit() command comes up with the correct answer, as in

restart;
pts1 := Vector([0, 1, 2, 6, 12, 15]):
pts2 := Vector([0, 13, 21, 45, 54, 77]):
Statistics:-NonlinearFit( 21+a*(x-2), pts1, pts2, x);

 

The fact that both

CurveFitting:-LeastSquares()

and

Optimisation:-LSSolve()

can handle linear model functions with an additive constant, whereas

Statistics:-LinearFit()

cannot, bothers me.

Anyone have a reason for this peculiarity, or should it be considered a (minor) bug

In the command

ArcLength(f(x), x = Pi..5*Pi/3);

It is pretty obvious that what you require is the arc length along the curve f(x) between the x-values Pi and 5*Pi/3, (for which the corresponding y-values are f(Pi) and f(5*Pi/3) ).

All of the required information for the calculating the answer is therefore contained in the argument list for the ArcLength() function

Although still no closed form (hence the call to evalf() )

restart;
f:=x->sin(cos(x+Pi));
with(Student[Calculus1]):
ArcLength(f(x), x = Pi..5*Pi/3);
evalf(%);

 

Your program seems to provide correct, consistent answers - but I'm using a much more recent Maple version and can't test/debug it in Maple 7 :-(

I no longer have any Maple releases earlier than Maple 18.

My original code suggestion will not work in Maple 7, because the ArrayTools package was not introduced until Maple 9. Revised code which ought(?) to work in Maple 7 is shown below

getMatDet:=proc( n )
                     uses LinearAlgebra:
                     local j, A:=Matrix(n,n);
                     A[1,..]:=Vector([seq(binomial(n,i), i=0..n-1)]):
                     for j from 2 to n do
                          A[j,2..n]:=A[j-1,1..n-1];
                          A[j,1]:=A[j-1,n];
                     od:
                    return A, Determinant(A);
                    end proc:
getMatDet(6);
getMatDet(7);

I have to admit that I prefer acer's solution, and I can't think of any reason why it would not work in Maple 7

n:=6:
A:=Matrix(n,n):
A[1,..]:=Vector([seq(binomial(n,i), i=0..n-1)]):
for j from 2 to n do
     A[j,..]:=ArrayTools:-CircularShift(A[j-1,..],1);
od:
A;
LinearAlgebra:-Determinant(A);

 

I'm not exactly sure what you are trying to achieve, but the following performs a calculation in Maple and transfers the results to a Matlab variable, so it may(?) be helpful

 

   %
   % perform calculation in Maple
   %
       maple('fred:=[rhs~(fsolve([2*x-9*y=6, 5*x-5*y=30]))[]]');
   %
   % Get results from maple back into matlab
   %
       res=getmaple('fred');
   %
   % Display results in matlab and do a simple
   % calculation with them
   %
       res(1)
       res(2)
       res(1)+res(2)

First 105 106 107 108 109 110 111 Last Page 107 of 207