Maple 2016 Questions and Posts

These are Posts and Questions associated with the product, Maple 2016

I am trying to find the orthocenter in the x,y plane, given three coordinates  (x1,y1) (x2,y2) (x3,y3).

I am trying to avoid division by zero.

orthocenter.mw
 

restart:
orthocenter:=proc(x1,y1,x2,y2,x3,y3)
local m1,m2,m3,L1,L2,L3,slope;
slope:=(a,b,c,d)->(d-b)/(c-a);

if x1=x2 then L1:=x=x1;
elif y1=y2 then L1:=y=y1;
else m1:=-1/slope(x2,y2,x3,y3); L1:=y-y1=m1*(x-x1);
end if;

if x2=x3 then L2:=x=x2;
elif y2=y3 then L2:=y=y2;
else m2:=-1/slope(x1,y1,x3,y3);L2:=y-y2=m2*(x-x2);
end if;

if x1=x3 then L3:=x=x1;
elif y1=y3 then L3:=y=y1;
else m3:=-1/slope(x1,y1,x2,y2);L3:= y-y3= m3*(x-x3);
end if;
print(solve({L1,L2,L3},{x,y}));
end proc:

orthocenter(1,1,3,4,5,3);

{x = 11/4, y = 9/2}

(1)

orthocenter(0,0,0,3,4,1)

Error, (in slope) numeric exception: division by zero

 

 


 

Download orthocenter.mw

 

The following website contains worksheets written in an early version of Maple.

http://www.yorku.ca/marko/ComPhys/

I would like to import worksheets 5.1 and 5.2 and work with them in Maple 2016. Is this possible?

Clicking on the worksheet id, e.g. 5.1, displays an .mws worksheet written in HTML which is not supported as an import format.

I am beginning to study Special Relativity and Classical Field Theory - The Theoretical Minimum by Leonard Susskind and Art Friedman.

The book's notation for a 4-Vector is X superscript mu. Its components are X superscripts 0, 1, 2 and 3 which, in sequence, refer to t(ime), x, y and z.

Proper time, tau, is defined using these vector components in that sequence.

The book's notation for 4-Velocity is U superscript mu with components U superscripts 0 thru 3. U superscript zero is defined to be the derivative of X superscript zero with respect to tau i.e. dt/dtau and the remaining U components follow this pattern.

As a beginner in this area, which Maple packages/commands would most easily and clearly implement this notation in a Maple worksheet? 

Why does solve not find the value of xp = sqrt(1-v^2) in this worksheet?

SpecialRelativity.mw

Reference: Special Relativity and Classical Field Theory. Authors: Leonard Susskind and Art Friedman

I have been working some plots using piecewise, and this seem to always result in graphs with very jagged edges

Example: https://i.imgur.com/ZBOSDsL.png

The function its plotting is this one:

f:=unapply(piecewise(x^2+y^2 <= 1 and x>=0, 4*x*y^2-x^2, undefined),x,y):

Now I assume this happens because of the piecewise part. How do I smoothen the edges?

How do I access and assign values given by the solve command

for example

f := unapply(x*(8*x^2+5*x+cos(y)), x, y);

p := solve({diff(f(x, y), x) = 0, diff(f(x, y), y) = 0}, {x, y})

This gives the following

{x = 0, y = (1/2)*Pi}, {x = -1/6, y = 0}, {x = -1/4, y = 0}, {x = -1/2, y = Pi}, {x = 1/12, y = Pi}

now if I type: p[1] I get the following

{x = 0, y = (1/2)*Pi}

Now this isn't very useful. I want to access the "0" and the "(1/2)*Pi". How do I do that?

Hi,

As a notional example those instructions generate 21 variables and around 4 Giga Bytes of data (bottom right of the Maple window ; roughly the same value read from the windows manager)

with(Statistics):
for n from 1 to 10 do
   X__||n := RandomVariable(Uniform(0,1)):
   S__||n := Sample(X__||n, 10^8)
end do:

I want to clean some part of the  memory ; for instance all the S__||n.
The following doesn't work

KeepVars := { seq(X__||n, n=1..10)}:
unassign({anames(user)} minus KeepVars ) ;
gc();


Is there a way to deallocate the memory occupied by some of my user variables ?
 

Hi, I'm trying to display (print / typeset) a vector of derivatives where an overdot is used instead of d/dt and the dependent variable is hidden.  For a single variable 

Suppress(x(t)):
diff(x(t),t);

Gives the desired result, but

Suppress(x(t)):
Suppress(y(t)):

<diff(x(t),t),diff(y(t),t)>;

doesn't.  I presume the vector/matrix package is doing something to the formatting?  Any help would be appreciated. Thanks.

Dears,  I have a questian about the fieldplot. 

I use the following 

with(plots):

fieldplot([x^2+y^2, 3*sin(x)-y^2], x = -1 .. 1, y = -1 .. 1, arrows = SLIM, color = x) ;

The domain is bounded from x = -1 .. 1, y = -1 .. 1.

Now, I want to use the same order to plot this function over a pentagon definde as 

with(plots):

Q11R := plottools[polygon]([[0, -1], [3/4, -1], [1, 0], [3/4, 1], [0, 1]], style = line, thickness = 3);

plots[display](Q11R, size = [.3, .5]).

I hope that I can find help.

Amr

 

I have a coupled pair of anharmonic oscillators and need to calculate the stability matrix and find the lyaupanov exponent for how the nearby trajectories diverge. In particular, I have the Hamiltonian

H = (p1^2+p2^2 + q1^4+q2^4 + 12*q1^2*q2^2 )/2

and I need to compute the matrix M given by

dM/dt = J*Hess*M

where J := Matrix(4,4,[0,0,1,0,  0,0,0,1,  -1,0,0,0,  0,-1,0,0]), and the Hessian takes the form:

Matrix(4,4, [6*q1_12(t)^2 + 12*Q2_12(t)^2, 2*12*Q1_12(t)*Q2_12(t),0,0,   2*12*Q1_12(t)*Q2_12(t), 6*Q2_12(t)^2 + 12*q1_12(t)^2,0,0,    0,0,1,0,    0,0,0,1])

The solver finds the trajectories of p1,p2,q1,q2 fine, but I don't seem to find a way to incorporate their solutions as inputs to reevaluate the Hessian at each time step. I read through https://www.maplesoft.com/support/help/Maple/view.aspx?path=DEtools%2fmatrixDE and the dsolve since I'm trying to do this numerically.

I thought I could get around this just by resolving the trajectories, but it's spitting out an error that arrays must be initialized with lists.

The actual code is here: AMO_HW4.mw

Sorry, I still need to clean it up a bit. Any help would be appreciated. I need to calculate M(t), then calculate the matrix norm and find the exponent.

 

 

 

 

How do i plot

in one plot with this paraellogram (it has to come out of the center of it)

test_sections.mw

Hi, I'm getting some unusual behaviour between the Explore() command / graphs and collapsed sections, as exemplified in the attached (linked) worksheet.  I'm trying to develop some worksheets with several sections where some of the sections have an explore() graph in them.  To keep things simple, I'd like some sections to be collapsed with the graphs hidden (and remain collapsed: View - Section - Autoexpanding - Uncheck) when the worksheet is evaluated.  In the attached, the section remains collapsed, so does the normal graph, but the explore "graph" gets published outside the collapsed section and when there is other information on the worksheet, the explore window appears almost randomly.

So is there any way to ensure the explore graph remains inside the collapsed section?

Sorry for the slightly longwinded explanation :-)

Thanks,

So I needed a CAS, and I spent a couple of months trying to get a basic understanding of SymPy and various applications starting with "M". We have Maple version 2016.

My "prototype problem" can be solved by hand, and is a system of quadratic Bellman equations, for i=1,2.  I'll return to it below, as I am obviously too clumsy to get even the second-to-simplest max/min working.  Oh, and I can't even insert Maple Math here in the forum, it does not like maximize or minimize.

Let's start easy. I enter
maximize((b-x)x,x) 
which works as I expect. Then already at
maximize((abs(b)-x)x,x>=0) 
I am stuck. Please, sweet Maple, you know that the answer is the same as before, don't you? (In the meantime I have tried to feed it maximize((b-x)x,x=0..1)... )

I was hoping my "proper" problem should be doable. What I really need is a sequence of quadratic optimization problems, where I have a vector x maximizing b'x-x'Ax subject to linear constraints, so it should not be too hard.  The "prototype problem" I needed for starters, is a system where for i=1,2 I have 

v_i(0,y)=0 and inductively v_i(t+1,y)=max{x_i*(b_i-x_1-x_2)+ r_i v_i(t,y-x)}

where b_i and r_i are constants, x=(x_1,x_2), y=(y_1,y_2), and everything is nonnegative - including, the choice variables x_i must be between 0 and min{y_i, b_i-x_1-x_2}. And I want to plot both functions and the x with time as a slider, but ... I don't think I'll ever get that far? 

Sorry for whining. (I know why I dropped out of computer science.)

This is my first post here, and any help is really appreciated.

I have two complex polynomials 

f(w)= w^8+w^6+4*w^4+w^2+1 , and 

g(w)= w^16+2*w^14+9*w^12-2*w^10+44*w^8-2*w^6+9*w^4+2*w^2+1 .

I want to plot the roots of f in blue, roots of g in red and a unit circle in black at the same picture. 

Thanks in advance for your help.

Good day, I have an assignment in which I'm required to plot the solid that results from the cone (x^2+y^2-z^2=0), limited by the planes z=0 and x+2z=3. So far I've been trying to use plot3d and implicitplot3d, to no avail: the parametric expression from plot3d returns something quite different from the intented, and implicitplot3d won't allow the use of variable parameters.

Any ideas on how to solve this?

First 18 19 20 21 22 23 24 Last Page 20 of 60