acer

32405 Reputation

29 Badges

19 years, 346 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

For this example there is a way to get the simpliciation by going through a temporary conversion to hypergeom, and then back to StandardFunctions. The double conversion produces a longer expression with just LaguerreL(n,...) terms, which simplifies.

restart:

ee := (2*l+2*n-1)*LaguerreL(n-2,l+1/2,y)-(2*l+4*n-2*y-1)*LaguerreL(n-1,l+1/2,y):

simplify(convert(convert(ee,hypergeom),StandardFunctions));

                                     /       1   \  
                         -2 LaguerreL|n, l + -, y| n
                                     \       2   /  

Did you see how I used a FunctionAdvisor identity in an answer to your previous question? (I used subs, after converting the unknown names to globals.)

acer

@brian bovril It works for me in 32bit and 64bit Maple 18.02 on Windows 7, and in 64bit 18.01 on Linux, and in 64bit Maple 17.02 on Windows 7. That's all I tried so far.

The following final solving step also works for me (but a little slower, and not so accurate),

Student:-NumericalAnalysis:-Bisection(
               'HeightatHalt'( v0, 1.2, xf ) - yf, [30,100], tolerance= 1e-6 );

Also working for me, though a little slower still, is,

RootFinding:-NextZero( v0->HeightatHalt( v0, 1.2, xf ) - yf, 30 );

@Carl Love For fun here is a modification, using events to allow dsolve/numeric itself to find the height at which the target distance is attained.

Of course, one can make it fancier (augment the given event by diff(y(t),t)<0 or add a foremost event for y(t)=yf, etc) to try and speed it up. But perhaps such additional discontinuity makes it harder for root-finders.

This is pretty fast to execute in Maple 18.01. If one throws the compile=true option into the call to dsolve then the rootfinding is a bit faster but there is additional overhead in the dsolve call.


restart:

interface( warnlevel = 0 ):

m := 0.145:      #mass of baseball

g := 9.81:       #gravity

C_d := 0.35:     #drag coefficient

r := 0.037:      #radius

y0 := 1.5:       #y(0): height from which ball is hit

yf := 2.5:       #height of home-run fence

xf := 114:       #home-run distance

theta := Pi/4.:  #angle of elevation of the hit

v_x := diff( x(t), t ):

v_y := diff( y(t), t ):

eqx := diff( v_x,t) = -((C_d)*rho*Pi*(r^2)*(v_x)*sqrt((v_x)^2 +(v_y)^2))/(2*m):

eqy := diff( v_y,t) = -((C_d)*rho*Pi*(r^2)*(v_y)*sqrt((v_x)^2 +(v_y)^2))/(2*m)-g:

ics := x(0) = 0, y(0) = y0, D(x)(0) = v0*cos(theta), D(y)(0) = v0*sin(theta):

Sol := dsolve( { eqx, eqy, ics  }, numeric, parameters = [ v0, rho, xhalt ],
               events = [ [x(t) - xhalt, halt] ], output = listprocedure ):

Y := eval( y(t), Sol ):
HeightatHalt := proc( v0, rho, xtarget )
   Y( parameters = [ :-v0 = v0, :-rho = rho, :-xhalt = xtarget ] );
   Y( 20 ); # 20 second airborne limit
end proc:

fsolve( 'HeightatHalt'( v0, 1.2, xf ) = yf, v0 = 30..100 );

46.65980695

fsolve( 'HeightatHalt'( v0, 1.2*0.9, xf ) = yf, v0 = 30..100 );

44.92447287


Download bbhalt.mw

By the way, I was able to use fsolve instead of Bisection in your code, in Maple 18.01, without a problem. Also I suspect that providing a judicious range to the fsolve call inside your ClearTheFence might help its speed a bit.

@maple2015 Could you have a button that fired up Maplets:-Examples:-GetFile ? Or a button that did something similar using Maplets:-Elements:-FileDialog ?

@Carl Love Perhaps you intended it more like,

radius= .1*((rhs-lhs)(minMax(P)))

so that it worked for wider z-ranges. Eg,

P:=plot3d( x^2+y^2, x=-10..10, y=-10..10, shading=zhue ):

(Of course you might wrap the tubeplot creation within a procedure, to avoid having to call minMax more than once.)

Another issue is that zhue shading gets adjusted by the GUI renderer to accomodate the view. For example,

P:=plot3d( x^2+y^2, x=-10..10, y=-10..10, shading=zhue, view=50..250 ):

That might be handled by picking off the z-range from the VIEW substructure (if detected) and using that to adjust what is returned by minMax.

If you plan on raising the matrix to many, many different powers, because you want many results from those, then you might consider the following: diagonalize the matrix just once to get it factored like p^(-1).d.p where d is diagonal and m^n=p^(-1).d^n.p due to orthogonality in p. (You just raise entries of vector form of d, and the turn into diagonal matrix, rather than raising d to power n.) Once the single time cost of the eigenvector computation gives you those factors you can raise to many different powers quickly, or even in parallel using the Grid package.

@Carl Love I would expect that the cost of the extra function calls would make a recursive implementation relatively expensive when the number of total iterations becomes very large. But sometimes it can be easier to set up a recursive method in code, which is only why I mentioned it. As usual for this site. the Asker didn't give a lot of details.

How about writing a procedure that admits a list of the specifics of remaining loops as one of its arguments? Then it could loop, and inside that loop call itself with the pared list of specifics?

acer

@wolfman29 Axel meant more decimal places in your data (constant values you used, like parameters). If you have 'em...

Or you could try root finding (fsolve) of your expression plus a small fudge factor (constraint violation). Or you could tryOptimization instead (with objective any constant, and expression equal to zero as constraint, and use constraint violation options). Or you could use the DirectSearch v.2 package which can also do such things.

BTW, I got the previously found partial results much faster by using the range option for fsolve. You even put in a way to shoehorn it into Denom. But you didn't make use of it? Another possible speedup might be to use immediately previously found root as initial guess, at each step after the first.

@Carl Love That works even in MapleV R5.

You've asked similar questions twice before, with an uploaded worksheet by the same name. This file and question might be quite different and new, of course, but I would still like to ask which version of Maple you're using. The previous two questions were marked as Maple 13, and so is the marking of this one as Maple 18 correct?

acer

Having submitted this I see that while I was busy Preben gave my first suggestion as his last suggestion. Apologies: no offence intended, Preben.

It's a shame that querying the Help system for IsSimilar brings up a page for the inert IsSimilar (for use with modp) as its first choice, ranked higher than the page for LinearAlgebra:-IsSimilar. Most students will not want that first suggestion of the Help system.

It's also a shame that Student:-LinearAlgebra:-IsSimilar has yet a third style of returning the transformation Matrix. How confusing.

acer

@Markiyan Hirnyk The plot that the Asker showed as Maple output is the same as what one gets by issuing the command,

smartplot[cos, x]( cos*x/(x^2+2*x)=0 );

And that is what the context-menu system and PlotBuilder command can suggest here. And the black arrow between 2D expression and the plot, in the original Question, clearly indicates that context-menu plotting was done.

Enter the expression,

cos*x/(x^2+2*x)

and then right-click, and select from the context-menus the item "Plots" -> "2-D Implicit Plot" -> "(cos, x)". That invokes the `smartplot` call above.

I only called it an implicit plot because that was the term used in the context-menu item that gave the same plot as was originally shown. I've edited to now use the quoted term "2-D Implicit Plot" exactly.

It is clear that the Askers problem was indeed that he used cos*x instead of cos(x).

First 341 342 343 344 345 346 347 Last Page 343 of 593