acer

32313 Reputation

29 Badges

19 years, 313 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@dharr For some reason I had convinced myself that the solution of the linear problem lay outside the OP's provided ranges -- hence my least-squares approach. I might not have looked properly at the range end-points X that the OP provided.

@gravatarq I deleted a duplicate posting of this.

@mehdibgh Your description is that of an inverted range, since with your t value as 1 the values in X will be negative and you have the lower range value q as 0.

Also, you have the same kind of indexing mistake with X, which you have as a 4x1 Matrix, and not a Vector.

You could try the ranges as,

     { seq(V[1, r] = X[r, 1] .. q, r = 1 .. 4) }

but you might not find a solution.

[edit] Perhaps you might actually be satisfied with a solution to an optimization problem of minimizing some related objective (eg. least-squares). Here I raise the working precision to try and get a more accurate result:

restart

EQ := Matrix(4, 1, {(1, 1) = 32.1640740637930*Tau[1]-0.172224519601111e-4*Tau[2]-0.270626540730518e-3*Tau[3]+0.1570620334e-9*P[1]+0.3715450960e-14*sin(t), (2, 1) = -0.172224519601111e-4*Tau[1]+32.1667045885952*Tau[2]+0.587369829416537e-4*Tau[3]-0.1589565489e-8*P[1]+0.1004220091e-12*sin(t), (3, 1) = -0.270626540730518e-3*Tau[1]+0.587369829416537e-4*Tau[2]+32.1816411689934*Tau[3]-0.7419658527e-8*P[1]+0.5201228088e-12*sin(t), (4, 1) = 0.1570620334e-9*Tau[1]-0.1589565489e-8*Tau[2]-0.7419658527e-8*Tau[3]+601.876235436204*P[1]})

V := Matrix(1, 4, {(1, 1) = Tau[1], (1, 2) = Tau[2], (1, 3) = Tau[3], (1, 4) = P[1]})

q := 0

X := Matrix(4, 1, {(1, 1) = -0.1156532164e-15*sin(t), (2, 1) = -0.3121894613e-14*sin(t), (3, 1) = -0.1616209235e-13*sin(t), (4, 1) = -0.2074537757e-24*sin(t)})

t := 1

Digits := 60; Sol := Optimization:-Minimize(add(EQ[r, 1]^2, r = 1 .. 4), seq(V[1, r] = X[r, 1] .. q, r = 1 .. 4))

[0.23051887707880648450227137668244873934400e-43, [P[1] = -0.174566332911092633926811253720853832324936144346344610109133e-24, Tau[1] = -0.973188258955118595763778228079271664727641452276400379153389e-16, Tau[2] = -0.262698373446757694397996566086762382450096865275922610909883e-14, Tau[3] = -0.135999317663106703497601318807782949900124793323219378929709e-13]]

Sol[2]

[P[1] = -0.174566332911092633926811253720853832324936144346344610109133e-24, Tau[1] = -0.973188258955118595763778228079271664727641452276400379153389e-16, Tau[2] = -0.262698373446757694397996566086762382450096865275922610909883e-14, Tau[3] = -0.135999317663106703497601318807782949900124793323219378929709e-13]

evalf[5](evalf[60](eval(add(EQ[r, 1]^2, r = 1 .. 4), Sol[2])))

0.23052e-43

NULL

Download SoalNewton_acc.mw

@fkohlhepp I have deleted a duplicate of this Question thread.

If you have any additional details or related followup queries then feel free to add them here. Please don't spawn a separate Question thread for this.

And here is an animation, based upon the OP's revised code...

I let it be animated w.r.t. the parameter t passed to CircleParm for point P1.

The procedure F produces each plotted frame.

(It could also be done with Explore, optionally with additional parameters passed for F's other arguments -- being the values passed to CircleParm for P2,P3,P4.)

restart;

with(plots): with(plottools):with(LinearAlgebra): unprotect(D);

_EnvHorizontalName := 'x':
_EnvVerticalName := 'y':

Vdot := proc (U, V)local i: add(U[i]*V[i], i = 1 .. 2) end proc:
dist := proc (M, N) sqrt(Vdot(expand(M-N), expand(M-N))) end proc:
MinDistPoint := proc (A::[algebraic, algebraic], B::[algebraic, algebraic], P::[algebraic, algebraic])
local D, R, V;
description "Point on line AB at minimum distance from P";
D := `<,>`(A-B); R := `<,>`(`<|>`(0, -1), `<|>`(1, 0));
V := `<,>`(`<,>`(P) . D, -R . `<,>`(A) . `<,>`(B)); `~`[`/`]([V . D, R . V . D], ` $`, D . D)
end proc:

EqBIS := proc(P, U, V) local a, eq1, M1, t, PU, PV, bissec1; a := (P - U)/LinearAlgebra:-Norm(P - U, 2) + (P - V)/LinearAlgebra:-Norm(P - V, 2); M1 := P + a*t; eq1 := op(eliminate({x = M1[1], y = M1[2]}, t)); return op(eq1[2]); end proc:

Cen := proc(M, N, R) local eq1, eq2, sol; eq1 := EqBIS(M, N, R) = 0; eq2 := EqBIS(N, M, R) = 0; sol := simplify(solve({eq1, eq2}, {x, y})); return [subs(sol, x), subs(sol, y)]; end proc:

CircleParm := t -> [(-t^2 + 1)/(t^2 + 1), 2*t/(t^2 + 1)]:

 

F := proc(parm1,parm2,parm3,parm4)
local P1,P2,P3,P4,r1,r2,r3,r4,p1,p2,p3,p4,Cir1,Cir2,Cir3,Cir4,
      H,C4,C1,C2,C3,J,K,Pts,Ii,Poly,SegP1P4,SegP2P3,quadri,rect,tex;
try
P1 := Vector(CircleParm(parm1)):
P2 := Vector(CircleParm(parm2)):
P3 := Vector(CircleParm(parm3)):
P4 := Vector(CircleParm(parm4)):
p1 := convert(P1, list);
p2 := convert(P2, list);
p3 := convert(P3, list);
p4 := convert(P4, list);
C4 := Vector(Cen(P1, P2, P3)):H := convert(C4, list):
C1 := Vector(Cen(P4, P2, P3));
J := convert(C1, list);
C2 := Vector(Cen(P4, P1, P3));
Ii := convert(C2, list);
C3 := Vector(Cen(P4, P2, P1));
K := convert(C3, list);
Pts := [P1, P2, P3, P4, C1, C2, C3, C4]:
r4 := dist(MinDistPoint(p1, p2, H), H);
r2 := dist(MinDistPoint(p1, p4, Ii), Ii);
r1 := dist(MinDistPoint(p2, p3, J), J);
r3 := dist(MinDistPoint(p2, p1, K), K);
Cir1 := circle(Ii, r2, color = black);
Cir2 := circle(K, r3, color = black);
Cir3 := circle(J, r1, color = black);
Cir4 := circle(H, r4, color = black);
Poly := polygonplot([p1, p2, p4, p3, p1], color = blue, transparency = 0.9);
SegP1P4 := plot([p1, p4], color = black);
SegP2P3 := plot([p2, p3], color = black);
quadri := plot([p1, p2, p4, p3, p1], color = black);
rect := polygonplot([H, Ii, J, K, H], color = red, transparency = 0.7);
tex := textplot([[p1[], "P1"], [p2[], "P2"], [p3[], "P3"], [p4[], "P4"], [H[], "H"], [Ii[], "I"], [J[], "J"], [K[], "K"]], align = ["above", "right"]);
display(Poly, tex, quadri, rect, SegP1P4, SegP2P3, Cir1, Cir2, Cir3, Cir4, implicitplot([x^2 + y^2 - 1], x = -2 .. 2, y = -4 .. 2, colour = [blue], scaling = constrained), pointplot(Pts, symbolsize = 16), axes = none);
catch:
  NULL;
end try;
end proc:

animate(F,[param1,5,-1/10,-19/2], param1=1/10..1);

Download jamet_anim1.mw

The OP wrote, in a followup comment, "how to draw all the lines P1P2,P2P3,P3P4, etc,  and the incirles of centers C1, C2.."

The OP's earlier code did not define C2, however, so I have made a guess as to that (and to the incircles).

restart;
with(LinearAlgebra):
with(plots):
with(plottools,line):
with(plottools,circle):

EqBIS := proc(P, U, V) local a, eq1, M1, t, PU, PV, bissec1; a := (P - U)/LinearAlgebra:-Norm(P - U, 2) + (P - V)/LinearAlgebra:-Norm(P - V, 2); M1 := P + a*t; eq1 := op(eliminate({x = M1[1], y = M1[2]}, t)); return op(eq1[2]); end proc:

A := <4, 8>;
B := <4, 2>;
C := <1, 4>;
EqBIS(A, B, C);

A := Vector(2, {(1) = 4, (2) = 8})

B := Vector(2, {(1) = 4, (2) = 2})

C := Vector(2, {(1) = 1, (2) = 4})

-5*y-20+15*x

Cen := proc(M, N, R) local eq1, eq2, sol; eq1 := EqBIS(M, N, R) = 0; eq2 := EqBIS(N, M, R) = 0; sol := simplify(solve({eq1, eq2}, {x, y})); return [subs(sol, x), subs(sol, y)]; end proc:
Cen(A,B,C):

CircleParm := t -> [(-t^2 + 1)/(t^2 + 1), 2*t/(t^2 + 1)];

proc (t) options operator, arrow; [(-t^2+1)/(t^2+1), 2*t/(t^2+1)] end proc

P1 := (CircleParm(1/4));

P2 := (CircleParm(5));
P3 := (CircleParm(-1/10));
P4 := (CircleParm(-3/2));

[15/17, 8/17]

[-12/13, 5/13]

[99/101, -20/101]

[-5/13, -12/13]

C1 := Cen(<P1>, <P2>, <P3>);

[(1/44642)*(1066*17^(1/2)-255*26^(1/2))*101^(1/2)-(1/442)*26^(1/2)*17^(1/2), (1/44642)*(156*17^(1/2)-833*26^(1/2))*101^(1/2)+(21/442)*26^(1/2)*17^(1/2)]

C2 := Cen(<P4>, <P2>, <P3>);

[(1/2626)*(15*2^(1/2)+34)*1313^(1/2)-(17/26)*2^(1/2), (1/2626)*(49*2^(1/2)-64)*1313^(1/2)-(7/26)*2^(1/2)]

Pts := [P1, P2, P3, P4, C1, C2];

[[15/17, 8/17], [-12/13, 5/13], [99/101, -20/101], [-5/13, -12/13], [(1/44642)*(1066*17^(1/2)-255*26^(1/2))*101^(1/2)-(1/442)*26^(1/2)*17^(1/2), (1/44642)*(156*17^(1/2)-833*26^(1/2))*101^(1/2)+(21/442)*26^(1/2)*17^(1/2)], [(1/2626)*(15*2^(1/2)+34)*1313^(1/2)-(17/26)*2^(1/2), (1/2626)*(49*2^(1/2)-64)*1313^(1/2)-(7/26)*2^(1/2)]]

rr := proc(p1,p2,p3) local dd,d12,d23,d31;
        dd := (a,b)->sqrt((b[2]-a[2])^2+(b[1]-a[1])^2);
        (d12,d23,d31) := dd(p1,p2),dd(p2,p3),dd(p3,p1);
        (s->sqrt((s-d12)*(s-d23)*(s-d31)/s))((d12+d23+d31)/2);
      end proc:

display(implicitplot([x^2 + y^2 - 1], x = -2 .. 2, y = -4 .. 2, colour = [blue], scaling = constrained), pointplot(Pts, symbolsize = 16),
        line(P1,P2),line(P2,P3),line(P3,P1),circle(C1,rr(P1,P2,P3)),
        line(P4,P2),line(P2,P3),line(P3,P4),circle(C2,rr(P4,P2,P3)));

Download jamet_ac2.mw

@JAMET You now seem to be calling plot instead of plots:-pointplot.

Why did you change it?

(You could attach a worksheet containing the code you actually use. That could save effort, all round.)

I am unable to get either of the pair of tubeplots to be rendered in black, using Maple 2022.1 for ubuntu 18.04 LTS, with hardware acceleration turned either on or off in the GUI Options.

Why not simply provide your full requirenents on your other, recent Question on this?

You could zip-compress-archive the file, then upload and attach the .zip file using the green up-arrow in the Mapleprimes editor.

@Carl Love A PlotComponent allows for properties (clickx  clicky) to be queried programatically. Those can be used with a single right-click, or click&drag.

The `Explore` command allows for this by having two (or one) parameters be specified via its `markers` option. Additionally, the corresponding Sliders may be shown, or suppressed. See ?Explore as well as ?examples,Explore .

The above have a notion that the scale of the parameters is the same as the scale of the 2D plot. Naturally, if the interactive plot is 3D then such marker-style interaction (on a 2D plot area) would need to be in a separate plot, by the side say.

I'm away from a computer until this coming Sunday  and then again from Mon-Fri. Apologies not being to show examples by code.

[edit. If I can paste properly...]

The parameter values taken from a 2D plotting area can be used as simply the x,y values of an input point. Or they can be used as a pair of parameters used in some quite different manner of your own devising.

IIRC, here's an Explore app that used markers to grab an x-y point input on-the-fly,

https://www.maplesoft.com/Applications/Detail.aspx?id=153552

And here's an embedded components app that also used clickx,clicky (but not via Explore) to control parameters,

https://www.maplesoft.com/Applications/Detail.aspx?id=153557

 

As far as a (forcing) programmatic transformation goes, do you care whether it is always valid?

ps. Is this entirely different from all your earlier queries on 2-argument arctan, and if not then why split up the topic?

@Christian Wolinski I believe that the OP is aware that he can write it out, with the body of the inner procedure hard-coded. Ie, more tersely,

f := a -> (b -> a/b);

      f := a -> b -> a/b

f(A)(B);

            A/B

I believe that the OP's issue was in programmatically building f such that the body of the inner operator was constructed from the predefined expression e.

@vv If g changes then the efficient course would be to rebuild dgdx2. (The efficiency alluded to is the cost of repeatedly invoking D for each call to dgdx, not the cost of construction.)

In terms of simplicity but with a similar inefficiency, forming dgdx2 once, prior to defining g, makes it behave like dgdx1, ie. consistent results. (But it's still simpler and more straightforward.) Eg,

dgdx1:=(x,T) -> D[1](g)(x,T);
dgdx2:=  D[1](g);

g := (x, T) -> T*x + x^2:  #just an example
dgdx1(1, 2);
dgdx2(1, 2);

g := (x, T) -> T*x + 7*x^2:
dgdx1(1, 2);
dgdx2(1, 2);

@Saha 

You've accidentally pasted Tom's 1D plaintext code in as 2D Input, without altering it to avoid (incorrect) implicit multiplications.

You've changed the boundary conditions in two different ways (both invalid).

You've changed f(x) in one of the equations.

First 101 102 103 104 105 106 107 Last Page 103 of 591