20133 Reputation

14 years, 359 days

followups...

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.)

Actually...

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

several changes...

@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.

typo...

@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.

 > restart;
 > 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));

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

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

 > dee := diff(ee,y);

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

 > simplify( hdee -dee );

 > this := eval(eval(ee, [A(y)=(b+m*y)*y,                   P(y)=b+2*y*sqrt(1+m^2)]),              [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,                   P(y)=b+2*y*sqrt(1+m^2)]);

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

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

 >

y[i-1]...

@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.

distinct instances of GUI+ java run-time...

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
-standalone
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.

 > restart;
 >
 > J:-dash(X);

 >
 > use J in   o(A,`·`)*I*Pi + arctan(3*o(X,`−`)/sb(Y,3,5));   Adot := o(A,`→`);   Xbar := dash(X); end use;

 >
 > 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: P(x);

 >
 > J:-sb(A,6);

 > J:-sb(A,4,3,2);

 > J:-sp(A,6); J:-sp(x,`′`);

 > J:-sp(A,4,3,2);

 > J:-o(A,m);

 > J:-o(A,x,y,z);

 > J:-o(x,`−`); J:-o(Z,`&^;`);

 > J:-u(A,x,y,z); J:-u(A,`→`);

 > J:-uo(W,`→`,`∗`); J:-uo(W,[a,b],[[x,y]]);

 > J:-sc(A,1,2,3,4,5,6);

 > J:-sc(A,1); J:-sc(A,1,`+`); J:-sc(A,1,`*`,3);

 > J:-sc(X,[],[],2); J:-sc(Y,x,[],[],[],y); J:-sc(Z,[],a,[],[],[],b);

 > # 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);

 > # 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);

 > map(J:-sp@op,     [[A,`♣`],[K,`♦`],      [Q,`#mi("♥",mathcolor=red)`],      [J,`#mi("♠",mathcolor=black)`],      [10,`#mi("♦",mathcolor=red)`]]);

 >

op...

 > restart;
 > f := (a,z) -> z*exp(a*z) / (z^2 + 1)^2:
 > R:=[singular(f(a,z),z)];

 > R[1];

 > op(R[1]);

 > R[1][];

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

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

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

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

 >

converted from Post to Question...

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.

1D input, 2D output with immutable subsc...

@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.

temptation...

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,

```restart;

F:=proc(u,a,b,c,d)
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,
':-title'=expr,
':-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,
':-title'=expr,
':-view'=-2..2);
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) "],
#controller="listbox",
placement=top]
],
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]
);```

data...

@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:  doubt2_MathContainer_ac2.mw

duplicate?...

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

version?...

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
﻿