PatrickT

Dr. Patrick T

2073 Reputation

18 Badges

13 years, 136 days

MaplePrimes Activity


These are answers submitted by PatrickT

Following up on Georgios's lead, in your case you can actually get some explicit formulae for the roots. For any of the four roots, you can do the following:

 

solve(x^4 + 6*x^3 + 3*x^2 + 6,x);
alias( a=%[2] ); #equivalent to:  alias( a=RootOf(_Z^4+6*_Z^3+3*_Z^2+6, index = 2) );
convert(a,radical);

  RootOf(%1, index = 1), RootOf(%1, index = 2), RootOf(%1, index = 3),

        RootOf(%1, index = 4)

          4       3       2
  %1 := _Z  + 6 _Z  + 3 _Z  + 6


                                  a


                    /        1/2     1/2          1/2        \1/2
                    |14 %2 %3    - %3    %1 - 9 %3    + 36 %2|
                    |----------------------------------------|
              1/2   |                   1/2 1/3   1/2        |
            %3      \        (85 + 4 406   )    %3           /
    - 3/2 - ----- + ---------------------------------------------
              2                           2

                                         1/2 (2/3)
                        %1 := (85 + 4 406   )

                                         1/2 (1/3)
                        %2 := (85 + 4 406   )

                                 7 %2 + %1 + 9
                         %3 := ------------------
                                          1/2 1/3
                               (85 + 4 406   )


If you needed a more compact formulation, you could do

subs((85+4*406^(1/2))=b, % ); 

and so on, writing the root in terms of new parameters b,c, etc..

Suppose you want to copy the output of a matrix into a comment at mapleprimes. Suppose you want your matrix to look like something like this :


                            [1    0    0]
                            [           ]
                            [0    1    0]
                            [           ]
                            [0    0    1]

and not like this:

RTABLE(192033604,MATRIX([[1, 0, 0], [0, 1, 0], [0, 0, 1]]),Matrix)

I just discovered a way to do that by mouse action only. Select the matrix plus (at least) one character from the line above, which will typically be a colon or semicolon. Check the picture below -- notice the highlighted semicolon? A copy-paste action on that selection will give the formatted matrix above (plus a colon or semicolon), while a copy-paste action on the matrix only will give the RTABLE thing. I don't have an explanation.

Problem in the definition of your piecewise function:

f := piecewise(x = 2 and x=3 and x=5 and x=7, 1);

                                f := 0

Here's an example of how to use piecewise:

f:=piecewise(x<=2, 1, x>2, x);
                             { 1        x <= 2
                        f := {
                             { x        2 < x


you can then plot thus:

 

plot(f, x=0..5);

if you show more code, you're more likely to rcceive useable help. I assume you've looked up the Help on "plot"?

is( sin(x)/cos(x) = tan(x) );
                                 true

Hopefully this does answer your question:

fy := FORCE/(2*ANGLE*RADIUS)*cos(ANGLE):

plots:-implicitplot3d(fy,
  ANGLE=0..2*Pi,
  RADIUS=0..10, 
  FORCE=0..1, 
  coords=cylindrical, 
  axes=box, 
  shading=zgrayscale,
  style=surfacewireframe
);
 #The default style is surfacewireframe.

EDIT: oops, I didn't read your question properly, what I did below doesn't answer your question...

restart;
fy := FORCE/(2*Pi*R)*cos(PHI):

with(plots):
p3d := implicitplot3d(fy, PHI = 0..2*Pi, FORCE = 0..10, R = 0..1):
display(p3d, axes=box);

Fantastic, Robert. Yes this does exactly what I was looking for. For instance,

init:= map2(getarrows,0.2, [
> 0.08, 0.081, 0.082, 0.083, 0.084, 0.085, 0.086, 0.087, 
> 0.0871, 0.0872, 0.0873, 0.0874, 0.0875, 0.0876, 0.0877, 0.0878, 0.0879, 
> 0.0872981, 0.0872989, 
> 0.088, 0.089, 0.090, 0.091, 0.092
> ]):

gives:

And I think that I'm learning something from this particular positioning of the arrows. Perhaps alternating colors would help distinguish the arrows in the initial salvo.

One more thing I'll look into is to plot iso-lines connecting the extremities of the arrows. I can probably extract that information from your procedure, and then extrapolate between the points.

This will keep me busy for a little while. I've got to learn, "events", "halt", the difference between "procedurelist" and "listprocedure", "map2", and "floor", so I'll probably keep a low profile for a while.

Thanks a lot Robert!

if you're looking for a tangent to the contour lines (indifference curves) with a given slope, there is one for each contour line. The equation for a contour line Q[a]^alpha*Q[b]^(1-alpha)=U, for a given value of U, is in explicit form:

solve(Q[a]^alpha*Q[b]^(1-alpha)-U,Q[b]);
                         -ln(U) + alpha ln(Q[a])
                     exp(-----------------------)
                               -1 + alpha

Consider the line with equation Q[b]=A - B*Q[a], where B is the known slope and A an unknown intercept. The point of tangency of your tangent and of your contour line is a particular solution of the system formed by the two equations:

IC := Q[b] = exp((-ln(U)+alpha*ln(Q[a]))/(-1+alpha));
BC := Q[b] = A - B*Q[a]; 

where U, alpha, and B are given but A is unknown. The above system will generically have two solutions and your A is the value where the two solutions reduce to one solution (rather like the case of a quadratic equation going from 2 solutions to 1 as one parameter is changed and the discriminant crosses zero).

This seems rather complicated.

But of course one straightforward way to do this is to solve the maximization problem that it represents, i.e. find the first-order condition of the maximization of U(Q[a],Q[b]) given the constraint BC -- in your case (known as Cobb-Douglas) it is straightforward to solve it in closed form, so that once you have your values of Q[a] and Q[b] in terms of the parameters of the problem (including A) you can substitute those values into the above system and solve for A. In short, the missing information is contained in the first-order condition of the maximization problem associated with your IC and BC.

Note that the more standard problem is: given a budget constraint BC (above) where both A and B are known, find the value of U in the indifference curve  IC (above) such that the IC is tangent to the BC.

your code doesn't run as is, there are several problems, in your loop in your differential equation, etc., for instance here

^*

and here

(*

 

... is this your DE?

DE := (-1/(2)*diff(diff(F(x),x),x) + (x^(4)-3)*(exp((-x^(2))/(2)))*F(x)) = E*F(x);
               / 2      \                    2
               |d       |     4             x
    DE := -1/2 |--- F(x)| + (x  - 3) exp(- ----) F(x) = -3/50 F(x)
               |  2     |                   2
               \dx      /

 

your expression is very big, and contains absolute values, it's hard to see whether what you're asking is feasible. I'd recommend you go step by step -- first, reduce the size of the expression, if that fails try to remove the absolute value and use "assuming real" or "assuming positive" instead, maybe eliminate the squares to see if that helps. Once you get something on which "eliminate" works, then gradually introduces the more complicated bits until you find out where "eliminate" fails. You can set printlevel:=1; where you gradually raise the digit 1 to 2, 3, 4, etc. and that should give you some information about what's happening or not happening. But at this stage your expression is too messy for printlevel to give useful information, I think.

Joe Riel has just put together a very thorough introduction/tutorial on the differences between sum and add, you ought to check it out, you may find something applicable to your case, e.g. delaying evaluation using quotes, perhaps:

http://www.mapleprimes.com/forum/suggestionfrequentanswersection#comment-30664

you need a criterion according to which to evaluate the "goodness of fit". Least Squares minimizes the sum of the squared residuals, and that's one way (standard OLS regression). Another way is to minimize the sum of the absolute values of the residuals (median regression). Another way is to define a likelihood function and maximize that. There are many ways.

replace D by something else, say DD:


D:=1;
Error, attempting to assign to `D` which is protected


assign parameters for your DD and a, then plot, adjust range.

restart;
params := [DD=1, a=1]:
expr1 := 2*DD*(2*(a^2)*(y^4)-(a^4)*(y^2)-1)/((a^2)*(y^3))=10;
expr2 := x=2*DD*((a^4)*(y^2)-1)/((a^4)*(y^3));
eval(expr1,params);
eval(expr2,params);
p1 := plots:-implicitplot( eval(expr1,params), x=-1..1, y=-1..1):
plots:-display(p1);
p2 := plots:-implicitplot( eval(expr2,params), x=-1..1, y=-1..1):
plots:-display(p2);
plots:-display(p1,p2);
First 11 12 13 14 15 16 17 Last Page 13 of 24