13776 Reputation

19 Badges

14 years, 59 days

MaplePrimes Activity

These are answers submitted by tomleslie

be able to solve it numerically, provided

  1. you supply numeric values for the parameters q1, q2, q3, q4
  2. you supply three initial/boundary conditions for the ODE

In the attached, I just use some random values for thes quantities

ode := -(q2-q4)*(q2-q3)*(q1-q4)*(q1-q3)*y(w)^2+(q1+q2-q3-q4)*(2*q1*q2-q1*q3-q1*q4-q2*q3-q2*q4+2*q3*q4)*(diff(y(w), w))*y(w)+(-2*q1^2-2*q1*q2+3*q1*q3+3*q1*q4-2*q2^2+3*q2*q3+3*q2*q4-6*q3*q4)*(diff(y(w), w))^2+(q1-q2+q3-q4)*(q1-q2-q3+q4)*(diff(y(w), w, w))*y(w)+(3*q1+3*q2-3*q3-3*q4)*(diff(y(w), w, w))*(diff(y(w), w))-3*(diff(y(w), w, w))^2+(-q1-q2+q3+q4)*(diff(y(w), w, w, w))*y(w)+2*(diff(y(w), w, w, w))*(diff(y(w), w)) = 0

-(q2-q4)*(q2-q3)*(q1-q4)*(q1-q3)*y(w)^2+(q1+q2-q3-q4)*(2*q1*q2-q1*q3-q1*q4-q2*q3-q2*q4+2*q3*q4)*(diff(y(w), w))*y(w)+(-2*q1^2-2*q1*q2+3*q1*q3+3*q1*q4-2*q2^2+3*q2*q3+3*q2*q4-6*q3*q4)*(diff(y(w), w))^2+(q1-q2+q3-q4)*(q1-q2-q3+q4)*(diff(diff(y(w), w), w))*y(w)+(3*q1+3*q2-3*q3-3*q4)*(diff(diff(y(w), w), w))*(diff(y(w), w))-3*(diff(diff(y(w), w), w))^2+(-q1-q2+q3+q4)*(diff(diff(diff(y(w), w), w), w))*y(w)+2*(diff(diff(diff(y(w), w), w), w))*(diff(y(w), w)) = 0


params := [q1 = 1, q2 = -2, q3 = -3, q4 = 4]; ics := y(0) = 0, (D(y))(0) = 1, (D[1, 1](y))(0) = 0; ans := dsolve(eval([ode, ics], params), numeric); with(plots); odeplot(ans, [w, y(w)], w = 0 .. 5)





You could start by typing

?How do I solve an ordinary differential equation

at the Maple prompt. If yoou need more info, check the Maple help for the command dsolve()

values for 'm' and 'l' (I just used 1 for both), then you could try DEplot3d() as shown in the attached. I just guessed a value for the range of the dependent variable p(t).


For some reason, this particular plot won't render on this site, by I can assure you that this code

  sys := { diff(r(t),t)=p(t)/m,
  sys1:=subs({n=1,k=1, m=1, l=1},sys);
  p1:=DEplot3d( sys1,
                [r(t), p(t), phi(t)],

will produce this plot




just your misunderstanding of how a plot command "works". When plotting some expression, the plot() command will evaluate the expression at ~200 points (by default), and then produce a "straight line" between adjacent points. The fact that you "see" this as a smooth "curve" is an optical illusion.

In your first example the points are only about 1.8 degrees apart (360/200) by default. In your second example, the points will be 3600000/200 degrees apart (by default) - so 18000degrees or about 50 complete revolutions. - so essentially you end up drawing a straight line from some point on the cicumference of a circle to some other (more or less random) point on the circumference. These lines will fill up the interior of the circle very quickly. You can get around this by increasing the option numpoints drastically and then wait a while for your plot to appear


the styles you want using conventional 'labels' and 'labelfont' options, see the attached

NB the double square brackets around the unit only appear on this site - they do not occur in the original worksheet

  plot( x,
        labels=[ typeset(foo*Unit(kg/m^3)),
                 typeset(bar*Unit(m) )
        labelfont=[times, bold, 14]

Automatically loading the Units[Simple] subpackage







  1. Two of your constraints are on the form s<p<q. Each of these has to be split into two simple inequalities, ie s<p, p<q. This fix is trivial
  2. Both the expression you want to minimise and one of the constraints contain terms such as 91201.82720*(-0.05*i + 0.04)*sqrt(-i), - 912.0182718*i/sqrt(-i). Since 'i' is restricted to range 0..1, the sqrt(-i) factor in both of these terms is going to produce a complex value, which the optimizer cannot handle. ( All optimizers essentially work on the basis of determining whether an expression using the current variable values is greater than or less than the expression with the previous set of variables. However for complex values, the term "greater than or less than" has no meaning. So you have to ask, why do complex values occur?? Is this expected?
  3. If the existence of complex values is unexpected then there must be an error in yur derivation somewhere. These complex valuesappear to arise from the evaluation of the quantities 'Q' and 'Qr'

I suggest you read the help page at ?pdsolve/numeric, very carefully

The attached at least executes, although I can't say I'm wildly convinced by the answer which Maple provides

Inline displlay of worksheets on this site appears to be broken - again!


the command line (which *seems* to be true), then you  can add


to the end of your probem.mpl file. This will produce 1/x

If you don't need/want to show the steps, then you can just change the problem.mpl file to


which will also produce 1/x;

Your integral can be solved without resdtriction(s)- see the attached

  int(sin(m*Pi*y/a), y = 0 .. b);





as in the attached ( a "toy" example)


with( DynamicSystems ):
sys1 := ZeroPoleGain([0,1],[2,4,6],1):
p1:=NyquistPlot(sys1, color=blue);
sys2 := ZeroPoleGain([0,1],[1,3,5],1):
p2:= NyquistPlot(sys2, color=red);






to set the x and y-ranges appropriately - yours are much too small.

See the attached

# Plot with OP's original ranges for x and y, which are
# waaaaaaay too small to see a complete ellipse
  plots:-implicitplot(TW, x=16666666..415000000,y=-333333..83000000);
# Plot withh appropriate ranges for x- and y. Note that x and y are scaled
# differently on plot which *distorts* the shape
  plots:-implicitplot(TW, x=-2e9..3e9,y=-10e08..10e09, axes=boxed);
# Force the x- and y- scales to be the same
  plots:-implicitplot(TW, x=-2e9..3e9,y=-10e08..10e09, axes=boxed, scaling=constrained);










hack something in the Finance() package to produce what you want, but since there is a simple closed form expressionj for a standard mortgage (see about halfway down on, it is pretty trivial to do in an explicit manner.

In the attached, there are two methods of doing this calculation, The first uses a recursive function call, basically keep adding interest and subtracting payments, until the duration is up, then solve for the payment which makes the outstanding loan zero at the end of the duration. The second just uses the formula from the above Wikipedia page - you can google for the derivation

You can give students extra points if they manage to get the output to appear (as in the attached), by using the  settings under the menu Format->NumericFormatting

  Mortgage:= proc( p, r, Duration:=12*30)
                   local Rate:=convert(r, float):
                   if   Duration=0
                   then return solve(p);
                   else thisproc( p*(1+Rate/12/100)-Payment, Rate, Duration-1);
             end proc:
# Usage:
# Mortgage( AmountOfLoan, InterestRate, DurationInMonths)
  Mortgage(150000*0.8, 9, 12*30);



# Using a closed-form expression, rather than the above
# (recursive) function call: see
  mgage:=( P, r, n)-> evalf(r/100/12*P*(1+r/100/12)^n/((1+r/100/12)^n-1)):
  mgage(150000*0.8, 9, 12*30);





is to use isolate() as in the attached

  eq:=(3*y - 2)/3 + (2*y + 3)/3 = (y + 7)/6;
  isolate(eq, y);

(5/3)*y+1/3 = (1/6)*y+7/6


y = 5/9




the ratio of circumference to diameter is Pi not pi - so the attached will work


a := (.3*exp(-2*t/(x^2+.2+.4*x))*(x^2+.2+.4*x)-(.6*(x^2+.2+.4*x))*exp(-2*t/(x^2+.2+.4*x))*(((1/2)*x^2+.2*x+.1)*arctanh(-(2.500000000*I)*(.2+x))-(.2000000000*I)*(.2+x))/(.4*arctanh(-(2.500000000*I)*(.2+x))*x+arctanh(-(2.500000000*I)*(.2+x))*x^2+.2*arctanh(-(2.500000000*I)*(.2+x))-0.8000000000e-1*I-(.4000000000*I)*x))*exp(2*t/(x^2+.2+.4*x))



plot3d(a, x = 2*Pi .. 4*Pi, t = 0 .. 10)





completely clear to me what you want since you state that

i need the solution  for Y=0 and Y=1

but you also seem to require the integral expression

(int(U(Y)*Theta(Y), Y = 0 .. 1))/(int(U(Y), Y = 0 .. 1));

The attached covers both of these requirements.

  kp := .3:

  Pr := .3: N := .5: g := .5: A := 1: B := 0: M := .5: lambda := .5: Ec := .5:

  rf := 997.1: kf := .613: cpf := 4179: `&sigma:f` := 0.5e-1:
  p1 := 0.1e-1: sigma1 := 2380000: rs1 := 4250: ks1 := 8.9538: cps1 := 686.2:
  p2 := 0.5e-1: sigma2 := 3500000: rs2 := 10500: ks2 := 429: cps2 := 235:
  a1 := (1-p1)^2.5*(1-p2)^2.5:
  a2 := (1-p2)*(1-p1+p1*rs1/rf)+p2*rs2/rf:
  a3 := 1+3*((p1*sigma1+p2*sigma2)/`&sigma:f`-p1-p2)/(2+(p1*sigma1+p2*sigma2)/((p1+p2)*`&sigma:f`)-((p1*sigma1+p2*sigma2)/`&sigma:f`-p1-p2)):

  a4 := (1-p2)*(1-p1+p1*rs1*cps1/(rf*cpf))+p2*rs2*cps2/(rf*cpf):
  a5 := (ks1+2*kf-2*p1*(kf-ks1))*(ks2+2*kf*(ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1))-2*p2*(kf*(ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1))-ks2))/((ks1+2*kf+p1*(kf-ks1))*(ks2+2*kf*(ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1))+2*p2*(kf*(ks1+2*kf-2*p1*(kf-ks1))/(ks1+2*kf+p1*(kf-ks1))-ks2))):

  OdeSys := (diff(U(Y), Y, Y))/(a1*a2)+Theta(Y)+N*(Theta(Y)*Theta(Y))-a3*(M*M)*U(Y)/a2-(kp*kp)*U(Y)/(a1*a2),
          a5*(diff(Theta(Y), Y, Y))/a4+Pr*Ec*((diff(U(Y), Y))^2+U(Y)^2*(kp*kp))/(a1*a2):
  Cond := U(0) = lambda*(D(U))(0), Theta(0) = A+g*(D(Theta))(0), U(1) = 0, Theta(1) = B:

  Ans := dsolve([OdeSys, Cond], numeric, output = listprocedure):
# Get values for U(0), Theta(0), U(1), Theta(1)
# Note that the BCS ought to guarantee that the latter
# two are both equal to 1
# Perfom the integral which the OP *appears* to want
  Int( eval(U(Y), Ans)(Y)*eval(Theta(Y), Ans)(Y), Y=0..1)
  Int(eval(U(Y), Ans)(Y), Y=0..1);
# Plot a few functions (just for illustration
         ( Ans,
           [ [Y, U(Y)],
             [Y, Theta(Y)],
             [Y, U(Y)*Theta(Y)]
           color=[red, blue, black],
           legend=[typeset(U(Y)), typeset(Theta(Y)), typeset(U(Y)*Theta(Y))]


(Theta(Y))(0) = HFloat(0.6670135632234151)


(U(Y))(0) = HFloat(0.1130465092117131)


(Theta(Y))(1) = HFloat(0.0)


(U(Y))(1) = HFloat(0.0)


(Int(`U(Y)`(Y)*`Theta(Y)`(Y), Y = 0 .. 1))/(Int(`U(Y)`(Y), Y = 0 .. 1))







4 5 6 7 8 9 10 Last Page 6 of 207