tomleslie

13821 Reputation

20 Badges

14 years, 214 days

MaplePrimes Activity


These are answers submitted by tomleslie

This works for me

 

with(DEtools):
eqn1:= diff(y(x),x)+4*y(x)^3-3*y(x)=0:
DEplot(eqn1, y(x), x=-1..1, y=-1..1);

restart:
with(LinearAlgebra):
with(CurveFitting):
M:=RandomMatrix(12,2):
pairs:=[ seq([M[j,1], M[j,2]], j=1..RowDimension(M))]:
PolynomialInterpolation(pairs, x);

Important things to realise are

  1. it is necessary for y<abs(x) so that the arcsin function is meaningful
  2. the function is actually defined for all (x,y) provided a value is defined for (x,y)=(0,0), and the restriction y<=abs(x) is maintained. The OP's requirement for -pi/2<=x,y,<=pi/2 is better interpreted as a region over which to plot than part of the piecewise definition
  3. This function gets very ugly for negative alpha. The factor (x^2+y^2)^alpha -> infinity as (x,y)->(0,0) when alpha is negative, and the value is defined as 0, when (x,y)=(0,0): not a good combination.

I came up with the attached

 

asinfunc.mw

I think you have a fundamental problem of understanding,

You seem to expect (-0.2)^0.1 to be a real number?!!

Well, for example, if you set alpha=0.5, would you expect

(-0.2)^0.5=sqrt(-0.2)

to be a real number??

On which planet would you expect the tenth root of a negative number to be anything other than a complex number??

I suggest you examine the dfference between

plot(floor(x), x=0..10);

and

plot(floor(x), x=0..10, discont=true);

 

The check out the advice on plotting discontinuous functions using

?[plot,discont];

Not exactly sure how complicated you want to get but you could try either of the following

    restart;
#
# Use simple functional operator, which is
# fine if returned values are very simple
# functions of the row and column indices
#
    f1:= (r,c)->`if`(type(r+c, even),0,1):
    m1:= Matrix(3,f1);
#
# Or using s simple procedure which allows
# greater control over the return value
# for any given combination of row and and
# column indices
#
    f2:= proc(r::integer,c::integer)
                   if      type(r+c, odd)
                   then return 0:
                   else return 1:
                   fi:
           end proc:
    m2:=Matrix(3, f2);

The most general way is the second of the above - write a simple procedure which accepts two integer arguments (the row and column indices) and returns a single value corresponding to that index combination

Thanks Prebhen: I tried your stuff, but couldn't make the animations work properly, so they gave me no further insight. However your idea of plotting a few things was too godd to pass up so added some to my original worksheet (new version attached) and this was reasonably illuminating

posVecChk.mw

My conclusions now are

  1. when using options spherical in plotting commands, then the zenith angle is the third entry in the triple, so that the coords/help page is correct
  2. when using  the option spherical in VectorCalculus, PositionVector command, then zenith angle is the second entry in the triple, so that the coords/help page is incorrect

I see that dharr has just added a comment (thanks) which seems to confirm my conclusion, but like me has not been able to find any help entry which confirms this.

Do either of you know whether it is possible to flag this discussion to a Maple moderator for a definitive comment?

Thanks for the help, I'm going to lie down now

Well everything following the hash (#) character on a line is considered a comment.

a:=2: # I've just assigned a to be 2

or

# This is a simple one-line comment

If you need multiline comments then anything between (* and *) will be treated as comment, eg

(*
 whatever I write in here will be

totally ignored by the

Maple interpreter

and treated as a comment

*)

All of this stuff is in the help files - what's difficult??

Can't fill a spacecurve, so back to the drawing board!

I suspect there are several different ways to do this, but my first/only attempt is

with(plots):
ampl:=[2.0, 1.1, 1.2, 1.4]:
incl:=[0.0, 0.1, 0.2, 0.3]:
phases:=[0, Pi/8, Pi/4, Pi/2]:
colors:=[black, blue, red, green]:
ps:=[ seq
      ( implicitplot3d
        ( z=incl[j]*r*cos(theta-phases[j]),
          r=0..ampl[j],
          theta=-Pi..Pi,
          z=-1..1,
          coords=cylindrical,
          color=colors[j],
          style=surface,
          numpoints=10000,
          transparency=0.5
        ),
        j=1..4
      )
   ]:
display(ps);

Clunky, but it works.

You could probably do a fair bit of fiddling with the various plot options to improve the "look"

Lots of ways to do this,  but the most general I can thnk of is to specify the radii, the inclination and the phase of the inclination separately: somethng like

with(plots):
ampl:=[1.0, 1.1, 1.2, 1.4]:
incl:=[0.0, 0.1, 0.2, 0.3]:
phases:=[0, Pi/8, Pi/4, Pi/2]:
colors:=[black, blue, red, green]:
display(  seq( spacecurve( [ ampl[j]*cos(t),
                                         ampl[j]*sin(t),
                                         incl[j]*cos(t-phases[j])
                                      ],
                                      t=-Pi..Pi,
                                      color=colors[j],
                                      view=[-1.5..1.5,-1.5..1.5,-1..1]
                                   ),
                     j=1..4
                   )
           );

Although obviously you are going to have to do a lot of fiddling to get the precise values you want

Couldn't run your worksheet cos it came up with an error I couldn't be bothered to debug

However you can specify tickmarks on a given axis - the following is a  really simple example which demonstrates the basics (with some more or less randomly distributed tickmarks on the x- and y-axes)

xvals:=[0.5, 0.75, 1.25, 2]:
yvals:=[0.25, 0.75, 1.0, 1.85]:
plot3d( x^2+y^2, x=0..2,y=0..2, axis[1]=[tickmarks=xvals], axis[2]=[tickmarks=yvals]);

which sets the values of the tickmarks on the relevant axis to those specified by the appropriate list

Don't have a real problem with the previous answer, but ignoring possible discontinuities in an integrand can lead to trouble. Consider the four (real) possibilities for your variables: Maple gives the correct answer for each

restart:
int(x__1^k, x__1=0..x__2) assuming x__2::negative, k::positive;
int(x__1^k, x__1=0..x__2) assuming x__2::positive, k::positive;
int(x__1^k, x__1=0..x__2) assuming x__2::negative, k::negative;
int(x__1^k, x__1=0..x__2) assuming x__2::positive, k::negative;

If you actually know the constraints on x__2, k, then it is probably safer to express them explicitly, as in one of the above options

restart:
with(plots):
semilogplot(20*log10(1/(1+f)), f=10^(-4)..10^4);

The variable 's' in the TransferFunction command has to be an unassigned global. By default it seems to be "unitless". So I'm guessing that the problem is that in generating the transfer function you are trying to add a unitless quantity (ie 's') to those with units (eg 'wo'), which is technically incorrect.

Rewriting the transfer function argument, so that 's' is povided with units, then the following seems to work in Maple 18.0

restart;
with(Units[Standard]):
R1 := 18.2*10^3*Unit('Omega'):
R2 := 10^3*Unit('Omega'):
C1 := 470*10^(-12)*Unit('F'):
C2 := 4.7*10^(-9)*Unit('F'):
# wo is in hertz
wo := 1/sqrt(R1*R2*C1*C2):
# Q is unitless
Q := wo*R1*R2*C2/(R1+R2):

with(DynamicSystems):
#
# Make sure that s has appropriate units
#
sys2 := TransferFunction( wo^2/((s*Unit('Hz'))^2+wo*(s*Unit('Hz'))/Q+wo^2) );
BodePlot(sys2, hertz = true, output = dualaxis);

Don't have access to Maple 16, so can't comment on Carl's observation that the original code works in that version

Well you don't give the circles you want to plot, or the system of differential equations, so it is impossible to provide an explicit solution. The following works for a couple of "made-up" circles and a "made-up" pair of differential equations

with(DETools):
with(plottools):
with(plots):
#
# define the two circles as plot objects
#
c1:=circle([0,0], 0.5, color=red):
c2:=circle([0,0], 0.75, color=blue):
#
# Using a random pair of differential equations (cos OP
# doesn't give the ones he wants), generate its plot object
#
sys := {diff(x(t), t) = y(t), diff(y(t), t) = -x(t)-(1/2)*y(t)}:
de:=DEplot(sys, [x(t), y(t)], t = 0 .. 30, [[x(0) = 0.8, y(0) = 0]], x = -1.25 .. 1.25, y = -1.25 .. 1.25, numpoints = 300, axes = boxed):
#
# display all three plots
#
display([c1, c2, de]);

First 204 205 206 207 Page 206 of 207