tomleslie

13876 Reputation

20 Badges

15 years, 162 days

MaplePrimes Activity


These are answers submitted by tomleslie

trivial to plot the analytical solution for the same parameters as the numerical solutions - either separately or together, see the attached.

One would have to say that the agreement is terrible - a typo somewhere maybe?

restart

ode := diff(theta(y), y, y)+Br*((-3*We*(y+1+(1/2)*x^2)*((9*(1+(1/2)*x^2)^2+9*y^2)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^3/(4*(1+(1/2)*x^2)^7)+3*y*(k+1)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^2/(1+(1/2)*x^2)^5+3*(k+1)^2*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)/(2*(1+(1/2)*x^2)^3)-(-120*lambda*(1+(1/2)*x^2)^4+(63*k^2-36*k+63)*(k-1)*(1+(1/2)*x^2)^3+288*Q*(k^2-(11/8)*k+1)*(1+(1/2)*x^2)^2+486*Q^2*(k-1)*(1+(1/2)*x^2)+324*Q^3)/(15*(1+(1/2)*x^2)^5))/(16*(1+(1/2)*x^2)^2)-3*We*(y-1-(1/2)*x^2)*((9*(1+(1/2)*x^2)^2+9*y^2)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^3/(4*(1+(1/2)*x^2)^7)+3*y*(k+1)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^2/(1+(1/2)*x^2)^5+3*(k+1)^2*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)/(2*(1+(1/2)*x^2)^3)-(-120*lambda*(1+(1/2)*x^2)^4+(63*k^2-36*k+63)*(k-1)*(1+(1/2)*x^2)^3+288*Q*(k^2-(11/8)*k+1)*(1+(1/2)*x^2)^2+486*Q^2*(k-1)*(1+(1/2)*x^2)+324*Q^3)/(15*(1+(1/2)*x^2)^5))/(16*(1+(1/2)*x^2)^2)-3*We*(y-1-(1/2)*x^2)*(y+1+(1/2)*x^2)*(9*y*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^3/(2*(1+(1/2)*x^2)^7)+(3*(k+1))*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^2/(1+(1/2)*x^2)^5)/(16*(1+(1/2)*x^2)^2)+(-3*y*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)/(1+(1/2)*x^2)^2-k-1)/(x^2+2))^2-(1/2)*We*(-3*We*(y+1+(1/2)*x^2)*((9*(1+(1/2)*x^2)^2+9*y^2)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^3/(4*(1+(1/2)*x^2)^7)+3*y*(k+1)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^2/(1+(1/2)*x^2)^5+3*(k+1)^2*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)/(2*(1+(1/2)*x^2)^3)-(-120*lambda*(1+(1/2)*x^2)^4+(63*k^2-36*k+63)*(k-1)*(1+(1/2)*x^2)^3+288*Q*(k^2-(11/8)*k+1)*(1+(1/2)*x^2)^2+486*Q^2*(k-1)*(1+(1/2)*x^2)+324*Q^3)/(15*(1+(1/2)*x^2)^5))/(16*(1+(1/2)*x^2)^2)-3*We*(y-1-(1/2)*x^2)*((9*(1+(1/2)*x^2)^2+9*y^2)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^3/(4*(1+(1/2)*x^2)^7)+3*y*(k+1)*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^2/(1+(1/2)*x^2)^5+3*(k+1)^2*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)/(2*(1+(1/2)*x^2)^3)-(-120*lambda*(1+(1/2)*x^2)^4+(63*k^2-36*k+63)*(k-1)*(1+(1/2)*x^2)^3+288*Q*(k^2-(11/8)*k+1)*(1+(1/2)*x^2)^2+486*Q^2*(k-1)*(1+(1/2)*x^2)+324*Q^3)/(15*(1+(1/2)*x^2)^5))/(16*(1+(1/2)*x^2)^2)-3*We*(y-1-(1/2)*x^2)*(y+1+(1/2)*x^2)*(9*y*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^3/(2*(1+(1/2)*x^2)^7)+(3*(k+1))*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)^2/(1+(1/2)*x^2)^5)/(16*(1+(1/2)*x^2)^2)+(-3*y*(k*(1+(1/2)*x^2)+2*Q-1-(1/2)*x^2)/(1+(1/2)*x^2)^2-k-1)/(x^2+2))^4) = 0

bc := theta(-1-(1/2)*x^2) = 0, theta(1+(1/2)*x^2) = 1

Q__vals := [.5617, .4392, .2564, .1645, 0.659e-1]

`λ__vals` := [0.96e-2, 0.10e-2, 0.93e-2, 0.75e-2, 0.31e-2]; k__vals := [.1, .3, .5, .7, .9]

We__vals := [.1, .3, .5, .7, .9]

colors := [black, red, blue, green, orange, cyan, purple, yellow, navy]; for j to numelems(k__vals) do sol := dsolve(eval([ode, bc], [k = k__vals[j], We = .1, Br = .3, x = 0, Q = Q__vals[j], lambda = `λ__vals`[j]]), numeric); pltn[j] := plots:-odeplot(sol, [y, theta(y)], y = 0 .. 1, axes = boxed, color = colors[j]) end do; plots:-display([seq(pltn[j], j = 1 .. 5)], title = "Numerical Solution")

 

Analytical_sol := -(3*y+3+3*x^2*(1/2))*((-2/3+(-(5/12)*k^2+(1/6)*k-5/12)*Br)*(1+(1/2)*x^2)^5-lambda*Br*((-(1/12)*k^2+(1/6)*k-3/4)*y+Q*(k-1))*(1+(1/2)*x^2)^4-(((1/6)*k+7/6)*y+Q)*Br*((-(1/2)*k+1/2)*y+Q)*(1+(1/2)*x^2)^3+We*Br*((1/4)*(k-1)^2*y^2-(1/3)*Q*(k-5)*y+Q^2)*y*(1+(1/2)*x^2)^2-((1-k)*y+Q)*Br*y^2*Q*(1+(1/2)*x^2)+Q^2*y^3*Br)/(4*(1+(1/2)*x^2)^6)

for j to numelems(k__vals) do sol[j] := eval(Analytical_sol, [k = k__vals[j], We = .1, Br = .3, x = 0, Q = Q__vals[j], lambda = `λ__vals`[j]]); plta[j] := plot(sol[j], y = 0 .. 1, axes = boxed, color = colors[j], linestyle = dash) end do; plots:-display([seq(plta[j], j = 1 .. numelems(k__vals))], title = "Analytical Solution"); plots:-display([seq(plots:-display([pltn[j], plta[j]]), j = 1 .. numelems(k__vals))], title = "Numerical and Analytical Solutions")

 

 

``

 

Download plots.mw

if you posted the complete worksheet for your calculation using the big green up-arrow in the Mapleprimes toolbar.

In the attached I have performed the calculation you seem to want in two completely different ways.

The first uses Maple's bult-in numapprox() and orthopoly() packages.  The second uses an "add-on" package (which you probably don't have?) called OrthogonalExpansions() which is available from the Maple Application Centre. These return the same answers: the desired series is

-0.577350269189626*T(0, x) - 0.309401076758503*T(1, x) - 0.0829037686547607*T(2, x)

The coefficients in this series disagree with those which you report - but since you do not specify how you obtained your coefficients, there isn't much I can say?

When converted to a simple polynomial in 'x', both give

-0.494446500534865 - 0.309401076758503*x - 0.165807537309521*x^2

and both return your measure of "error" as 0.02776926226

  restart;
#
# Use built-in approach with numapproz and orthopoly packages
#
# NB numapprox(0 will only give floating point coefficients
# for the series. Retyrned series is claimed to be accurate
# to 10^-(Digits) - Diigits is on default, ie 10
#
  u:=1/(x-2);
  ser0:= numapprox:-chebyshev(u, x=-1..1):
#
# Restrict to first three terms, and use orthopoly() to
# evaluate the ChebyshevT polynomials. Note that the latter
# returns the same as using the OrthogonalExpansions package
# below
#
  ser2:=add(op([1..3], ser0));
  ser3:=eval( ser2, T=orthopoly[T]);
#
# Compute OP's definition of "error"
#
  evalf(Int(abs(u - ser3), x = -1 .. 1));

1/(x-2)

 

-HFloat(0.5773502691896257)*T(0, x)-HFloat(0.309401076758503)*T(1, x)-HFloat(0.08290376865476069)*T(2, x)

 

-HFloat(0.49444650053486505)-HFloat(0.309401076758503)*x-HFloat(0.16580753730952139)*x^2

 

0.2776926226e-1

(1)

  restart;
  with(OrthogonalExpansions):
  u:=1/(x-2);
#
# Generate ChebyshevT series of 'u' above over the
# range x=-1..1
#
  ser := ChebyshevTSeries(u, x = -1 .. 1, 'n', 'Coefficients');
#
# Restrict series to th first three terms, ie, ChebyshevT(0, x)
# ChebyshevT(1, x), and ChebyshevT(2, x)
#
# Return the restricted series and the coefficients. Compare the
# latter with the values in 'ser2' above
#
  n:= 2;
  ser2:=value(ser);
  evalf(value(Coefficients));
#
# Use the orthopoly() package to convert the ChebyshevT polynomials
# Compare 'ser3' below with 'ser3' in previous execution group
#
  ser3:=evalf(eval(ser2, [ seq( ChebyshevT(i, x)=orthopoly:-T(i,x), i=0..2)]));
#
# Check OP's definition of the "error" between the series
# expansion and the orifginal function
#
  evalf(Int(abs(u - ser3), x = -1 .. 1));

u := 1/(x-2)

 

Sum(piecewise(i = 0, 1/Pi, 2/Pi)*(int(ChebyshevT(i, x)/((x-2)*(-x^2+1)^(1/2)), x = -1 .. 1))*ChebyshevT(i, x), i = 0 .. n)

 

2

 

-(1/3)*3^(1/2)*ChebyshevT(0, x)+2*(Pi-(2/3)*Pi*3^(1/2))*ChebyshevT(1, x)/Pi+2*(4*Pi-(7/3)*Pi*3^(1/2))*ChebyshevT(2, x)/Pi

 

[-.5773502693, -.3094010774, -0.8290376528e-1]

 

-.4944465040-.3094010774*x-.1658075306*x^2

 

0.2776926183e-1

(2)

 

Download cheby.mw

This illustrates how I'd probably do it.

  1. The ODE system is a simple predator-prey model.
  2. A list of solution matrices is obtained by varying one of the initial conditions
  3. The list of solution matrices is plotted as an animation by using the display() command with the option, insequence=true
  4. The list of solution matrices is exported to a (matlab) binary file - I think this is about the only option if one wants to export a list of matrices (as distinct from a single matrix). Obviously you will have to change the path name for this file to something appropriate for your machine
  5. restart;
  6. Import the list of solution matrices generated by 4 above
  7. Repeat 3 above

  restart;
  with(plots):
  odesys:= [ diff(x(t),t) = x(t) - x(t)*y(t),
             diff(y(t),t) = x(t)*y(t) - y(t)
           ] :
  tv:= Array([seq( j, j=0..10,0.1)]):
  ics:= [x(0)=k, y(0)=1]:
#
# Solve odesys, for different initial conditions
# and extract the matrix which contains the results
# to be plotted
#
# 'sol' is a list of such matrices
#  
  sol:= [ seq( dsolve( [odesys[], eval(ics, k=j)[]],
                       numeric,
                       output=tv)[2,1][..,2..3],
               j=1.5..2.5, 0.1
             )
        ]:
#
# Display the results as an animation
#
  display( [seq( listplot( sol[j]), j=1..numelems(sol))], insequence=true);
#
# Export the list of solution matrices
#
  ExportMatrix( "C:/Users/TomLeslie/Desktop/test.mat", sol, target=Matlab);

 

18095

(1)

  restart;
  with(plots):
#
# Import the list of solution matrices which was generated above
#
  ans:=[ImportMatrix( "C:/Users/TomLeslie/Desktop/test.mat", output=matrices)]:
#
# Display the results as an animation
#
  display( [seq( listplot( ans[j]), j=1..numelems(ans))], insequence=true);

 

 

Download toyAnim.mw

This is actually used as an example (with multiple plotting possibilities) on the help page for DEPlot() .

There are *a lot* of options for this command.  One possibility for your specific set of equations is shown in the attached.

If you don't want actual solution curves (for which I admit I just made up initial values), then you can just delete the lines in the attached

[ [x(0)=2,   y(0)=1],
  [x(0)=0.5, y(0)=3],
  [x(0)=1.5, y(0)=1.5]
],
linecolor=[ green, orange, yellow],

  DETools:-DEplot( [ diff(x(t),t) = x(t) - x(t)*y(t),
                     diff(y(t),t) = x(t)*y(t) - y(t)
                   ],
                   [x(t),y(t)],
                   t=0..10,
                   x=0..3,
                   y=0..3,
                   [ [x(0)=2,   y(0)=1],
                     [x(0)=0.5, y(0)=3],
                     [x(0)=1.5, y(0)=1.5]
                   ],
                   linecolor=[ green, orange, yellow],
                   arrows=mediumfill,
                   color=magnitude,
                   dirfield=[10,10],
                   axes=boxed,
                   labels=["prey/density", "predator/density"],
                   labelfont=[times, bold, 12]
                 );

 

 

Download predprey.mw

 

 

on whether you want a 2-D contour plot or a 3-D contour plot! Both come with many options. I suggest you read the help at ?contoutplot.

Examples of 2D and 3D plots for your function are shown in the attached

  restart;
  with(plots):
  f:=(x,y)-> (x - 3)*(y - 2) - 2;
  contourplot( f(x,y),
               x=-10..10,
               y=-10..10,
               contours=20,
               filledregions=true,
               coloring=[red, blue]
             );
  contourplot3d( f(x,y),
                 x=-10..10,
                 y=-10..10,
                 contours=20,
                 filledregions=true,
                 coloring=[red, blue]
               );

proc (x, y) options operator, arrow; (x-3)*(y-2)-2 end proc

 

 

 

 

Download conPlot.mw

  1. Error is not new - it occurs in Maple 2021.2. (i haven't bothered to check anything earlier
  2. "too many levels of recursion" is untrappable. see the excerpt from the Maple help below, with emphasis added

Some exceptions are untrappable. This means that a catch clause will never match such an exception, even if the catchString is missing. The finalStatSeq is also not executed if an untrappable exceptions occurs. The following exceptions are untrappable:
• Computation timed out (this can only be caught by timelimit, which raises a "time expired" exception, which can be caught).
• Computation interrupted (user pressed Ctrl+C, Break, or equivalent).
• Internal system error (which indicates a bug in Maple itself).
• ASSERT or return type or local variable type assertion failure (assertion failures are not trappable because they indicate a coding error, not an algorithmic failure).
Stack overflow (when that happens, generally stack space is insufficient for doing anything like running cleanup code). This includes the "too many levels of recursion" exception at the Maple language level.

 

you are going to have to upload an actual worksheet (using the big green up-arrow in the Mapleprimes toolbar) illustrating the problem, because the attached just works! (although for some reason it won't display inline on this site)

Download oddInt.mw

simply by using 'assuming x>0' on the evaluation of 'f', the attached (which for some reason won't display inline here) computes values for N=8 in about 20 seconds

badInt.mw

you want something like the animation shown in the attached?

  restart:
  with(plots):
  with(geometry):
  _EnvHorizontalName := 'x':
  _EnvVerticalName := 'y':
  a := 7:
  b := 3:
  ellipse(p, x^2/a^2 + y^2/b^2 - 1, [x, y]):
  Fig := proc(t)
              local M, l1,L1,L2,  q, m, c , tex;
              global a, b, p;
              point(M, a*cos(t), b*sin(t));
              if   VerticalCoord(M)=0
              then line(l1, x=HorizontalCoord(M));
              else m:=eval[recurse]( rhs
                                     ( isolate
                                       ( diff
                                         ( eval
                                           ( Equation(p),
                                             y=y(x)
                                           ),
                                           x
                                         ),
                                         diff(y(x),x)
                                       )
                                     ),
                                     [ y(x)=y,
                                       x=HorizontalCoord(M),
                                       y=VerticalCoord(M)
                                     ]
                                   );
                   c:=VerticalCoord(M)-m*HorizontalCoord(M);
                   line(l1, y=m*x+c);
              fi;
              reflection(q, p, l1);
              line(L1, [point(P1, evalf~(coordinates(foci(q)[1]))),
                            point(P2, evalf~(coordinates(foci(q)[2])))]):  
              line(L2, [point(P3, evalf~(coordinates(foci(p)[1]))),
                            point(P4, evalf~(coordinates(foci(p)[2])))]):
              segment(P1P3,[P1,P3]):
              circle(cir1,[P3,2*a]):
              segment(P2P4,[P2,P4]):
              circle(cir1,[P3,2*a]):
              circle(cir2,[P4,2*a]):
              display
              ( [  textplot( [ [ HorizontalCoord(P2), VerticalCoord(P2), "F1"],
                               [ HorizontalCoord(P4), VerticalCoord(P4), "F2"]
                             ],
                             font = [times, 10], align = {below, left}
                           ),            
                   draw( [ p(color = blue),P1P3(color=magenta,linestyle=3),
                           q(color = blue),P2P4(color=magenta,linestyle=3),
                           l1(color = black),L1(color = black),cir1(color=magenta,linestyle=3),
                           cir2(color=magenta,linestyle=3),
                           M(color = blue, symbol = solidcircle, symbolsize = 16),
                           P1(color = red, symbol = solidcircle, symbolsize = 16),
                           P2(color = red, symbol = solidcircle, symbolsize = 16),
                           P3(color = red, symbol = solidcircle, symbolsize = 16),
                           P4(color = red, symbol = solidcircle, symbolsize = 16)
                         ],
                         axes = none,
                         scaling = constrained
                       )
               ]
             );
          end proc:
#
# Change nFig to type float
#
   nFig := 180.0:
#
# Make sure loop index is a float, and change end point
# on loop to nFig-1.0
#
   Figs := seq(Fig(2*Pi*i/nFig), i = 0.0 .. nFig-1.0):
   display(Figs, insequence = true);

 

 

Download ellAgain.mw

This is one of "the other ways" Acer hinted at

  restart;

  with(SignalProcessing):
  with(plots):
  omega:= 10*2*Pi:
  X:= 0.01:
  Y:= 0.5:
  F:= z-> local n:
          add(n/5*cos(n*omega*z),n=1..5):
  M:= Matrix( round(Y/X)+1,
              2,
              (i,j)-> `if`( j=1,
                            (i-1)*X,
                            F((i-1)*X)
                          )
            ):
  pointplot(M, connect=true);
  DFT(M[..,2]);

 

Vector[row](51, {(1) = .4200840182210052+0.*I, (2) = .42175153145122596+0.26012742640677006e-1*I, (3) = .42738545009952356+0.5292178634466152e-1*I, (4) = .4399041444472854+0.8223233612574507e-1*I, (5) = .47323109216063936+.11902239778505733*I, (6) = 1.0877924493528262+.3460516914792915*I, (7) = .3569320314570551+.13827620524187353*I, (8) = .414833894333841+.19085387686449504*I, (9) = .4619399274145152+.24805650622392686*I, (10) = .5560941557902452+.3443189269702432*I, (11) = 1.469836292129841+1.04047557098834*I, (12) = .1354050482831708+.10896002634039997*I, (13) = .3109084313472085+.28343047568220325*I, (14) = .39949979863301566+.41199781946469993*I, (15) = .5322331623495987+.6212252018208262*I, (16) = 1.3813301614844198+1.8291767697037422*I, (17) = -.14619781523913705-.2206346570*I, (18) = .14702941702158098+.25466240414170943*I, (19) = .2515105054815079+.5051011809451251*I, (20) = .36322795606438085+.8581599811601474*I, (21) = .8576247422926545+2.4337623700243673*I, (22) = -.24629997141466162-.8656546337*I, (23) = 0.3677142801562732e-1+.1679034418246177*I, (24) = .10208684947348139+.6576543671923859*I, (25) = .12844055089795586+1.386094247329963*I, (26) = .1388294003759689+4.5060332423908855*I, (27) = .13882940037596955-4.506033242*I, (28) = .12844055089795575-1.386094247*I, (29) = .10208684947348153-.6576543672*I, (30) = 0.36771428015627355e-1-.1679034418*I, (31) = -.24629997141466176+.8656546336811152*I, (32) = .8576247422926543-2.433762370*I, (33) = .3632279560643809-.8581599812*I, (34) = .25151050548150783-.5051011809*I, (35) = .14702941702158098-.2546624041*I, (36) = -.14619781523913708+.22063465695269732*I, (37) = 1.3813301614844198-1.829176770*I, (38) = .5322331623495988-.6212252018*I, (39) = .39949979863301566-.4119978195*I, (40) = .3109084313472085-.2834304757*I, (41) = .1354050482831709-.1089600263*I, (42) = 1.469836292129841-1.040475571*I, (43) = .5560941557902455-.3443189270*I, (44) = .4619399274145148-.2480565062*I, (45) = .414833894333841-.1908538769*I, (46) = .35693203145705504-.1382762052*I, (47) = 1.0877924493528262-.3460516915*I, (48) = .4732310921606394-.1190223978*I, (49) = .43990414444728543-0.8223233613e-1*I, (50) = .4273854500995235-0.5292178634e-1*I, (51) = .42175153145122596-0.2601274264e-1*I})

(1)

 

Download DFT.mw

Since you do not specify where you want to

"rite lettres F1, F2"

For the attached, I just guessed that you might want to label the foci of the rotating ellipse.

If this is not what you want then you have to specify exactly what you want written and where!

  restart:
  with(geometry):
  _EnvHorizontalName := 'x':
  _EnvVerticalName := 'y':
  a := 7:
  b := 3:
  ellipse(p, x^2/a^2 + y^2/b^2 - 1, [x, y]):
  Fig := proc(t)
              local M, l1,L1,L2,  q, m, c;
              global a, b, p;
              uses plots:
              point(M, a*cos(t), b*sin(t));
              if   VerticalCoord(M)=0
              then line(l1, x=HorizontalCoord(M));
              else m:=eval[recurse]( rhs
                                     ( isolate
                                       ( diff
                                         ( eval
                                           ( Equation(p),
                                             y=y(x)
                                           ),
                                           x
                                         ),
                                         diff(y(x),x)
                                       )
                                     ),
                                     [ y(x)=y,
                                       x=HorizontalCoord(M),
                                       y=VerticalCoord(M)
                                     ]
                                   );
                   c:=VerticalCoord(M)-m*HorizontalCoord(M);
                   line(l1, y=m*x+c);
              fi;
              reflection(q, p, l1);
              line(L1, [point(P1, evalf~(coordinates(foci(q)[1]))),
                            point(P2, evalf~(coordinates(foci(q)[2])))]):  
              line(L2, [point(P3, evalf~(coordinates(foci(p)[1]))),
                            point(P4, evalf~(coordinates(foci(p)[2])))]):
              segment(P1P3,[P1,P3]): circle(cir1,[P3,2*a]):segment(P2P4,[P2,P4]):
              circle(cir1,[P3,2*a]): circle(cir2,[P4,2*a]):
              display( [ textplot
                         ( [ [ coordinates(foci(q)[1])[],
                               "F1",
                               align={above, right}
                             ],
                             [ coordinates(foci(q)[2])[],
                               "F2",
                               align={above, right}
                             ]
                           ]
                         ),
                         draw
                         ( [ p(color = blue),P1P3(color=magenta,linestyle=3),
                             q(color = blue),P2P4(color=magenta,linestyle=3),
                             l1(color = black),L1(color = black),cir1(color=magenta,linestyle=3),
                             cir2(color=magenta,linestyle=3),
                             M(color = blue, symbol = solidcircle, symbolsize = 16),
                             P1(color = red, symbol = solidcircle, symbolsize = 16),
                             P2(color = red, symbol = solidcircle, symbolsize = 16),
                             P3(color = red, symbol = solidcircle, symbolsize = 16),
                             P4(color = red, symbol = solidcircle, symbolsize = 16)
                           ],
                           axes = none,
                           scaling = constrained
                         )
                       ]
                     );
          end proc:
#
# Change nFig to type float
#
   nFig := 120.0:
#
# Make sure loop index is a float, and change end point
# on loop to nFig-1.0
#
   Figs := seq(Fig(2*Pi*i/nFig), i = 0.0 .. nFig-1.0):
   plots:-display(Figs, insequence = true);

 

 

 

Download ell.mw

 

as the help (rather unhelpfully) says (emphasis added)

Integrals appearing in answers returned by dsolve are expressed using the inert Int and Intat (not int or intat). These integrals appear when int is not able to calculate them or when it appears to be convenient not to evaluate them during the solving process. You can request the evaluation of these integrals using the value command.

So just add a value() command to your first example, as in the attached.

  restart;
  ode:=diff(y(x),x)=(b*y(x)+sqrt(y(x)^2+b^2-1) )/(b^2-1);
  dsolve(ode);
  value(%);

diff(y(x), x) = (b*y(x)+(y(x)^2+b^2-1)^(1/2))/(b^2-1)

 

x-Intat((b^2-1)/(b*_a+(_a^2+b^2-1)^(1/2)), _a = y(x))+_C1 = 0

 

x+(1/2)*(-b^2*ln(2*((b^2)^(1/2)*(y(x)^2+b^2-1)^(1/2)+b^2+y(x)-1)/(y(x)-1))+b^2*ln(2*((b^2)^(1/2)*(y(x)^2+b^2-1)^(1/2)+b^2-y(x)-1)/(y(x)+1))-b*ln(y(x)-1)*(b^2)^(1/2)-b*ln(y(x)+1)*(b^2)^(1/2)+2*ln(y(x)+(y(x)^2+b^2-1)^(1/2))*(b^2)^(1/2))/(b^2)^(1/2)+_C1 = 0

(1)

 

Download odeVal.mw

The first of the attached files is the code you supplied with added comments just to illustrate why there are o mant errors and ambiguities that it has no chance of ever working

Download OPevents2.mw

Your original question states

Basically there is a very simply system of two differential equations and I would simply like to see an event triggered when the dependent variable is above 2. 

Well you don't state which independent variable, bu the following code will execute, and the dsolve() soltion proces will terminate whenever either dependent variable exceeds 2.
 

  restart;
  fcns := {y(x), z(x)}:
  p := dsolve( { diff(y(x), x) = 5*z(x),
                 diff(z(x), x) = 4*y(x),
                 y(0) = 0,
                 z(0) = 1
               },
               fcns,
               numeric,
               events = [ [y(x) - 2, halt],
                          [z(x) - 2, halt]
                        ]
             ):
  plots:-odeplot( p,
                  [ [x, y(x)],
                    [x, z(x)]
                  ],
                  x=0..0.3,
                  color=[red, blue]
                );

 

NULL

Download odeEvents2.mw

 

In order to plot the point F2 - you will have defined F2! You did define F1 twice, so I'm guessing this is a simple typo

You also need plots[pointplot]()

Both problems fixed in the attached, along with a "neater" way to do it, using the geometry() package

restart:
_local(D):
  f := (x, y) -> 3*x^2 - 3*y*x + 6*y^2 - 6*x + 7*y - 9:
  coeffs(f(x, y)):
A, B, C, D, E, F := %:
theta := 1/2*arctan(B/(A - C)):
solve({-2*A*xc - B*yc = D, -B*xc - 2*C*yc = E}):
assign(%):
x := xcan*cos(theta) - ycan*sin(theta) + xc:
y := xcan*sin(theta) + ycan*cos(theta) + yc:
Eq := simplify(expand(f(x, y))):
xcan^2/simplify(sqrt(-tcoeff(Eq)/coeff(Eq, xcan^2)))^`2` + ycan^2/simplify(sqrt(-tcoeff(Eq)/coeff(Eq, ycan^2)))^`2` = 1:
a := sqrt(-tcoeff(Eq)/coeff(Eq, xcan^2)):
b := sqrt(-tcoeff(Eq)/coeff(Eq, ycan^2)):
c := sqrt(a^2 - b^2):
F1 := [xc + c*cos(theta), yc + c*sin(theta)]:
evalf(%):
F2 := [xc - c*cos(theta), yc - c*sin(theta)]:
evalf(%):
Points := plots[pointplot]([F1[], F2[]], symbol = solidcircle, color = [red], symbolsize = 6):
xcan := plot(yc + tan(theta)*('x' - xc), 'x' = -2 .. 3.5, color = black):
ycan := plot(yc - ('x' - xc)/tan(theta), 'x' = 0.1 .. 1.5, color = black):
Ellipse := plots[implicitplot](f('x', 'y'), 'x' = -2 .. 3.5, 'y' = -2 .. 1.5, color = red, thickness = 2, gridrefine = 5):
labels := plots[textplot]([[0.4, 1.3, "ycan"], [3.2, 0.75, "xcan"]], font = [TIMES, ROMAN, 14]):
plots[display](xcan, ycan, Points, Ellipse, labels, scaling = constrained);

 

  restart:
  with(plots):
  with(geometry):
 _EnvHorizontalName := 'x':
 _EnvVerticalName := 'y':

  ellipse(el, 3*x^2 - 3*y*x + 6*y^2 - 6*x + 7*y - 9):
  evalf~(coordinates~(foci(el)));

  line( L1,
        [ point(P1, evalf~(coordinates(foci(el)[1]))),
          point(P2, evalf~(coordinates(foci(el)[2])))
        ]
      ):
  PerpendicularLine( PL1,
                     point( P3,
                            coordinates( center(el))
                          ),
                     L1
                   ):

  display( [ textplot( [ [rhs~(solve( [Equation(el), Equation(L1)], [x,y])[1])[], "major"],
                         [rhs~(solve( [Equation(el), Equation(PL1)], [x,y])[1])[], "minor"]
                       ],
                       'align'={'right'}
                     ),

             draw( [ el(color=red),
                     L1(color=black),
                     PL1(color=black),
                     P1(color=red, symbol=solidcircle, symbolsize=16),
                     P2(color=red, symbol=solidcircle, symbolsize=16)
                   ],
                   axes=normal
                 )
           ]
         );

[[-.9034508668, -1.090489724], [2.522498486, .3285849626]]

 

 

 

Download ellipse.mw

is that when you *think* you are invoking the procedure, you actually have the code

TEST*(A, B, TOL, maxIter)

Notice the multiplication sign?!!!! This occurs because you have a space between TEST and  (A, B, TOL, maxIter). So the 2D input parser regards this as "implicit multiplication", so inserts a multiplication symbol, ie '*'. Aah the pleasures of using 2D Math input!!

There are multiple instances of the same problem within the procedure itself, usually associated with the print() command, where you have typed print () rather than print() Again the extra space is the problem. It is tricky to find/fix all of these because (obviously) the standard find/replace capability does not work for 2D math input

As a side note, I notice a lot of return commands in your procedure which do not actually return anything. Is this deliberate?

I think I have fixed the problem with "extra" spaces in the attached, although I cannot be sure. The procedure now "executes" - but the problem is that it never seems to stop - I gave it ten minutes on my machine and it was still running! You could try the attached and see if it ever stops executing!!

Any further diagnosis probably requires firing up the debugger which I don't have time for now - past my bedtime!

``

restart; with(LinearAlgebra)

NULL

TEST := proc (A, B, TOL, maxIter) local k, n, shift, lambda, j, b, c, d, muOne, muTwo, delta, x, y, z, q, r, qq; k := 1; n := RowDimension(A); shift := 0; while k <= maxIter do if evalf(abs(B[n])) <= TOL then lambda := A[n]+shift; print(lambda); n := n-1 end if; if evalf(abs(B[2])) <= TOL then lambda := A[1]+shift; print(lambda); n := n-1; A[1] := A[2]; j := 2; while j <= n do A[j] := A[j+1]; B[j] := B[j+1]; j := j+1 end do end if; if n = 0 then return  end if; if n = 1 then lambda := A[1]+shift; print(lambda); return  end if; j := 3; while j <= n-1 do if evalf(abs(B[j])) <= TOL then print('Split*matrix*at'); return  end if; j := j+1 end do; b := -A[n-1]-A[n]; c := A[n-1]*A[n]-B[n]^2; d := sqrt(b^2-4*c); if 0 < evalf(b) then muOne := -2*c/(b+d); muTwo := -(1/2)*b-(1/2)*d else muOne := (1/2)*d-(1/2)*b; muTwo := 2*c/(d-b) end if; if n = 2 then lambda := muOne+shift; print(lambda); lambda := muTwo+shift; print(lambda); return  end if; if evalf(abs(muOne-A[n])) <= evalf(abs(muTwo-A[n])) then delta := muOne else delta := muTwo end if; shift := shift+delta; j := 1; d := Vector(1 .. n); while j <= n do d[j] := A[j]-delta; j := j+1 end do; x := Vector(1 .. n); y := Vector(1 .. n); delta := Vector(1 .. n); c := Vector(1 .. n); z := Vector(1 .. n); x[1] := d[1]; y[1] := B[2]; q := Vector(1 .. n); r := Vector(1 .. n); j := 2; while j <= n do z[j-1] := sqrt(x[j-1]^2+B[j]^2); c[j] := x[j-1]/z[j-1]; delta[j] := B[j]/z[j-1]; q[j-1] := c[j]*y[j-1]+d[j]*delta[j]; x[j] := c[j]*d[j]-delta[j]*y[j-1]; if j <> n then r[j-1] := delta[j]*B[j+1]; y[j] := c[j]*B[j+1] end if; j := j+1 end do; z[n] := x[n]; A[1] := c[2]*z[1]+delta[2]*q[1]; B[2] := delta[2]*z[2]; j := 2; while j <= n-1 do A[j] := c[j+1]*c[j]*z[j]+delta[j+1]*q[j]; B[j+1] := delta[j+1]*z[j+1]; j := j+1 end do; A[n] := c[n]*z[n]; k := k+1 end do; print('Max*iterations*exceeded'); qq := -1; return  end proc

A := Vector(1 .. 3, [3, 3, 3]); B := Vector(1 .. 3, [1, 1, 1])

Vector(3, {(1) = 3, (2) = 3, (3) = 3})

 

Vector[column](%id = 36893488148212512276)

(1)

NULL

TOL := 0.1e-3; maxIter := 20

0.1e-3

 

20

(2)

TEST(A, B, TOL, maxIter)

NULL

NULL

NULL

NULL

Download someFixes2.mw

 

First 10 11 12 13 14 15 16 Last Page 12 of 207