20133 Reputation

29 Badges

14 years, 359 days

Social Networks and Content at

MaplePrimes Activity

These are replies submitted by acer

Put your followup queries on this topic as comments here in this same thread, please.

Please upload .mw worksheets (green up arrow in the Mapleprimes editor) since you're having copy and paste issues. (And never paste in 2D input code as plaintext here.)

@Christopher2222 Actually you should describe your actual background problem up front.

@rquirt Units:-Simple allows you to add blah*Unit(W) and the unevaluated function call to your proc (which itself returns a quantity with units).

I removed the call to `with(Units:-Standard)` at the top level. The procedure revision i gave works without it. I utilized `uses` in the proc instead. (It is not great programming to write a proc that only works if `with`is called outside it.)

I also made your proc return unevaluated when the first argument is not numeric*unit or numeric.

There was also a left- right- quote match typo in your original.

Better to upload actual working code or worksheet. 

@MAJP Firstly, I commend you for putting in real effort at solving this. It's refreshing to see.

I suspect that you have made two or three typo's in writing down the formula for Fdiff[i].

The first is that you are missing a multiplication sign between two pairs of round brackets. So that ends up being parsed as function application rather than multiplication. (Maple allows you to apply a floating-point number to something else, and it returns that same float.)

The second seems to be that you have (F[i]-1) instead of (F[i]+1) in the formula for Fdiff[i].

Also, as Carl mentioned, you have an y[1] which ought to be y[i] in the formula for dAdy[i].

If I make those adjustments then the derivative of F appears to match Fdiff. And then the starting point y0=1 allows convergence to the root near y=2.4222.

In order to get convergence to the apparent root near y=-8.57 I wrapped the formula for y[i+1] with two commands whose purpose is to remove any small imaginary component (where small means close to the working precision.) You can get rid of that if you find it's out of scope for your task.

I suppose you realize that you don't really need to keep track of all the values of A,P,Fdiff,etc for all i values. You could just as well use non-indexed names for those. The indexing of Y is key to your approach, of course.


Newton := proc (n, y0, Q, b, m, k, S0)
  local A, P, Sf, y, F, dAdy, dPdy, Fdiff, i, ylist;
  y[0] := evalf(y0);
  for i from 0 to n do
    A[i] := (b+m*y[i])*y[i];
    P[i] := evalf(b+2*y[i]*sqrt(1+m^2));
    Sf[i] := evalf(Q*abs(Q)*P[i]^(4/3)/(k^2*A[i]^(10/3)));
    F[i] := S0/Sf[i]-1;
    dAdy[i] := b+2*m*y[i];
    dPdy[i] := evalf(2*sqrt(1+m^2));

    #Fdiff[i] := -(4/3)*S0*k^2*A[i]^(10/3)*(dPdy[i])/(Q*abs(Q)*P[i]^(7/3))
    #            +(10/3)*S0*k^2*A[i]^(7/3)*(dAdy[i])/(Q*abs(Q)*P[i]^(4/3));
    Fdiff[i] := (2/3)*(F[i]+1)*(5*dAdy[i]/A[i]-2*dPdy[i]/P[i]);

    y[i+1] := simplify( fnormal( y[i]-F[i]/Fdiff[i] ), ':-zero' );
  end do;

  ylist := [seq(y[i], i = 0 .. n)];
  return ylist
end proc:


Newton(10, 1, 5, 12, 1, 30, 10^(-5));

[1., 6.573224507, 4.850242691, 3.616575701, 2.840981033, 2.493303585, 2.424667056, 2.422212016, 2.422208959, 2.422208959, 2.422208959]

Newton(10, -8, 5, 12, 1, 30, 10^(-5));

[-8., -8.487501254, -8.568487419, -8.570502786, -8.570504010, -8.570504009, -8.570504009, -8.570504009, -8.570504009, -8.570504009, -8.570504009]

ee := S0/(Q*abs(Q)*P(y)^(4/3)/(k^2*A(y)^(10/3)))-1;


dee := diff(ee,y);

-(4/3)*S0*k^2*A(y)^(10/3)*(diff(P(y), y))/(Q*abs(Q)*P(y)^(7/3))+(10/3)*S0*k^2*A(y)^(7/3)*(diff(A(y), y))/(Q*abs(Q)*P(y)^(4/3))

hdee := (2/3)*(ee+1)*(5*diff(A(y),y)/A(y)-2*diff(P(y),y)/P(y));

(2/3)*S0*k^2*A(y)^(10/3)*(5*(diff(A(y), y))/A(y)-2*(diff(P(y), y))/P(y))/(Q*abs(Q)*P(y)^(4/3))

simplify( hdee -dee );


this := eval(eval(ee, [A(y)=(b+m*y)*y,
             [Q=5, k=30, S0=10^(-5), m=1, b=12]);


Digits := 30;


sol1 := fsolve(this, y=1..10);


evalf[100](eval(this, y=sol1)): evalf[10](%);


sol2 := fsolve(abs(this), y=-9..-8);


evalf[100](eval(this, y=sol2)): evalf[10](%);


foo := simplify(combine(expand(this)),size) assuming y>-9, y<-8;


fsolve(foo, y=-9..-8);


bar := eval(ee, [A(y)=(b+m*y)*y,


bbar := simplify(evalc(bar),size) assuming real, m<b/y, b>=10, b<13, y>-9, y<-7;


fsolve(eval(bbar, [Q=5, k=30, S0=10^(-5), m=1, b=12]), y=-9..-8);




@MAJP Each iteration through the loop , do you want to be defining y[i] in term of the previous value y[i-1] ?

Trying to assign y[i] in terms of a formula with y[i] is not right.

You'll  also need to consider whether the other indexed names in the formulas in the loop should use the current iteration's values indexed by i, or the previous iteration's values indexed by i-1.

I feel sure that, by thinking about this aspect, you'll understand what the iteration is supposed to accomplish.



Whenever I install Maple the next thing I do is edit the properties of the launcher, to add (along with a blank space as separator) the option
to the end of the invocation of the GUI executable.

This has the effect that I can launch separate worksheets under separate Java jvm processes. And if one of them stalls or freezes or crashes (in the GUI sense) then the other one(s) stay ok.

It'll even let me open the same worksheet twice.

Memory is cheap. Back around Maple 10 the few hundred MB footprint of the GUI+jvm seemed huge. Now it seems modest.


The code for the module J is in the Startup Code of this attachment.  (Use the menubar's Edit->Startup Code to see it, or modify it.)  The whole point is that the input is 1D and the pretty-printed names appear in the 2D output.

You can make the commands as long as you wish, or as short as a single character. You could add additional commands like J:-dash which puts a bar over a name, so that you don't have to remember HTML entity names. Or you could add  additional commands like J:-o which puts anything over anything. Or you could could add additional commands like, say. br for bottom-right or tl for top-left.

You can assign the marked up names to any other variable of your choice.

If you really wanted to you could add additional options to allow you to specify the color, boldness, or upright vs italic.

Of course it involves more typing, but you can create your own procedure names for custom mnemonics. If you also utilize use and uses (see examples) then it's not that much more typing than LaTeX.






use J in

  o(A,`&centerdot;`)*I*Pi + arctan(3*o(X,`&minus;`)/sb(Y,3,5));

  Adot := o(A,`&rarr;`);
  Xbar := dash(X);

end use;




Adot + Xbar;



P := proc(t)
  local q,r;
  uses J;

  r := dash(Q);
  return sin(r*t) + int(sb(t,i,j)(y), y=0..Pi);
end proc:


Parse:-ConvertTo1D, "invalid input %1", Typesetting:-mprintslash([sin(`#mover(mi("Q"),mrow(mi("\`&mdash;\`")))`*x)+int(`#msub(mi("x"),mrow(mrow(mi("i"),Typesetting:-mo("&comma;"),mi("j"))))`(y), y = 0 .. Pi)], [sin(`#mover(mi("Q"),mrow(mi("\`&mdash;\`")))`*x)+int(`#msub(mi("x"),mrow(mrow(mi("i"),Typesetting:-mo("&comma;"),mi("j"))))`(y), y = 0 .. Pi)])























`#munderover(mi("W"),mrow(mrow(mi("a"),Typesetting:-mo("&comma;"),mi("b"))),mrow(mfenced(mi("x"),mi("y"),open = "&lsqb;",close = "&rsqb;")))`











# evaluation sanity check
u,s,t,v,w,A := 'u','s','t','v','w','A':
u:=s: s:=t: t:=v: v:=w: w:=A:
J:-sb('u',6), J:-sb(u,6), J:-sb(eval(u,3),6);

`#msub(mi("u"),mrow(mn("6")))`, `#msub(mi("A"),mrow(mn("6")))`, `#msub(mi("v"),mrow(mn("6")))`

# evaluation sanity check
p,q := [3,4], 5:
J:-sc(A, [1,2], p, q,
           6, 7, 8);
J:-sc(AAAAA, [[1,2]], 'p', 'q',
           6, 7777, 8);


`#mscripts(mi("AAAAA"),mrow(mfenced(mn("1"),mn("2"),open = "&lsqb;",close = "&rsqb;")),mrow(mi("p")),mrow(mi("q")),mrow(mn("6")),mrow(mn("7777")),mrow(mn("8")))`


[`#msup(mi("A"),mrow(mi("\`&clubs;\`")))`, `#msup(mi("K"),mrow(mi("\`&diams;\`")))`, `#msup(mi("Q"),mrow(mi("&hearts;",mathcolor = red,Typesetting:-msemantics = "atomic")))`, `#msup(mi("J"),mrow(mi("&spades;",mathcolor = black,Typesetting:-msemantics = "atomic")))`, `#msup(mn("10"),mrow(mi("&diams;",mathcolor = red,Typesetting:-msemantics = "atomic")))`]





f := (a,z) -> z*exp(a*z) / (z^2 + 1)^2:


[{z = -I}, {z = I}]


{z = -I}


z = -I


z = -I

residue(f(a,z), op(R[1]));


residue(f(a,z), R[1][]);


seq(residue(f(a,z), op(eq)), eq=R);

((1/4)*I)*a/exp(I*a), -((1/4)*I)*a*exp(I*a)

seq(residue(f(a,z), eq[]), eq=R);

((1/4)*I)*a/exp(I*a), -((1/4)*I)*a*exp(I*a)



Every one of your queries submitted to this site has been a Post. And someone has had to convert each to a Question. I don't think that is very considerate of you.

Could you please use the Question form in future? It's right there at the top right of this site, right beside the Post form.

@erdisayar You mentioned LaTeX, for comparison, which entails a more verbose 1D plaintext form.

That makes it sound as if you are willing to use a 1D plaintext syntax for marking up your symbols/names with immutable subscripts and overscripts. If that's true then I can show you how. But, as input, it will require more typing/keystrokes.

I have always found 2D Input mode to be awkwardly impractical at best, and buggy at worst. I don't know how people manage to use it, even with keyboard shortcuts. It's curious to me that you're still trying to find a way to work with it easily.

I resisted changing everything to my own taste, since I believe that the OP is learning by doing.

Otherwise, a somewhat similar effect could be had with, say,


  local expr, x;
  if u="   y = a sin(b x + c) + d " then
    expr := evalf[3](a*sin(b*x + c) + d);
    plot(expr, x=-2*Pi..2*Pi,
         ':-view'=-3 .. 6);
  elif u="   y = sin(a x) + cos(b x) " then
    expr :=  evalf[3](sin(a*x) + cos(b*x));
    plot(expr, x=-2*Pi..2*Pi,
  else error u;
  end if;
end proc:

Explore( F(`function :`,a,b,c,d),
         parameters=[ [`function :`=["   y = a sin(b x + c) + d ",
                                     "   y = sin(a x) + cos(b x) "],
         a = 1.0 .. 3.0, b = 1.0 .. 3.0,
         c = 0.0 .. 2*Pi, d = 0.0 .. 3.0,
         placement = right
         #, newsheet, showbanner=false, startupdefinitions=[F]

Could you upload your data here as an attachment (green up-arrow)?

@Ramakrishnan One of the problems with your original was that MyApp did not export ChangeE. So when you called ChangeE() in the code of the Sliders nothing happened.

If you are interested in using different formulas and radio buttons:

@Ramakrishnan You mean you're posting the same question twice? Please don't do that.

The first thing to clarify is the format of your data. It looks like the three columns denote four points of [x,y,z] data, rather than a 3x4=12 collection of [x,y] data points. Is that right?

What version of Maple are you using?

Is this a toy example, and you plan on wanting to do it for larger sets of points (possibly with surface smoothing)? Or do you just need to deal with this kind of simple 3D polygon with a quadrilateral base?


First 69 70 71 72 73 74 75 Last Page 71 of 435