Carl Love

Carl Love

28050 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You have used f in two different ways in your question---as the function name and as one of the coefficients. I changed the function name to g. Here's how to solve the problem:

restart:
g:= x-> d*x^2+e*x+f:
solve({g(0)=4, g(3)=7, g(-2)=18}, {d,e,f});

You need to use a Vector (or an Array) as temporary local storage for the list. Maple will not let you assign directly to a parameter.

InsertionSort:= proc(L::list)
local A:= < L >, j, key, i;
     for j from 2 to nops(L) do
          key:= A[j];
          for i from j by -1 to 2 while A[i-1] > key do
               A[i]:= A[i-1]
          end do;
          A[i]:= key
     end do;
     convert(A, list)
end proc;

Also note that the j loop completely surrounds the i loop, and that Vectors (and lists) are indexed starting at 1, not 0.

You usually cannot remove a removable singularity by using eval. You need to use limit instead. In your case, change

eval(diff(Psi_, epsilon), epsilon= 0);

to

limit(diff(Psi_, epsilon), epsilon= 0);

This will take a few more seconds to process, but definitely less than a minute.

Let T be a Vector of your time values, and let Y be a Vector of the corresponding population values (or whatever you are measuring if not population). Then, in its most basic form, the command would be

Statistics:-NonlinearFit(A*exp(B*exp(C*t)), T, Y, t);

See ?Statistics,NonlinearFit .

Usually, when you want to convert to binary, you want to access the individual bits/digits. The command Bits:-Split returns a list of the bits.

nums:= [10,3,90,6]:
Bits:-Split~(nums);
    [[0, 1, 0, 1], [1, 1], [0, 1, 0, 1, 1, 0, 1], [0, 1, 1]]

Note that each list of bits is returned in order from least-significant bit to most-significant bit. See ?Bits,Split .

The above pertains to converting nonnegative integers only.

To search for the global optimum in univariate problems with no general constraints but finite bounds, use method= branchandbound.

Note that the method is somewhat confused by the strict inequality at 10 in your piecewise. If you change it to x <= 10, then Maximize will return x = 10.

Some general principles to make numerical analysis routines run faster are

  1. set Digits to 15 (in general, but not always),
  2. create all Matrices and Vectors with option datatype= float[8],
  3. use evalhf as much as possible.

See ?evalhf and ?LinearAlgebra,General,EffNumLA .

You should post some code that seems to run particularly slowly, and I'll show you how to improve its efficiency.

I don't think that it makes sense to maximize one's chances (chances of winning presumably). I think that the thing to maximize is the expected value of participating.

The optimal strategy is going to be the same for everybody, and there's a sort of prisoner's dilemma involved here. The optimal straegy is going to be something akin to this: The employees who want to participate hold a preliminary drawing to select three of their members. Then those three, and only those three, each buy one ticket. Then those 3 have a 100% chance of winning. If that is not feasible, then each employee should use a computer to draw a random integer from 1 to 1600. Anyone who draws a 1, 2, or 3 should buy one ticket. Then each of those has close to a 100% chance of winning.

Is this what you had in mind?

plots:-fieldplot([piecewise(x+y > 0, x), piecewise(x+y > 0, y)], x= -10..10, y= -10..10);

 

Let x represent the overall expression, let n represent the numerator, and let d represent the denominator. We have the following system of three equations:

solve({x=1+n/d, n=3+x/n, d=2+d/x}, {x,n,d});

Note that iquo and irem can be done together with a single call to either. Here's how I'd write your procedure:

euclid:= proc(m::posint, n::posint)
local q, r1:= m, r2:= n, r3;
     while r2 <> 0 do
          q:= iquo(r1,r2,'r3');  #or r3:= irem(r1,r2,'q');
          printf("%d = %d*%d + %d\n", r1, q, r2, r3);
          (r1,r2):= (r2,r3)
     end do;
     r1
end;

To get f(6) and f(15), just enter the procedure into Maple, then enter f(6) and f(15).

All four can be entered directly into dsolve. The first two require the addition of option implicit


Problem 1:

restart:

dsolve({(x+epsilon*y(x))*diff(y(x),x)+y(x)=0, y(1)=1}, implicit);

-(1+(1/2)*epsilon)/y(x)+x+(1/2)*epsilon*y(x) = 0

solve(%, y(x));

(-x+(epsilon^2+x^2+2*epsilon)^(1/2))/epsilon, -(x+(epsilon^2+x^2+2*epsilon)^(1/2))/epsilon

Problem 2:

restart:

dsolve({(x^n+epsilon*y(x))*diff(y(x),x)+n*x^(n-1)*y(x)=m*x^(m-1), y(1)=b}, implicit);

y(x)*x^n-x^m+(1/2)*epsilon*y(x)^2-b+1-(1/2)*epsilon*b^2 = 0

solve(%, y(x));

(-x+(b^2*epsilon^2+2*x^m*epsilon+2*b*epsilon+x^2-2*epsilon)^(1/2))/epsilon, -(x+(b^2*epsilon^2+2*x^m*epsilon+2*b*epsilon+x^2-2*epsilon)^(1/2))/epsilon

Problem 3:

restart:

Sol:= dsolve({diff(u(t),t$2)+u(t)+epsilon*u(t)^3=0, u(0)=A, D(u)(0)=0});

u(t) = RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))*((-2*epsilon-4)/((epsilon*RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))^2-epsilon-2)*(epsilon+2)))^(1/2)*JacobiSN(((1/2)*(2*epsilon+4)^(1/2)*t+InverseJacobiSN(A/(RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))*(-2/(epsilon*RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))^2-epsilon-2))^(1/2)), RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))*(-(epsilon+2)*epsilon)^(1/2)/(epsilon+2))/(-2/(epsilon*RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))^2-epsilon-2))^(1/2))*((-2*epsilon-4)/((epsilon*RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))^2-epsilon-2)*(epsilon+2)))^(1/2), RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))*(-(epsilon+2)*epsilon)^(1/2)/(epsilon+2))

indets(%, specfunc(anything, RootOf));

{RootOf(_Z*2^(1/2)*((A^2*_Z^2*epsilon-A^2*epsilon-2*A^2+2*_Z^2)/_Z^2)^(1/2)*(-(2*A^2*_Z^2*epsilon^2-2*A^2*epsilon^2-4*A^2*epsilon-4*epsilon-8)/(epsilon+2))^(1/2))}

alias(R=%[]);

R

Sol;

u(t) = R*((-2*epsilon-4)/((epsilon*R^2-epsilon-2)*(epsilon+2)))^(1/2)*JacobiSN(((1/2)*(2*epsilon+4)^(1/2)*t+InverseJacobiSN(A/(R*(-2/(epsilon*R^2-epsilon-2))^(1/2)), R*(-(epsilon+2)*epsilon)^(1/2)/(epsilon+2))/(-2/(epsilon*R^2-epsilon-2))^(1/2))*((-2*epsilon-4)/((epsilon*R^2-epsilon-2)*(epsilon+2)))^(1/2), R*(-(epsilon+2)*epsilon)^(1/2)/(epsilon+2))

Problem 4:

restart:

dsolve({diff(y(x),x$2)+2*diff(y(x),x)^2+3*diff(y(x),x) = -sin(x), y(0)=1, D(y)(0)=0});

y(x) = -(3/4)*x+(1/2)*ln((MathieuC(-9, -4, -(1/4)*Pi+(1/2)*x)*MathieuSPrime(-9, -4, (1/4)*Pi)+3*MathieuC(-9, -4, -(1/4)*Pi+(1/2)*x)*MathieuS(-9, -4, (1/4)*Pi)+3*MathieuS(-9, -4, -(1/4)*Pi+(1/2)*x)*MathieuC(-9, -4, (1/4)*Pi)+MathieuS(-9, -4, -(1/4)*Pi+(1/2)*x)*MathieuCPrime(-9, -4, (1/4)*Pi))/(MathieuSPrime(-9, -4, -(1/4)*Pi+(1/2)*x)*MathieuC(-9, -4, -(1/4)*Pi+(1/2)*x)-MathieuCPrime(-9, -4, -(1/4)*Pi+(1/2)*x)*MathieuS(-9, -4, -(1/4)*Pi+(1/2)*x)))+1

 


Download 4_dsolves.mw

Let X:= [x1, ..., xm] and Y:= [[y11, ..., y1n], ..., [ym1, ..., ymn]]. Then

plot([[[X[i],Y[i][j]] $ i= 1..m] $ j= 1..n], style= point);

This version uses color to show which Y-list the point came from.

Let me know how that goes.

Here are some hints: Each geometric object asked for can be created with a single command from ?geom3d with no intermediate computation required. Just follow the syntax shown in the help files. The commands required are, in order: with, ?geom3d,point , point, point, ?geom3d,line , ?geom3d,plane , ?geom3d,intersection , ?geom3d,sphere (with the the centername option),  line, ?geom3d,FindAngle , ?geom3d,coordinates , and ?geom3d,intersection . And you'll need evalf to get the decimal approximation for the first answer.

First 344 345 346 347 348 349 350 Last Page 346 of 395