tomleslie

13876 Reputation

20 Badges

15 years, 181 days

MaplePrimes Activity


These are replies submitted by tomleslie

@Rouben Rostamian  

On the other hand, the OP did specify an integrand

"which is to be integrated simultaneously with respect to dw dp dq (where w, p, q are 3-d vectors)."

When I see an integration specified wrt to the infinitesimal of a vector (and the integrand is scalar) then I think -it's a path integral. Obviously I could be wrong, I often am.

@Ronan 

that would need simplify(isolate()), as in

restart;
eq := (F+G)*R*sin(x)/sqrt(W-1) = (1/2)*M*R^2*tan(x)*(a/(R*sqrt(W-1)));
simplify(isolate( eq, F+G))

 

@Federiko 

I've just tried Preben's code on 64-bit Win 7 with

Maple 18
Maple 2015
Maple 2016
Maple 2017
Maple 2018

and it executes with no errors. Which Maple version+OS are you running?

@mehdi jafari 

Try some simple checks to determine exactlyt what does/doesn't work

  1. Page Up/Page Down operation in Maple.
    1. Don't touch any function keys
    2. Create/open a plain, ordinary Maple worksheet which is more than a "screenful"
    3. Try PageUp/PageDown - do these "scroll" the worksheet in the way you would expect?
    4. "Fullscreen" the Maple worksheet (middle icon in the upper right corner): assuming that the worksheet still extends for more than a "screenful", does PageUp/PageDown work?
  2. Function key operation
    1. with a Maple worksheet as the active window, does F1 bring up the Maple help? There is a longstanding "tradition" that F1 should access the relevant help. I have just checked this for several of the applications on my machine, and for about 8 out of 10, the "help" page appears. Remember this is a Windows "tradition", not any kind of "requirement" so don't worry it it doesn't work for some of your installed applications. However it should work for Maple - does it?
    2. The Maple help page at ?hotwin will bring up the help page listing all available Windows shortcut keys, some of which are Function keys. Try a few of these: F1 should bring uo the help, F3/F4 should split/join execution groups (join only works if both groups are selected). Try to get some kind of "feel" whether appropriate function keys do what they are supposed to in Maple
    3. Bear in mind that for slideshow operation, Maple splits a worksheet by sections, not "execution groups", "pages", or anything else. Does your worksheet have appropriately defined sections? The attached "test" worksheet"  (with nothing of interest in it!), should produce a slideshow with three "slides", using F11, followed by right/left arrow keys for navigation. This works for me - how about you?

whatever 1

 

#
# Some random stuff
#

whatever 2

 

#
# Some more random stuff
#

whatever 3

 

#
# Even more random stuff
#

Download slideCheck.mw

 

@tzeng 

It is in fact possible to 'combine' operators in an expression, and then supply a single argument. The difficulty you are experiencing is becuase you are combining operators and unassigned variables in a single expression. Consider the 'toy' example

restart;
f:=x->x^2;
g:=x->2*x;
(f+g)(2);
(f+g/y)(2);

Before executng the above code, ask yourself the question - what is 'y' in the final expression? Is it an as-yet-undefined variable, in which case the expected result would be f(2)+g(2)/y - or is it an as-yet-undefined function, in which case the expected result would be f(2)+g(2)/y(2). Maple defaults to the former interpretation.

I wouldn't recommend doing it, but it is possible to do a minor rewrite to the code which Kitonum has supplied, so that a single argument can be provided for each function combination., and the "correct" answer is obtained.

The above 'toy' example and the revision of Kitonum's code is shown in the attached - as already mentioned I wouldn't recommend this because

  1. it doesn't gain you much, if anything
  2. it makes code a bit tricky to follow

  restart:
#
# y interpreted as a function
#
  f:=x->x^2:
  g:=x->2*x:
  (f+g)(2):
  (f+g/y)(2);

4+4/y(2)

(1)

  restart:
#
# the function y() returns the variable
# y, for any argument
#
  f:=x->x^2:
  g:=x->2*x:
  y:=x->y:
  (f+g)(2):
  (f+g/y)(2);

4+4/y

(2)

  restart:
  Mphi := f->-I*(diff(f, phi)):
  r:=f->r:
  Pr := f->-I*(diff(f, r(f))):
  rplus := f->r(f)*exp(I*phi)*f:
  rminus := f->r(f)*exp(-I*phi)*f:
  Pplus := f->exp(I*phi)*(Pr+I*Mphi/r)(f):  
  Pminus := f->exp(-I*phi)*(Pr-I*Mphi/r)(f):
  Rpp := f->(Pplus(f)+I*rplus(f)):
  Rmp := f->(Pplus-I*rplus)(f):
  Rpm := f->(Pminus+I*rminus)(f):
  mm := f->(Pminus-I*rminus)(f):
  Psi00 := sqrt(1/Pi)*exp(-(1/2)*r(f)^2):                        
  Rpm(Rpp(Psi00)):                
  simplify(%);   

(-4*r^2+4)*exp(-(1/2)*r^2)/Pi^(1/2)

(3)

 

Download funcComb.mw

send personal emails.

Any further help (from me at least) will only take place through this site

You can upload any further information here, or use the big green up-arrow in the toolbar to upload any relevant files

@pchin

when you state "displayprecision interface variable controls the number of decimal places", I'm afraid my only response is - wtf are you defining as a "decimal place"? Because the output of the trivial example below makes my eyes bleed

restart;

kernelopts(version);
interface(displayprecision=2);
seq( 123456789.0/10^j, j=0..9);

`Maple 2018.1, X86 64 WINDOWS, Jun 8 2018, Build ID 1321769`

 

-1

 

123456789.0, 12345678.90, 1234567.890, 123456.7890, 12345.67890, 1234.567890, 123.4567890, 12.34567890, 1.234567890, .1234567890

(1)

 

Download places.mw

After all, if we are dealing in "decimal places" then the first three entries should(?) have been 123456789.0, 12345678.90 and 1234567.89 - shouldn't they?

Or maybe you should extend the help for 'displayprecision' to point out to unwary users that the concept of a "decimal place" depends on whether or not the number in question is > 1.0e06

 

Nowhere in Maple help can I find any reference to the fact that vector input is allowed when seeking a symbolic solution from dsolve(), but is not allowed when seeking a numeric solution.

My view is that either both of the examples in the attached should be acceptable - or neither should work!

Consistency is a wonderful thing.

For some reason this site refuses to display the contents of this (trivial) worksheet - so you get link-only

deProb.mw

@unproductive 

Joe Riel did not suggest a "better mouse", I did: I was trying to be funny and obviously failed:-(

The comment was only made because I was unable to replicate this particular problem. Believe me I tried: I used Al+Minus repeatedly to zoom out as far as possible, making the section markers as tiny as they will go, which is teeny-teeny-tiny, and I could still open/close sections with one mouse-click every time. I suppose you might be able to get the section markers even smaller than I can if you are running a higher monitor resolution: I'm running 2560x1440

No one here made any comments about "user-error and problems with my system", so I don't know what you are referencing. All I see are sensible suggestions which fix your problem(s)

but then I never tried the Japanese version!

Just as a suggestion, ensure that Tools->Options->Display->Output Display is set to 2D Math notation (which *ought* to be the default)

@assma 

scalable x-axis, and data rotation. NB plots "render" better in Maple than they do on this site

restart;
data := Vector[column](25, [0, 0, 0, 0, 0., 0, -.12901351888865177210172017415364583333333333333333, -0.99242368143093037923177083333333333333333333333340e-1, .37625367305666259757677714029947916666666666666666, .56250000000000000000000000000000000000000000000000, 0, -.19475144716868229166666666666666666666666666666667, -.21163024381866666666666666666666666666666666666666, .12728253980166145833333333333333333333333333333334, 1.0000000000000000000000000000000000000000000000000, 0, -0.88292457198317913770675659179687500000000000000009e-1, -.14358380077549029541015624999999999999999999999989, -.26169225877306929516792297363281249999999999999994, .56250000000000000000000000000000000000000000000000, 0, 0, 0, 0, 0.]):
#
# Plot the above data as a function of the index value,
# scaled to fit the range xlower..xupper. Pick any values
# you want for these end-points
#
  xlower:= 0:
  xupper:= 10:
  xv:=Vector[column]( op(1, data),
                      [ seq
                        ( j,
                          j = xlower..xupper,
                              (xupper-xlower)/(op(1, data)-1)
                        )
                      ]
                    ):
#
# Basic plot
#
  p1:=plot( xv, data, style=line);
#
# Literally just rotate the plot as the OP requested
# - probably not exactly when the OP actually wants?
#
  plottools:-rotate(p1, 3*Pi/2, [0,0]);

 

 

 

#
# OP (probably) wants to interchange x-y cooordinates.
# which could be done with either
#
  p2:=plot( data, xv, style=line);
#
# or
#
  p3:=plottools:-reflect( p1, [ [0,0], [1,1] ]);
#
# or even
#
  p4:=plottools:-transform( (x, y)-> [y,x])(p1);

 

 

 

#
# Export the data from the "rotated" plot to a file, in
# simple 'csv' format
#
# NB OP will have to changethe path/filename to something
# appropriate for his/her machine
#
  ExportMatrix("C:/Users/TomLeslie/Desktop/testdata.csv", plottools:-getdata(p2)[3][] );

1207

(1)

 

 

Download dataplot2.mw

@Preben Alsholm 

Next time, I'll skim-read more slowly

@assma 

Maple can save data in pretty much any format anyone could sensibly want.

Your problem is that you have a 1x25 Vector of data and seem incapable of specifying exactly how you want this to be exported. Until you can specify the export requirement in an understandable way, you are unlikely to get much significant help

@Carl Love 

I thought I was being somewhat more realistic than other "solutions" here because I didn't use the exact analytic solution to set up the shooting method.

However, if you insist on only using IVP methods to set up the "shooting" method, then the attached shows how it can be done. For this specific problem, one simply sets D(u)(0) to some 'dummy' variable and uses fsolve() to determine the value of this variable which causes the boundary condition u(1)=0 to be met.

I believe that this is known as 'shooting' out trajectories in different directions until one finds a trajectory that has the desired boundary value. See https://en.wikipedia.org/wiki/Shooting_method

  restart;

#
# Set up the ODE + BCs and compute the
# exact solution. Note that although
# the boundary conditions are given at
# u(0)=0, u(1)=0, the solution can be
# plotted over any range of the
# independent variable
#
  eq:= diff(u(x),x,x)+1/9*u(x)=x^2+exp(x):
  ics:= u(0)=0, u(1)=0:
  exactSol:= dsolve( [eq, ics]):
  pExact1:= plot( rhs(exactSol),
                  x=0..1
                );
  pExact2:= plot( rhs(exactSol),
                  x=0..2
                );

 

 

#
# Now solve the example numerically as a BVP.
# Note that this solution *cannot* be plotted
# outside the range given by the BCs
#
  BVPsol:= dsolve( [eq,ics],
                  numeric
                ):
  pBVP1:= plots:-odeplot( BVPsol,
                          [x, u(x)],
                          x=0..1
                        );
  pBVP2:= plots:-odeplot( BVPsol,
                          [x, u(x)],
                          x=0..2
                        );
#
# As some kind of check, Plot the error between
# the BVP solution and the exact solution over the
# range x=0..1. Under "normal" circumstances, one
# wouldn't "know" the exact solution
#
  pBVP3:= plots:-odeplot( BVPsol,
                          [x, u(x)-rhs(exactSol)],
                          x=0..1
                        );

 

Warning, right boundary of range exceeds domain of the problem, it has been adjusted

 

 

 

#
# Now set up the "shooting" method, using only
# an IVP solver. The basic approach is to set
# D(u)(0) to some arbitrary variable and use
# fsolve() to adjust this variable until the
# IVP solver returns the condition u(1)=0.
# Thus no BVP solver is ever used
#
  f:= alpha -> eval( u(x),
                     dsolve
                     ( [ eq,
                         u(0)=0,
                         D(u)(0)=alpha
                       ],
                       numeric,
                       output=listprocedure
                     )
                   )(1):
  IVPsol:= dsolve
           ( [ eq,
               u(0)=0,
               D(u)(0)= fsolve(f)
             ],
             numeric
           ):
#
# Note that since we now have an IVP solution, it can
# be plotted for any range of the independent variable
#
  pIVP1:= plots:-odeplot( IVPsol,
                          [x, u(x)],
                          x=0..1
                        );
  pIVP2:= plots:-odeplot( IVPsol,
                          [x, u(x)],
                          x=0..2
                        );
#
# Plot the error between the IVP solution and the
# exact solution over the ranges x=0..1, and x=0..2
#
  pBVP3:= plots:-odeplot( IVPsol,
                          [x, u(x)-rhs(exactSol)],
                          x=0..1
                        );
  pBVP4:= plots:-odeplot( IVPsol,
                          [x, u(x)-rhs(exactSol)],
                          x=0..2
                        );

 

 

 

 

 

Download shoot2.mw

 

but don't get excited because this isn't a complete solution. The following are the steps I went throught to address your problem

  1. In the worksheet you posted the quantity Xip(Ts) (second-last execution group) is not calculated. One of the integrals returns "unevaluated". Unless these integrals can always be evaluated for any argument between Ts and Tf, you have no hope of obtaining a plot. So I focussed on *trying* to come up with a way tow ensure these intrgals are evaluated
  2. Maple has a lot of different "methods" for numerical integration, and I'm definitely not the best person to discuss there relative merits. However I have noticed from unrelated responses on this site that the method "_d01ajc" seems to be a popular choice for difficult problems - so I thought |I'd give this a whirl
  3. First problem, is that this method doesn't seem to handle probelms when Digits>15. I'm guessing that it is specifically written to use "hardware floats" more or less equivalent to conventional double precision. Your worksheet had Digits set to 20 (I have no idea why). Anyway I dropped the Digits setting to 15, and all of a sudden I could compute Xip(Ts), which is a small success
  4. Since the plot() statement allows arguments between Ts and Tf, with Tf=2*Ts (more or less), I tried a few more argument values in this range. This resulted in error messages from the integration process about "being unable to achieve the required accuraccy". The accuracy setting for this integration method seems to be derived from the setting of Digits, so I kept dropping the value of Digits until I could compute these integrals, for Ts, 1.1*Ts, 1.2*Ts,...1.9*Ts. This resulted in a Digits setting of 8 - so not great, but maybe usable?
  5. The attached worksheet toughInt.mw  (saved with output) shows the results of calculating Xip(t) for t from Ts to 1.9*Ts in steps of 0.1*Ts, and the answer is pretty much always -633.58, plus or minus. Computing these 10 values took about 10mins on my machine.
  6. Since the plot command wiill use 50 points by default (more or less), this suggest that produicing the plot *ought* to take an hour or so. I left it running for about 2 hours and didn't get any output. I needed my cpu for other work, so I killed it. If you want to leave this workheet running overnight, you *might* get a plot, but based on the 10 values described in (5) above, I'm guessing that it won't be very interesting:-(

On a somewht separate subject, I agree with Preben's earlier comments that your use of 2D-input mode with somewhat "complicated" variable names, makes your worksheet about 10x more difficult to debug than it needs to be. I have little interest in getting into an argument about the relative merits of 2-D versus 1-D input, but I think a couple of examples might illustrate the problems someone debugging yur code  acually experiences

  1. In 2-D input you use variable names such as the concatenation of 'Greek capital lambda', '2' and 's'. Just for your own amusement try to locate where this variabke occurs in your worksheet by using Maple's in-built Find/Replace capability. If you discover a successful way to do this, let me know. I have to painstakingly read the whole worksheet, to find where this variable is defined, because the simplest editor operation (ie (Find/Replace) doesn't work!
  2. My favourite example. You can award yourself a prize if you can predict the outcome of the five calculations in the attached, without actually executing the worksheet. I find this sort of thing makes "reading/analysing" 2D code very difficult. With 1-D input, the answers would be obvious

restart
x[i] := 2

x__i := 6

x__i-x__i

x__i-x[i]

x[i]-x__i

x__i-x[i]
x__i-x__i

 

Download love2D.mw

First 86 87 88 89 90 91 92 Last Page 88 of 207