Doug Meade

 

Doug

---------------------------------------------------------------------
Douglas B. Meade <><
Math, USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Phone: (803) 777-6183 URL: http://www.math.sc.edu

MaplePrimes Activity


These are answers submitted by Doug Meade

Your question is not very detailed, so I have to make some assumptions about what you are trying to do. At the simplest level, I would suggest doing something like the following:

eq_C := y=x^2;
                                        2
                                   y = x 
eq_P := [x=t,eval(eq_C,x=t)];
                               [            2]
                               [x = t, y = t ]

If your cartesian form does not explicitly define y in terms of x, then you might have more success with something like:

eq_C := y=x^2+y^2;
                                      2    2
                                 y = x  + y 
eq_P := [x=t,isolate(eval(eq_C,x=t),y)];
                     [                           (1/2)]
                     [           1   1 /       2\     ]
                     [x = t, y = - - - \1 - 4 t /     ]
                     [           2   2                ]

Of course, in some situations choosing to make x the parameter is not the most efficient. I doubt Maple can reliably predict the "best" choice of parameter (because I doubt there is always a "best" choice). If you want to make y the parameter, then the second example becomes:

eq_P2 := [isolate(eval(eq_C,y=t),x),y=t];
                      [          /  2        2\       ]
                      [x = RootOf\_Z  - t + t /, y = t]
allvalues( % );
           [            (1/2)       ]  [             (1/2)       ]
           [    /     2\            ]  [     /     2\            ]
           [x = \t - t /     , y = t], [x = -\t - t /     , y = t]

For a different choice of paramter, the following could be of use:

q := x+y=t;
                                  x + y = t
Q := algsubs(x+y=t,eq_C);
                                   2            2
                            y = 2 y  - 2 t y + t 
Y := isolate( Q, y );
                                                    (1/2)
                        1   1     1 /             2\     
                    y = - + - t - - \1 + 4 t - 4 t /     
                        4   2     4                      
eq_P3 := [eval(isolate(q,x),y=Y),Y];
             [        /                                (1/2)\  
             [        |    1   1     1 /             2\     |  
             [x = t - |y = - + - t - - \1 + 4 t - 4 t /     |, 
             [        \    4   2     4                      /  

                                               (1/2)]
                   1   1     1 /             2\     ]
               y = - + - t - - \1 + 4 t - 4 t /     ]
                   4   2     4                      ]

Are any of these close to what you need?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

Nice problem. Good description of what you are trying to do, and the problems you are having.

I would solve this problem in the following four steps:

  • STEP 1: Define the Hamiltonian as a function of c (not c(t), that comes later)
H:=c -> u(c)+lambda(t)*(f(k)-c-delta*k) ;
  • STEP 2: Differentiate H(c) wrt c, then insert the dependence of c on t
foc_1 := D(H)(c(t));
                           D(u)(c(t)) - lambda(t)
  • STEP 3: Differentiate with respect to t
                   (and put the result into the equation form you request)
foc_2 := isolate( diff( foc_1, t )=0, c(t) );
                                  / d      \    d           
                @@(D, 2)(u)(c(t)) |--- c(t)| = --- lambda(t)
                                  \ dt     /    dt          
  • STEP 4: divide by lambda(t)
foc_2/lambda(t);
                                  / d      \    d           
                @@(D, 2)(u)(c(t)) |--- c(t)|   --- lambda(t)
                                  \ dt     /    dt          
                ---------------------------- = -------------
                         lambda(t)               lambda(t)  

I believe this is what you are trying to do. You were close. I hope this is helpful.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

 

Look a little closer, it's not Z, but _Z (the underscore is part of the name). And, this expression appears in the argument to the RootOf command. RootOf gives many users some trouble, until they understand that RootOf is a way to refer to solutions (specific or general) of a univariate equation and _Z is the generic name of the variable. For example:

z := RootOf(x^2+1=0);
                                     /  2    \
                               RootOf\_Z  + 1/
z^4;
                                             4
                                    /  2    \ 
                              RootOf\_Z  + 1/ 
simplify( % );
                                      1

a := RootOf(x^2+1=0,index=1);
b := RootOf(x^2+1=0,index=2);
                               /  2               \
                         RootOf\_Z  + 1, index = 1/
                               /  2               \
                         RootOf\_Z  + 1, index = 2/
evalc([a,b]);
                                   [I, -I]

In your case, the argument to RootOf is much more complicated. But, it's the same idea being used.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

This is an example in the online help for Maplets,Elements,Plotter:

A simple Maplet application demonstrating the animation capabilities:

with(Maplets[Elements]);
p := plots[animate](plot,[a*x+2*a,x=-10..10],a=-5..5,frames=20):
animator := Maplet(
  [ Plotter[P](p, continuous=false),
        [ Button("play",SetOption(P('play')=true)),
          Button("stop",SetOption(P('`stop`')=true)),
          Button("pause",SetOption(P('pause')=true)) ],
        [ Button("to start",SetOption(P('to_start')=true)),
          Button("to end",SetOption(P('to_end')=true)) ],
        [ Button("backwards",SetOption(P('frame_backwards')=true)),
          Button("forward",SetOption(P('frame_forward')=true)) ],
        [ "continuous",CheckBox[CONTINUOUS](value=false, 
       onchange=SetOption(target=P, `option`='continuous',
       Argument(CONTINUOUS))) ],
        [ "delay", Slider[DELAY](100..500, 200, 'filled'=true,
          'showticks','majorticks'=100, 'minorticks'=50,
       onchange=SetOption(target=P,`option`='delay',Argument(DELAY))) ],
       Button("ok",Shutdown()) ]):
Maplets:-Display(animator);

This should answer your question.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

 

The noborder option is working. What you are seeing is the boxed axes.

Remove axes=boxed from the plot command and see what you get. Here's what I get:

myPlot2:= plot(sin(x), x= 0..10, color= black, scaling= constrained, view= [0..10, -5..5]):
plotsetup(
  ps,
  plotoptions= `noborder,width=5cm,height=5cm`,
  plotoutput= "myPlot2.eps"
);
plots[display](myPlot2);
plotsetup(default);
Download 178_myPlot2.eps

Change ps to jpeg and you can see the file inline in the MaplePrimes post.

myPlot2:= plot(sin(x), x= 0..10, color= black, scaling= constrained, view= [0..10, -5..5]):
plotsetup(
  jpeg,
  plotoptions= `noborder,width=5cm,height=5cm`,
  plotoutput= "myPlot2.jpg"
);
plots[display](myPlot2);
plotsetup(default);

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

Just a minute, where did I put  my flame-retardant keyboard. I haven't had to use it lately, but it's here somewhere.

Found it.

Now, let's look at the Student Help Center Code of Conduct:

Student Help Center code of conduct (Please read!)

Welcome to the Maple Student Help Center. This is a great place to get help on effectively using Maple for your courses. This forum will be supported by Maplesoft staff as well as experienced users around the world. Please take the time to read the following code of conduct:

  • No illegal, obscene, defamatory, hateful, and other forms of offensive content.
  • Be respectful to other members. No name-calling or "flaming". We want everyone to find this forum useful. If you think someone has posted a "stupid" question, then ignore the post. You don't have to express your personal opinion on the person or question in public.
  • Respect copyright. Do not post other peoples' images or work without permission or the proper level of acknowledgment.
  • Do your own homework. Don't expect other people to do your math homework for you. But, if you're genuinely stuck on a Maple question or a math question, you'll likely be able to get help.
  • Post in the appropriate forum. The student forums are intended for math-related questions covering topics from late high school to second year college/university. For more advanced topics, please use the regular MaplePrimes forums.

    • How do I do x in Maple? (student) is meant for finding out how to solve specific types of problems in Maple
    • Math advice (student) is meant for seeking help on math as opposed to the software
    • Help Center suggestions are meant for giving feedback to Maplesoft on ways to improve this service
    • Student chatter is meant to capture posts on a wide range of topics (math, computers, school, politics, music, etc.)

We reserve the right to remove any posts that do not, in our opinion, fall within the guidelines of conduct for this Web community.

It appears to me that you have not followed three of the first 4 items in this list: obscene, disrespectful, and asking ohers to do your homework. There is no excuse for this. The way you have responded does not make me interested in trying to help you do your homework. There is a big difference IMHO between asking someone to do your homework for you and getting help with your homework.

One reason most of us want to see something that you have done towards your problems is that we want to see the level on which you trying to use Maple. You never told us what type of class this is for, or anything about your background. What version of Maple are you using? These are very important pieces of information I seek to have answered before I answer any question in this forum or in face-to-face interaction with students.

The post that offended you so much did contain some very useful suggestions, which you appear to have chosen to ignore. I'll focus on the second question. Maple has a command, isprime, that returns true if the argument is prime and false otherwise. For example, the following procedure returns all primes between its two arguments:

IP := (m,n) -> select( isprime, [$m..n] );
IP(10,20);
                              [11, 13, 17, 19]

This implementation does not use any explicit looping. It will be much more efficient than your attempt, but this might not be anywhere close to what you would be expected to understand or come up with on your own.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

 

You have everything you need in the code I posted previously in this thread. Just change the final display to

 

display(
  [pointplot3d( P , color=green ),
#   pointplot3d( P1, color=blue ),
#   pointplot3d( P2, color=gold ),
#   pointplot3d( P3, color=magenta ),
   pointplot3d( P, style=line, color=green ),
   pointplot3d( P1, style=line, color=blue ),
   pointplot3d( P2, style=line, color=blue ),
   pointplot3d( P3, style=line, color=blue ),
   seq( pointplot3d( [ P1[i], P2[i], P3[i], P1[i] ], style=line, color=red ), i=1..51 )],
  axes=BOXED
);
 

and the resulting plot will be

 

Change the colors, uncomment or comment out other plots if you want something more or less than what is shown here. The only real change is the plotting of the triangles. The seq command is used to create all 51 triangles, with each triangle obtained by connecting the corresponding points in P1, P2, and P3.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

Notice that the integrand never changes, so there is no point in creating it each time through the loop. You might be able to do more with this expression, but this does compute pretty quick. Instead of using 51x3 matrices, I use 1-D arrays of points. And, everything can be done in one loop.

Does this come close to what you are trying to do?

restart;
with( plots ):
P := Array(1..51);
P1 := Array(1..51);
P2 := Array(1..51);
P3 := Array(1..51);
R := proc (s) options operator, arrow; 0.6e-1*(arctan(10*s/1.3-3.0)/Pi+1/2) end proc;
y := proc (s) options operator, arrow; evalf((-1)*0.6e-1*(arctan(10*s/1.3-3.0)/Pi+1/2)*cos(6*Pi*s/1.3)) end proc;
z := proc (s) options operator, arrow; evalf(0.6e-1*(arctan(10*s/1.3-3.0)/Pi+1/2)*sin(6*Pi*s/1.3)) end proc;
f := unapply( simplify(sqrt(1-((6*Pi/(2.6)*0.6e-1)*R(s))^2-(D(R))(s)^2)), s ):
for i from 1 to 51 do
  X := evalf(Int(f(s), s = 0 .. 0.26e-1*i));
  Y := y(0.26e-1*i);
  Z := z(0.26e-1*i);
  P[i] := [X,Y,Z];
  P1[i] := [X,
            Y+0.2e-1*Y/(Y^2+Z^2)^(1/2),
            Z+0.2e-1*Z/(Y^2+Z^2)^(1/2)];
  P2[i] := [X,
            evalf(Y+0.2e-1*Y*cos(2*Pi*1/3)/(Y^2+Z^2)^(1/2)-0.2e-1*Z*sin(2*Pi*1/3)/(Y^2+Z^2)^(1/2)),
            evalf(Z+0.2e-1*Y*sin(2*Pi*1/3)/(Y^2+Z^2)^(1/2)+0.2e-1*Z*cos(2*Pi*1/3)/(Y^2+Z^2)^(1/2))];
  P3[i] := [X,
            evalf(Y+0.2e-1*Y*cos(2*Pi*1/3)/(Y^2+Z^2)^(1/2)+0.2e-1*Z*sin(2*Pi*1/3)/(Y^2+Z^2)^(1/2)),
            evalf(Z-0.2e-1*Y*sin(2*Pi*1/3)/(Y^2+Z^2)^(1/2)+0.2e-1*Z*cos(2*Pi*1/3)/(Y^2+Z^2)^(1/2))];
end do:

display(
  [pointplot3d( P , color=red ),
   pointplot3d( P1, color=blue ),
   pointplot3d( P2, color=gold ),
   pointplot3d( P3, color=magenta )],
  axes=BOXED
);

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

You open your initial post by telling us this is for a math assignment. I have done everything except do the problem for you. Your followup posts give no indication that you have any idea about the math behind what you are doing. Short of you giving us three data points, you have done nothing on this. I am not going to do more for you, sorry. That's not the purpose of this forum.

  1. What type of course are you taking?
  2. How have you used Maple before?
  3. If you haven't, why is it being used now?
  4. How are others in the course working this same problem?
  5. Have you talked with your instructor?

Learning requires effort and commitment. Show some effort and attempts to learn and maybe I will reconsider, but as for now I am done with this topic.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

 

Your question is not very specific. If I had to guess, it sounds as though you have some data and want to find a parabola related to the data. How you proceed with this depends on how much data you have and what types of mathematics you are expected to use.

The general parabola can be written as y = a*t^2 + b*t + c (using t for time).

If you have three data points, plug each into the equation for the parabola to get three equations for the three parameters a, b, and c. This will be a linear system and most likely will have exactly one solution. This can be done in Maple using eval to create the equations and then solve the system:

DISCLAIMER:  All code written without Maple, so minor typos are possible.

P := y = a*t^2 + b*t + c ;
eq1 := eval( P, [t=?,y=?} );
eq2 := eval( P, [t=?,y=?} );
eq3 := eval( P, [t=?,y=?} );
S := solve( { eq1, eq2,eq3}, {a,b,c} );
plot( eval( P, S ), t=0..5 );

If you have more than three data points, you could try the same approach but this will give you more than three equations for the three parameters. Now, unless your data is very very good, this system will not have a solution.

PTS := [ [t1,y1], [t2,y2], [t3,y3], [t4,y4] ];  # fill in your data here
P := y = a*t^2 + b*t + c ;
sys := seq( eval(P,[t=pt[1],y=pt[2]), pt=PTS )
S := solve( { sys }, {a,b,c} );                 # not likely to have a solution

In this situation you typically ask for the parabola that best fits the data. This is a more advanced mathematical idea, but is easily done in Maple:

P1 := CurveFitting[LeastSquares]( PTS, curve=a*t^2+b*t+c );
plot( P1, t=0..5 );

There is also an interactive CurveFitting interface:

CurveFitting[Interactive]( PTS, y );

I hope one of these is appropriate for you.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

At some point you are going to have to get all x on one side of the equation.

You distributed the multiplication by y through the term (x-3) to get (xy-3y). Why don't you do the same with the division by (y-5).

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

Fine. But, what did you actually try? Post your actual commands or, better yet, a full worksheet.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

There are too many syntax errors in what you posted to list them all. The misspelling of Int is only the start. The general problems are that square brackets cannot be used as parentheses, multiplication should not be implied (i.e., use *), and you have to decide to use an expression or a function.

When I fix all of these, here's what I get:

R :=  s -> 0.6e-1*(arctan(10*s/1.3+10*(-.3))/Pi+1/2);
          /      /10 s            \    \
          |arctan|---- + (-10) 0.3|    |
          |      \1.3             /   1|
s -> 0.06 |------------------------ + -|
          \           Pi              2/
x:=Int(sqrt(1-(6*Pi/(1.3)*0.06 (R(s)))^(2)-(D(R)(s))^(2)),s=0..1.3);
   /1.3                                                                    
  |                                                                (1/2)   
  |     /                    2             0.2130177514           \        
  |     |1 - 0.07668639050 Pi  - ---------------------------------|      ds
  |     |                                                    2    |        
 /0     |                        /                         2\    2|        
        \                        \1 + (7.692307692 s - 3.0) /  Pi /        
value( x );
                                0.6365144807

Doug
---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

Here's the general idea I would try to use:

T[0] := 1;    # replace with your initial value
T[1] := T[0]+f(T[0]);
for i from 0 while abs( (T[i+1]-T[i])/T[i] ) >= 0.001 do
  T[i+2]=T[i+1]+f(T[i+1]);
end do;

This is going to have a few problems - division by zero, infinite loop, ... but this should show you how to use Maple's looping structure.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

If you know some mathematical properties of the parameters in your function, then there is a chance you could create a system of equations (nonlinear?) that could be solved to find the values of the parameters.

Using your example, from the form f(x)=(a+b*x)*exp(c*x), we can find f(0)=a, f'(0)=b*c, and f''(0)=2*b*c+a*c^2. For example,

restart;
f := x -> (a+b*x)*exp(c*x);
x -> (a + b x) exp(c x)
F := (1.330+2.440*x)*exp(-3.660*x);
                       (1.330 + 2.440 x) exp(-3.660 x)
sys := [
  f(0)=eval(F,x=0),
  D(f)(0)=eval(diff(F,x),x=0),
  D(D(f))(0)=eval(diff(F,x,x),x=0)
];
        [                                           2              ]
        [a = 1.330, b + a c = -2.427800, 2 b c + a c  = -0.04465200]
solve( sys, [a,b,c] );
         [[a = 1.330000000, b = 2.440000000, c = -3.660000000], 

           [a = 1.330000000, b = -2.440000000, c = 0.009172932331]]

Interestingly, Maple found two solutions to this system. This method will work best when the system of equations is chosen in a way that ensures a unique solution. This could take some real thought, but could also be quite worthwhile. The answer depends, exactly, on your specific needs.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.ed

 

First 27 28 29 30 31 32 33 Last Page 29 of 44