Carl Love

Carl Love

26089 Reputation

25 Badges

11 years, 54 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

dotprod(j,k) is 0 after you radnormal or simplify it. There is nothing wrong with your code.

You should not use linalg anymore. Use LinearAlgbera. It is available in Maple 8.

I can't tell if you want to create a surface, or if you simply want the sequence of curves in a 3D plot. If you just want the curves, it requires merely a trivial modification to your code:

  1. Change the curve that you plot in the odeplot command from [X(t), Y(t)] to [ j, Y(t), X(t)].
  2. Change the display command to display(convert(plott, list)).
  3. (Optional) Include an option such as thickness= 5 in the odeplot to improve visibility.

If you do want to create a surface, let me know.

 

[I converted your Post into a Question.-- Carl Love as a moderator]

Please upload a worksheet and/or post your equations in plaintext so that we do not need to retype them into Maple. Thanks.  The solution to your problem is probably to simply include a range in the fsolve command. See ?fsolve,details

fsolve({f, g}, {x= 0..Pi/2, y= 0..Pi/2});

Here's how to do it with a continuous transformation to your existing color function, which is presumed to return a value between 0 and 1 (the HUE color scale). Keeping it continuous is very very nice when you want colors to represent  numeric values. Let's say your existing color function is C, and your coordinate functions for a parametrized surface are Fx, Fy, Fz.

Gamma:= 1.15:
plot3d(
     [Fx, Fy, Fz],  a..b, c..d,
     color=  [
          (x,y)-> (1-C(x,y))^Gamma/3, #Hue
          (x,y)-> 1-C(x,y)/4,         #Saturation
          (x,y)-> 1-C(x,y)/7,         #Value
          colortype= HSV
     ],
     lightmodel= NONE,
     style= patchnogrid     
);

There are several parameters that can be adjusted; I've chosen some of them by my personal taste for color .

  • Gamma controls the evenness of the distribution between red and green. I gave this one a name because this is a well-known concept (see the Wikipedia article "Gamma correction").
  • The 3 in the Hue selects the fraction (1/3 in this case) of the full color spectrum that you want. If you want green to red, it will need to be pretty close to 3.
  • The Hue value is subtracted from 1 to make the scale go green to red rather than red to green.
  • The 4 in the Saturation controls (to some extent) how "light" the light-green is.
  • The 7 in the Value controls (to some extent) how dark the dark-red is (lower values will make it darker).
  • lightmodel= NONE is used so that the colors will not change due to shadows when the plot is rotated.

Here is the resulting sub-spectrum:

Brian wrote:

the above solution violates my assumption phi should be between -1.57 and +1.57. why?

Markiyan's Answer addresses well how to get the results. Regarding why you had the problem: solve generally ignores assumptions (see ?solve,details), sometimes without warning. Instead of using assumptions, you can include inequalities with the equations that you pass to solve, as Markiyan did.

You wrote:

so I dont actually need to asign as I did with xs??

Like virtually all commands in Maple, you do need to assign the results of dsolve in order to use them later.

You wrote:

in ordinary circumstances plot(eval(x(t),t=0..3) would be sufficient?

No, the command is plot(eval(x(t), xs), t= 0..3). It requires the xs. Note that you cannot directly plot the results of a dsolve(..., numeric); for the numeric case, use plots:-odeplot instead.

You wrote:

could I similarly use eval(xs,x(t)) ??

No, the command is eval(x(t), xs). The second argument to this type of eval must be an equation, or a list or set of equations--- which is what xs is in the case of a non-numeric dsolve.

You wrote:

ode3 := diff(y(t), t, t) = y(t)*sqrt((1-y(t))^2-1)/(1-y(t))

ics3 := y(0) = -2, (D(y))(0) = 0

ys := dsolve({ics3, ode3}, numeric)

I can ode plot this as the first one.

But my next step was to parametrically plot both solutions like

plots:-odeplot([xs(t), ys(t), t = 0 .. 3])

plots:-odeplot([xs, ys, t = 0 .. 3])

plots:-odeplot([x(t), y(t), t = 0 .. 3])

Unfortunately, each invocation of plots:-odeplot can only be used with the results of a single dsolve(..., numeric). But there are two ways around this problem. The first is to apply dsolve to the ODEs together as a system:

Sol:= dsolve({ode3, ics3, ode, ics}, numeric):
plots:-odeplot(Sol, [[t,x(t)], [t,y(t)]], t= 0..3);

The second is to combine two plots with plots:-display (which can combine any number of plots):

plots:-display([
     plots:-odeplot(xs, t= 0..3),
     plots:-odeplot(ys, t= 0..3)
]);

The second method gives you more flexibility.

You wrote:

how can one plot:

plots:-odeplot(f(xs), t= 0..3);

with some function f

Like this:

plots:-odeplot(xs, [t, f(x(t))], t= 0..3);

The command that you need is

B:= copy(A);

See ?copy for some details why. A few types of "container" structures in Maple are considered "mutable": tables, rtables (which includes Arrays, Matrices, and Vectors), procedures, and modules (which includes Records). Mutable objects need to be fully copied in order for an assignment to one to not affect the other. Note that most structures in Maple are not mutable even if they are containers: lists, sets, sequences.

 

As you have written it, it's an ODE, not a PDE, because all the derivatives are taken with respect to (wrt) x. Perhaps you meant for the derivative on the right side of the equals sign to be wrt t instead? Since it's a second-order ODE wrt x, two boundary conditions are enough, hence the error message.

The result returned by your dsolvexs, is of the form x(t) = ....  The plot command is complaining because you passed it an equation. The actual solution is the right-hand side of the equation. There are many ways  to isolate the right-habd side. One way that's easy to remember is rhs(xs). The way I generally prefer is eval(x(t), xs). Under ordinary circumstances you could give the plot command

plot(eval(x(t), xs), t= 0..3);

But these are not ordinary circumstances. The solution, although it appears short, is so complicated that Maple is having a lot of trouble evaluating it numerically. What we need to do is get a numeric solution from dsolve and then use plots:-odeplot to plot it:

xs:= dsolve({ics, ode}, numeric);
plots:-odeplot(xs, t= 0..3);

By the way, the right side of your ode has the useless coefficient 1^2. Did you intend for that to be something else?

How about this for the graphic?

N:= 96:
SP:= [seq](
     plots:-spacecurve(
          [1, k*3*Pi/N+Pi/2/N*floor(k/N), phi], phi= -Pi..Pi, coords= spherical,
          thickness= 9,
          transparency= 1-(N+k)/3/N
     ), k= 0..N
):
plots:-display(
     [plots:-display(
          [seq](plots:-display(SP[N+2-k..N+1]), k= 1..N+1)
         ,insequence
     ),
     plots:-tubeplot([0,0,t], t= -1..2, color= blue, radius= 0.05, transparency= .75),
     plots:-tubeplot([t,0,-1], t= -2..2, color= black, radius= 0.05, transparency= .6),
     plots:-tubeplot([0,t,-1], t= -2..2, color= black, radius= 0.05, transparency= .6),
     plot3d(-1, x= -2..2, y= -2..2, color= black, transparency= .5)
     ], axes= none, scaling= constrained, lightmodel= light4, style= patchnogrid,
     glossiness= 1
);

In the future, use square brackets for indexing (such as a[3]), not parentheses (such as a(3)).

Sys:= {seq}(eq(k), k= 1..18):

# Change to square brackets:
Sys:= subs([seq](a(k)= a[k], k= 1..18), Sys):
fsolve(Sys, {seq}(a[k], k= 1..18));

{a[1] = 0.000126988919895945, a[2] = -0.00105660821302691,
 a[3] = 0.00308434899631239, a[4] = -0.00423918949116484,
 a[5] = 0.00282464668788845, a[6] = -0.000740204565874612,
 a[7] = 0.290738925426173, a[8] = -1.17503115010852,
a[9] = 1.66075257813012, a[10] = -0.945945157740450,
 a[11] = 0.174368773622886, a[12] = -0.000158583197276566,
 a[13] = -0.00000150252845025158, a[14] = -0.0968979999980298,
 a[15] = 0.293699162347833, a[16] = -0.332030736202987,
 a[17] = 0.157521639797399, a[18] = -0.0248287447073636}

That took 3.45 seconds on my computer.

The residuals are not very good. You should use a high value of Digits (like 30) for the computation, and you should use more digits in your input constants.  I got good residuals (~ 10^(-19)) at Digits = 30.

This is difficult to diagnose without seeing the output of the previous commands. Nonetheless, I have an idea. Change the line

DE_C_tank_1 := diff(C_1(t), t)+m_out_tank_1*C_1(t)/M_tank_1-C_lost_tank_1 = Charge_rate_V3*C_V3/M_tank_1+Charge_rate_V4*C_V4/M_tank_1;

to

DE_C_tank_1 := diff(C_1(t), t)+~m_out_tank_1*C_1(t)/M_tank_1-C_lost_tank_1 =~ Charge_rate_V3*C_V3/M_tank_1+Charge_rate_V4*C_V4/M_tank_1;

The only difference is that I added two tildes (~), one after the first plus sign and one after the second equals sign. The purpose of the tilde is to "map" the operation over the whole Array. So, the output of the corrected command will be a single Array.

Let me know how that goes.

How about this?

Student:-Calculus1:-VolumeOfRevolution(
     sqrt(1-rho^2), -sqrt(1-rho^2), rho= 0..1,
     axis= vertical,
     output= animation
);
Student:-Calculus1:-VolumeOfRevolution(
     sqrt(a^2-rho^2), -sqrt(a^2-rho^2), rho= 0..a,
     axis= vertical,
     output= integral
);
value(%) assuming a>0;

You wrote:

I need to find a way to let Maple read the sigvm in 'normal' (x,theta) and plot them on (xcart,ycart,zcart) the deflected pile.

Try this (type it exactly like this (spacing doesn't matter)):

plot3d( 
     [xcart, ycart, zcart], 0 .. L, 0 .. 2*Pi,  
     color= unapply(sigvm(theta,x), [x,theta]),
     axes = boxed, scaling = constrained
);

We can trick rsolve into solving for a two-argument function by making the non-independent argument (i.e., the one fixed with respect to the recurrence) into an index.

 

Req:= g[m](n) = g[m-1](n)+g[m](n-1);

g[m](n) = g[m-1](n)+g[m](n-1)

Req[m=1]:= eval(Req, m= 1);

g[1](n) = g[0](n)+g[1](n-1)

rsolve(Req[m=1], g[1](n));

g[1](0)+Sum(g[0](n0), n0 = 1 .. n)

rsolve(Req[m=1], g[1](n), 'genfunc'(b));

-(Sum(g[0](n)*b^n, n = 1 .. infinity)+g[1](0))/(b-1)

 


By the way, there is no command Summation in Maple. The command is Sum (inert form) or sum (active form).

By the way (2), you probably know this, but your basic two-variable recurrence g(m,n) = g(m-1,n) + g(m,n-1) has solutions generally of the form binomial(m+n, m). The precise solution depends on initial and boundary conditions.

Download Two_var_rec_rel.mw

First 349 350 351 352 353 354 355 Last Page 351 of 378