Carl Love

Carl Love

28025 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Here are three solutions. My preference is strongly for the third of these, which avoids the need for any assign statements and any unevaluation quotes. Note that in the first solution, each variable name is surrounded by two pairs of single quotes, not one pair of double quotes.


restart:

ma[1]:= [-885.880598855072776, [''bh''= 0., ''g0h''= 0., ''g1h''= 0.825946224722250e-4]]:

ma[2]:= [-877.957885609114328, [''bh''= 347.116836805625, ''g0h''= 0., ''g1h''= 0.164861392564e-3]]:

ma[3]:= [-863.445203144006655, [''bh''= 0., ''g0h''= 0., ''g1h''= 0.787090377403668e-4]]:

avb:= 90.5276611129000:  avg0:= 0:  avg1 := 0.92225359e-4:

for j to 3 do

     assign(ma[j][2]);

     A[j]:= [(avb-bh)^2, (avg0-g0h)^2, (avg1-g1h)^2]

end do;

[8195.257426, 0., 0.9275108611e-10]

[65838.00509, 0., 0.5275993377e-8]

[8195.257426, 0., 0.1826909404e-9]

restart:

ma[1]:= [-885.880598855072776, [0., 0., 0.825946224722250e-4]]:

ma[2]:= [-877.957885609114328, [347.116836805625, 0., 0.164861392564e-3]]:

ma[3]:= [-863.445203144006655, [0., 0., 0.787090377403668e-4]]:

avb:= 90.5276611129000:  avg0:= 0:  avg1:= 0.92225359e-4:

for j to 3 do

     assign(['bh', 'g0h', 'g1h']=~ ma[j][2]);

     A[j]:= [(avb-bh)^2, (avg0-g0h)^2, (avg1-g1h)^2]

end do;

[8195.257426, 0., 0.9275108611e-10]

[65838.00509, 0., 0.5275993377e-8]

[8195.257426, 0., 0.1826909404e-9]

restart:

ma[1]:= [-885.880598855072776, [bh= 0., g0h= 0., g1h= 0.825946224722250e-4]]:

ma[2]:= [-877.957885609114328, [bh= 347.116836805625, g0h= 0., g1h= 0.164861392564e-3]]:

ma[3]:= [-863.445203144006655, [bh= 0., g0h= 0., g1h= 0.787090377403668e-4]]:

avb:= 90.5276611129000:  avg0:= 0:  avg1:= 0.92225359e-4:

for j to 3 do

     A[j]:= eval([(avb-bh)^2, (avg0-g0h)^2, (avg1-g1h)^2], ma[j][2])

end do;

[8195.257426, 0., 0.9275108611e-10]

[65838.00509, 0., 0.5275993377e-8]

[8195.257426, 0., 0.1826909404e-9]

 


Download Three_solutions.mw

Here are two ways that rely on the fact that op(0,f(t)) extracts f:

D~(map2(op, 0, x(t))) =~ 0:
(D@(x-> op(0,x)))~(x(t)) =~ 0:

The first method is more efficient.

Your code refers to signum in the line defining eq. The signum requires an argument---signum of what? In other words, it should be signum(...with some algebraic expression in the parentheses. After you correct that, then proceed like this:

sol_2:= dsolve({cond, eq}, numeric, parameters= [X]);
sol_3:= proc(X)
     sol_2(parameters= [X]);
     eval(V(z), sol_2(3*l))
end proc;

Digits:= 4:
fsolve(sol_3);

I'm not sure about the precision control. You may need to adjust Digits or the error options of dsolve. I can't adjust it until you fix the signum.

 

You didn't enter the procedure dsnumsort (like we discussed before)! But, actually, with a small modification to the rest of the code, you don't need it. That procedure is just a very, very crude substitute for two-argument eval (or subs) applied to the result returned by dsolve. (It's amazing how bad the Maple code is in some otherwise great books---this one being Solving Problems in Scientific Computing Using Maple and Matlab by W. Gander & J. Hrebicek.) You just need to replace the line

X[i] := rhs(NsT[C1]); Vx[i] := rhs(NsT[V1]); Y[i] := rhs(NsT[C2]); Vy[i] := rhs(NsT[V2]);

with

(X[i],Y[i],Vx[i],Vy[i]):= eval([x(t),y(t),diff(x(t),t),diff(y(t),t)], NsT)[];

Use the above if you want to save the values XVxYYx, and MofI. If you just want the plot, then Preben's Answer suffices.

 

It's hard to figure out what exactly you're talking about without you providing an example. But, anyway, here's an example that may help. I create a random polynomial with several independent variables:

p:= randpoly([x,y,z,w]):

Now I extract the independent variables into a set. Note that the order that they appear in the set is not the order that I originally listed them. The order that they appear is actually well-defined, but it may appear random to you.

S:= indets(p, name);

     S := {w, x, y, z}

Now I loop through the independent variables, are get the derivative with respect to each.

for v in S do dpd||v:= diff(p,v) end do;

 

(In this Answer, I refer several times to Windows Task Manager (WTM). In order to apply this Answer to another operating systems (OS), you'll need to use that OS's equivalent to WTM. The names of the tasks may also differ on other OSs.)

Generally the size of an expression that can be handled by Maple's computational engine (aka "the kernel") is limited only by your system's available memory. Use WTM to check your available memory. If the percentage of memory in use is in the high nineties, then the whole system may be rather sluggish and unresponsive and you may need to explicitly kill some processes with WTM (or close them "naturally" if you have the patience to wait for that). You should either free up some memory by either closing some unrelated processes or closing some other open Maple worksheets (documents) or use WTM to kill the mserver.exe process that is consuming the most memory. The Maple GUI will display a message "Kernel connection has been lost. You should save this worksheet and restart Maple." You should save the worksheet, close it, and reopen it, but there is no need to restart Maple---your other open worksheets will be fine (if they are all using different kernels). 

The size of expression that can be displayed by Maple's Standard GUI is much more limited. If you're working with large expressions, you should be careful to end commands with a colon to avoid their display. If you accidentally enter a command that will display a large result, it could be that the kernel has finished computing the expression but the GUI has gotten stuck formatting it for display (or perhaps not stuck but taking an inordinate amount of time doing so). You can detect if this has happened by using WTM: no processes named mserver.exe will be consuming any processor. In that case, you need to kill the GUI with WTM. It will be a process named something like "Maple 18", "maplejava.exe", or "Java(TM) Platform SE binary". Find such a process that is consuming processor and kill it. This will unfortunately abruptly close (unsaved) all your open worksheets. Restart Maple, and from the File menu, select Recent Documents -> Restore Backup. This should open and restore all the worksheets. 

Try pressing Control+J.

If I understand your first question correctly, you have an expression (that I'll call ex), and you want to select its terms that contain k to the first power. That can be done by

select(t-> degree(t,k)=1, ex);

 

I have no advice regarding your second question.

You can set the relative error for an entire session by the setting the Digits environment variable. It's set to 10 by default. But what you want is akin to setting the absolute error for an entire session. There's no easy way to do that (maybe no way at all?). However, you can apply fnormal to any individual expression containing floating-point constants, and it'll turn the small ones into zero.

If you use the hardware-floating-point environment, certain very small numbers will underflow and automatically become 0. This environment is used in the background by default by many (most?) numerical commands when you have Digits set to 15 or less. For example, I noticed that you used exp(-10000) in a call to pdsolve in a recent Question. We can see below that this will be treated as zero:

evalhf(exp(-10000));

     0.

No. That is, I believe, well beyond the capability of any current CAS. Even curves can only be parameterized when f(x,y) has certain special forms, such as polynomial.

The value under the square root sign is negative for any real rho. Therefore both h(rho) and its integral are purely imaginary for any real range of rho. We could plot these imaginary values if you want: Simply replace v(rho) with Im(v(rho)) in the plot command.

In Maple 2015, I tried with the default method= rkf45, and with method= rosenbrock and I had no trouble. Did you try the default method? I confirm that dverk78 and lsode don't work for this problem.

If you'd followed today's discussion in the followups to your prior Question, you would've tried is. It's the most basic command for testing the mathematical equality (over the complex numbers) of expressions. Unfortunately, testeq is very limited in the expressions that it can handle.

is(C45=C54);

     false

(I'm a bit disturbed that you ignored Kitonum's advice (in your prior Question) that you not use I as a variable. I had to substitute J for I below to get meaningful results.)

Here's an explicit proof that the two expressions are fundamentally different: We evaluate each one setting all derivatives and variables to Pi/4, then simplifying.

C45a:= subs(I= J, C45):
C45b:= evalindets(convert(C45a, rational), specfunc(diff), freeze):
C45c:= evalindets(C45b, name, ()-> Pi/4):
simplify(C45c);

C54a:= subs(I= J, C54):
C54b:= evalindets(convert(C54a, rational), specfunc(diff), freeze):
C54c:= evalindets(C54b, name, ()-> Pi/4):
simplify(C54c);

 

RootFinding:-NextZero performs a job similar to fsolve (for real functions only). It's a little trickier to use because you have to carefully adjust its options or else it'll miss roots. But, if you want all the roots in a given interval, it may be a better choice than fsolve. Here's the first 20 positive roots:

K:= N-> KummerM(1/2-sqrt(2*N)/4, 1, sqrt(2*N)):

R:= table([0=0]):
for k to 20 while R[k-1]<10000 do
     R[k]:= RootFinding:-NextZero(K, R[k-1], maxdistance= 10000, guardDigits= 3)
od:

convert(R, list)[2..];

[3.65679345776329, 22.3047305506807, 56.9605153816721, 107.620271629881, 174.282057717514, 256.945030311759, 355.608766328753, 470.273028271534, 600.937671278859, 747.602601263178, 910.267754050297, 1088.93308412430, 1283.59855815621, 1494.26415108509, 1720.92984364050, 1963.59562071823, 2222.26147028210, 2496.92738260118, 2787.59334970751, 3094.25936500266]

Another root-finding command that's supposed to find all the roots in an interval is Student:-Calculus1:-Roots. However, in this case, it only finds 4 of the first 20.

I can't tell what you're doing wrong since you didn't post your code or upload a worksheet. I'll assume that by "deriving" you mean finding the derivative. (The verb form of derivative in mathematical English is, oddly enough, differentiate rather than derive.) To differentiate L with respect to x, enter the command

diff(L, x)

 

First 266 267 268 269 270 271 272 Last Page 268 of 395