acer

32490 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@dpaddy I agree -- the difficulties are not that hard to understand. The error message doesn't reveal the offending argument's value. The error message is also more generally incorrect because negative integers are in fact allowed.

A straightforword way to approach such problems is to apply the trace command to the problematic command name. Eg, trace(Bits:-GetBits) . That has the convenience of allowing you to toggle extra reporting on/off without having to rewrite your code or take a performance hit from the extra wrapping function call. However there seems to be a technical obstacle to this approach. Upon first execution the Bits:-GetBits command replaces itself with a procedure that calls external compiled code. The replacement procedure has option call_external, and apparently option trace doesn't work for a procedure which also has option call_external. So only the first call gets its details reported.

@assma Does this work for you in Maple 18?

restart;

kernelopts(version);

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

f := proc(x, y) options operator, arrow; sin(x)*cos(y) end proc:

Psurf:=plot3d(f, -Pi..Pi, -Pi..Pi, style=surface,

              colorscheme=["zgradient", ["Orange","Blue"]]):

Pcont2D_1:=plots:-contourplot(f, -Pi..Pi, -Pi..Pi,

                              coloring=["Orange","Blue"],
                              style=line):

Proj:=plottools:-transform((a,b)->[a,b,-1]):

plots:-display(

  Psurf,

  Proj(Pcont2D_1)

);

 

Download surf_proj_contours_M1802.mw

@deniscr 

Do you mean that the elements of C and M are not numeric? If so then perhaps could you generate a Matrix U with names in it (using the symbol option to the Matrix constructor), then Equate U^%T.C.U to M, and call eliminate (or maybe solve)?

Providing us with the full example might help.

Here's a simple example. Note that the [2,2] entry of solutions for U may be free (arbitrary) for this particular example, but U[2,2] appears in the formulas for the other elements of U.

restart;

C:=Matrix([[t^2,t^3],[t^3,sin(t)]]);

_rtable[18446884112552558710]

M:=Matrix([[a,b],[c,d]]);

_rtable[18446884112552562550]

U:=Matrix(2,symbol=u);

_rtable[18446884112434897974]

eqns:=Equate(U^%T . C . U, M);

[(t^3*u[2, 1]+t^2*u[1, 1])*u[1, 1]+(u[1, 1]*t^3+u[2, 1]*sin(t))*u[2, 1] = a, (t^3*u[2, 1]+t^2*u[1, 1])*u[1, 2]+(u[1, 1]*t^3+u[2, 1]*sin(t))*u[2, 2] = b, (t^3*u[2, 2]+t^2*u[1, 2])*u[1, 1]+(u[1, 2]*t^3+u[2, 2]*sin(t))*u[2, 1] = c, (t^3*u[2, 2]+t^2*u[1, 2])*u[1, 2]+(u[1, 2]*t^3+u[2, 2]*sin(t))*u[2, 2] = d]

sol:=simplify([eliminate(eqns, indets(U,name))]):

nops(sol);

4

for i from 1 to nops(sol) do
  print(i);
  Usol[i]:=eval(U,sol[i,1]);
  res:=simplify( Usol[i]^%T . C . Usol[i] - M );
  conditions[i]:=remove(u->is(rhs(u)=lhs(u)),
                        simplify({Equate(res,Matrix(2))[]})
                        union map(`=`,sol[i,2],0));
  print(sprintf("conditions on Usol[%a]",i),conditions[i]);
end do:

1

"conditions on Usol[1]", {b-c = 0}

2

"conditions on Usol[2]", {b-c = 0}

3

"conditions on Usol[3]", {b-c = 0}

4

"conditions on Usol[4]", {b-c = 0}

Usol[1], conditions[1];

Matrix(2, 2, {(1, 1) = ((-sqrt(t^4*u[2, 2]^2-sin(t)*u[2, 2]^2+d)*t^2+u[2, 2]*(t^4-sin(t)))*sqrt(-(a*d-b^2)*((-2*t^4*u[2, 2]^2-d)*sin(t)-cos(t)^2*u[2, 2]^2+(t^8+1)*u[2, 2]^2+d*t^4))+(-t^2*u[2, 2]*(t^4-sin(t))*sqrt(t^4*u[2, 2]^2-sin(t)*u[2, 2]^2+d)+(-2*t^4*u[2, 2]^2-d)*sin(t)+t^8*u[2, 2]^2+d*t^4-cos(t)^2*u[2, 2]^2+u[2, 2]^2)*b)/(sqrt(t^4*u[2, 2]^2-sin(t)*u[2, 2]^2+d)*d*t*(t^4-sin(t))), (1, 2) = (-t^2*u[2, 2]+sqrt(t^4*u[2, 2]^2-sin(t)*u[2, 2]^2+d))/t, (2, 1) = (b*t^4*u[2, 2]-b*sin(t)*u[2, 2]+sqrt(-(a*d-b^2)*((-2*t^4*u[2, 2]^2-d)*sin(t)-cos(t)^2*u[2, 2]^2+(t^8+1)*u[2, 2]^2+d*t^4)))/(d*(t^4-sin(t))), (2, 2) = u[2, 2]}), {b-c = 0}

simplify( Usol[1]^%T . C . Usol[1] - M );

_rtable[18446884112179336006]

 

Download mateqnsolve.mw

@K SIVA THEJA 

I'm not sure what you mean.

Maple doesn't interpret a column Vector the same as an n-by-1 Matrix, nor a row Vector the same as a 1-by-n Matrix. In part this makes a mathematical distinction between members of Vector spaces and mappings between them.

And it distinguishes even between a single-element row Vector and a single-element column Vector. The default is a column Vector.

(You can argue that such behavior is not the best design, if you want. Other products may behave differently.)

And I wouldn't be surprised if there are buggy cases too.

Note the distinction of using OuterProductMatrix.

I can also mention that you didn't state what you meant by Vector-Vector multiplication. And the title of your Question is "VECTOR/MATRIX MULTIPLICATION" but your example contains just two Vectors and no Matrix. And it's not clear if you are looking for an inner product or an outer product.

B := Vector[column]([2,3]);

_rtable[18446884287804698982]

Bm := Matrix([[2],[3]]);

_rtable[18446884287804700542]

C := Vector[column]([4]);

_rtable[18446884287804701622]

B . C;

Error, (in LinearAlgebra:-DotProduct) vectors must have the same dimension

Bm . C;

_rtable[18446884287804702462]

 

Download MV.mw

@das1404 All Comments, Questions, and Posts on this site are public. You don't have to log in to view them.

Putting in a token link such as @das1404  into a response merely lets the reader know which previous Comment/Question you're addressing, and which member wrote it. Doing that doesn't cause the system to send a private message or email. (This site has a separate mechanism for sending a private message. And members get email notifications when threads in which they are active get additional content, but only if they set a Preference on their account.)

I'll try and check out your latest attachment, if nobody else fixes it up for you. But likely not before the weekend, sorry, I'm just too busy right now.

@Adam Ledger It's not too hard to produce that kind of infix display as output.

But the tricky bit is if you want the customised notation for typeset 2D math input.

Do you need input as well as output?

I believe that Maple 7 will produce a plot structure in which the first operand is a CURVES substructure.

But the operands of the CURVES substructure will not be an Array or a Matrix or even a listlist. Rather it may be a sequence of lists. Each of those lists will contain two lists, each representing a point by having two floats designating x and y values.

In other words, the line segments are represented separately within the CURVES substructure.

I'm not sure whether either (end) point of any outer list will necessarily agree with a point in a neighboring outer list (of the sequence) even though several of them may visually render like a continuous curve when they are all displayed.

This is my recollection, anyway.

If the OP uploads a worksheet with the implicitplot displayed then I could extract the data for examination (even without re-executing).

I could also mention that it's always been an issue that the fsolve command uses its complex option in two ways: 1) to specify that nonreal results can be obtained, and 2) to allow searching over nonreal values. So it doesn't provide a nice way to allow searching for purely real results while computing with complex domain values.

But for your particular example this will also work,

ee:=-2*sqrt(-K[1]^2+1)*K[1]+4*K[1]^2-Pi-2*arctan(sqrt(-K[1]^2+1)/K[1]):

fsolve(ee, K[1]=0.5-I..20+I, complex);

                          0.9832314847

And this would work too,

RootFinding:-Analytic(ee, K[1]=0.5-I..20+I);

                          0.9832314850

@Adam Ledger If you want to get a string then you could use a TextArea Component.

MAPLE_PLEASE_HELP_1.mw

@das1404 please keep followup questions that are so closely related as this to the same thread. 

@Jameel123 
 

NULL

restart

u := proc (x, t) options operator, arrow; 1/2+I*sqrt(2)/(exp(-t+x)+2*exp(t-x))+(1/2)*(exp(-t+x)-2*exp(t-x))/(exp(-t+x)+2*exp(t-x)) end proc

proc (x, t) options operator, arrow; 1/2+I*sqrt(2)/(exp(-t+x)+2*exp(t-x))+(1/2)*(exp(-t+x)-2*exp(t-x))/(exp(-t+x)+2*exp(t-x)) end proc

plots:-complexplot3d([Re(u(x, t)), Im(u(x, t))], x = -3 .. 3, t = -3 .. 3)

Download plot33_b.mw

Could you upload an actual worksheet using the green up-arrow in the Mapleprimes editor, rather than just showing us inlined images?

@vv I agree. I was thinking about the given example, rather than in general.

Perhaps better would have been to take the result from `solve` without fancy options, apply `simplify`, and then put that into a piecewise manually constructed to return NULL except for x in the stated domain.

The `real` option is related to the `parametric` option of `solve`. See ?solve,parametric for a help page. It's weird that sometimes it has an effect for input other than polynomial systems, and that no error message is emitted in cases where it will have no effect. (bugs that I've reported previously...)

Having said all that, the following is produced (in Maple 14, since the Question is marked for that) even without the `real` option.

restart;

kernelopts(version);

`Maple 14.01, X86 64 LINUX, Oct 15 2010, Build ID 535952`

simplify(solve({y>1,y<2,3^665/2^x=y}, {x}));

piecewise(y <= 1, [], y < 2, [{x = (665*ln(3)-ln(y))/ln(2)}], 2 <= y, [])

 

Download solve_res.mw

@ganelon Use the command evalf to approximate to floating-point.

@Jameel123 Yes, there are lots of ways.

Please tell us what you want.

Do you want a 2D or a 3D plot? Do you want a single shape which changes color? Or which changes with time as an animation?

Do you want a density plot whose color or hue or intensity vary with complex argument or magnitude?

Or a single surface where the height represents the real component and the shading represents imaginary component?

Or a 2D curve with horizontal and vertical values taking the real and imaginary values parameterized by the "x" in u(x,t), and the whole thing animated by the "t".

Or something else?

First 259 260 261 262 263 264 265 Last Page 261 of 594