Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 313 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

@yonasmibi If you want to use indexing, so that all previously computed values are stored in a table (the default) or a Vector (sometimes more efficient than a table) then you should do something like

for i to n do
   k[i+1]:= k[i]*(-b*r[i]+a+1);
   r[i+1]:= r[i]*(b*e*k[i]-c+1)
od;

This is the typical pattern for evaluating recurrence formulas: The index, i.e. the i or i+1 in this case, should be larger on the left side of := than on the right. To do this with Vectors, they should be declared with n+1 elements:

k:= Vector(n+1);  r:= Vector(n+1);

Tables never have a limit on their number of entries. They can be declared as k:= table(), etc., but it's often not necessary.

If you only want to get the final values after n iterations, then it's not necessary to use any indexing or container storage. All that's needed is

to n do (K,R):= (K*(-b*R+a+1), R*(b*e*K-c+1)) od:

It's necessary to use multiple assignment in the above. If you tried consecutive assignment, then the new value of K would erroneously get used in the formula for R.

 

For the distribution that you present, it is trivial and common to generate a sample simply by using rand; there's no need to refer to a PDF.

Sampler:= k-> n-> (r-> ['r()'$n])(rand(0..k)):
d4:= Sampler(4):
d4(9);

 

In addition to what vv said (which is totally correct):

The saving to a file and using in another worksheet is totally a red herring (English idiom for "misleading clue"). You'd have the same trouble if you tried to access psi in the first worksheet.

When you call newprocedure, regardless of which worksheet you call it from, you'll need to assign its results:

(H, psi):= newprocedure(2)

It is totally irrelevant whether you use the same names and psi or different names in the line above. In other words, the names that you use for the matrices outside the procedure have no connection to the names used inside the procedure.

 

Yes, there is now a command that can do that: Explore. But I don't think it exists in Maple 12.

You can change the vertex labels with GraphTheory:-RelabelVertices. The help page ?GraphTheory,GraphDrawingOptions describes how to change the color, border, and font of the vertices. You can change the plot positions of the vertices with GraphTheory:-SetVertexPositions. But I don't think that there's any direct way to print the labels outside the vertex. However, it should be fairly easy to do it indirectly by using GraphTheory:-GetVertexPositions combined with plots:-textplot, GraphTheory:-DrawGraph(..., showlabels= false), and plots:-display.

If your expression containing theta is expr, then do 

diff(subs(theta= theta(t), expr), t);

In other words, theta has been replaced by theta(t), which indicates that theta is a function of t.

Here is a simple closed-form answer that only uses real numbers:

U := n->
   exp(.238022513478555*n)
    * (1.70226106278932*sin(1.91811758317245*n)
       + 1.28091347285205*cos(1.91811758317245*n))
    + 6.71908652714795*exp(.622567261710995*n);

To get exact integer values, apply round.

I am working on an elementary expository derivation of the above formula for you. 

Your initial conditions are wrong. They should be U(-2) = 2, U(-1) =2, U(0) = 2.

What I present here is not the standard straightforward explanation; rather, I think it's the most-compact elementary explanation. Nonetheless, you should be able to find it in any good textbook for a full-year introductory single-variable calculus course.

We'll suppose that a(x) > 0 for all x. This is only done pedagogically to avoid imaginary numbers; it's not mathematically necessary.

Let y(x) = a(x)^b(x)  =>   ln(y(x)) = b(x)*ln(a(x)) . Differentiate both sides wrt x:

y'(x)/y(x) = b'(x)*ln(a(x)) + b(x)*a'(x)/a(x)  =>  y'(x) = y(x)*(b'(x)*ln(a(x)) + b(x)*a'(x)/a(x))  

=>  y'(x) = a(x)^b(x)*(b'(x)*ln(a(x)) + b(x)*a'(x)/a(x)). Now, rewrite "prime" notation as "diff" notation and you'll have what you posted.

A list of lists, all having the same number of elements, is called a listlist in Maple-lingo. It's a primitive form of matrix, and it's often a useful substitute for an official Matrix. If A is a listlist, then its transpose is

`[]`~(A[])

Thus, what you want to do can be done by

A:= [[0, 1, 2, 3, 4, 5], [0, 2, 4, 6, 8, 10]]:
writedata(test, `[]`~(A[]), integer);
0	0
1	2
2	4
3	6
4	8
5	10

 

I don't build web pages, so I've never done this, but I suspect that you could embed a Maple Player  , which is a freely redistributable app whose main purpose is allowing those who don't own Maple to view your worksheets.

Maple can solve nonlinear ODE BVPs both symbolically and numerically. It can solve linear ODE IVPs by Laplace transforms, but not nonlinear ones.

Please post an example BVP of the type that you work with and state whether you want a symbolic or numeric solution.

Your first plot specification is [X[k],Y[k]], k= 0..n. This type of specification treats k as a continuous variable. Since k is an integer variable, use seq, replacing the above with

[seq([X[k],Y[k]], k= 0..n)]

(I see now that the above is substantially the same as Kitonum's Answer.)

Here's another way, usings Arrays, and a single plot command:

f:= x-> x^2 + x - 12;
(a, n, h):= (0, 10, 5);
X:= Array(0..n, i-> a+(i-1)*h, datatype= hfloat); #Also works w/o datatype= hfloat.
Y:= map[evalhf](f,X); #Also works w/o [evalhf].
printf("\n    i        x       f (dec.form)    f (sci. notat.)\n"); 
printf( "  ---------------------------------------------------\n"); 
seq(printf(" %5d  %9.4f  %14.9f  %18.10e\n", i, X[i], Y[i], Y[i]), i= 0..n);
plot(
   # <...> is Matrix/Vector constructor/amalgamator.
   # (...)^+ is Matrix transpose.
   [<X,Y>^+, f(x)], x= a..a+n*h, 
   style= [point, line], symbol= soliddiamond, symbolsize= 24,
   color= [blue, black]
);

 

String literals, such as "A", should be in double quotes. Since you're also using as a matrix name, it can't be a string also. But "A" is always a string.

You have two errors, each of which occurs twice. The first error is that if you're going to use both a "parent" variable (such as your f or theta) and a subscripted form of that variable (such as f[0] or theta[0]), then you can't make an assignment to either form or to a function made from it, such as f[0](eta). If you do it, it doesn't immediately cause an error; it just leads to erroneous results later[*1]. So, in L[1] and L[2], you should change both f and theta to something else.

The second error is that in your assignments to ode1 and ode2, you need to put a space after L[1] and L[2] for there to be "implied multplication". Placing a name (such as L[1]) immediately before a left parenthesis is interpretted as function application rather than multiplication.

[*1]In particular, making an assignment to f[0] turns f into a table, which is why you see table in the error message.

Your PDF file has one differential equation with two unknown functions: Z(t) and V(t). Thus, you'll need one more equation with one or both of those functions. You'll need two initial condition for Z (for example Z(0) and Z'(0)) and perhaps also one or more for V, depending on the highest differential order of V (if any) that occurs in the second equation.

If you have a sequence of equations EQs and a sequence of initial conditions ICs, then a plot of V vs. t can be obtained by simply:

sol:= dsolve({EQs, ICs}, numeric);
plots:-odeplot(sol, [t, V(t)], t= 0..2);

where you can change 0..2 to any range that you want.

The fact that the equations are nonlinear is irrelevant; the commands and the numeric solution techniques are the same regardless.

First 159 160 161 162 163 164 165 Last Page 161 of 395