Carl Love

Carl Love

28015 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You need to take a limit instead of using direct evaluation. Change the last line from

omega[L]:= 9:  t:= 10:  evalf(U[init]);

to the single command

limit(U[init], omega[L]= omega[G]);

and you will get 0.

Another option is to ?overload igcd so that it will take container objects (sets, lists, vectors, etc.) as arguments.

restart:
~set:= x-> convert(x, set):
local igcd:= overload([
     proc(X::~set, $) option overload; :-igcd(X[]) end proc,
     :-igcd
]):

igcd~([ [12,4], {8,2}, <35|5> ]);
                           [4, 2, 5]

See ?overload , ?coercion , ?updates,Maple17,LocalNames , ?dollar,Procedure (section "End-of-parameters marker $").

I used to be annoyed by exactly the same problem. A workaround that I use now is to get rid of prompts entirely. I do this with the command interface(prompt= ""). I have it in my initialization file.

Another benefit of having no prompt is that when I upload a worksheet to MaplePrimes for display (when that is working (*sigh*)), I have an extra two characters per line to work with before MaplePrimes adds a line break (which wreaks havoc with indented code).

@JohnS Picking up where your code left off:

The variables that appear in the solution in the form a = a are the basic (B) variables. The other variables (nonbasic (NB)) are either constant or assigned linear expressions in terms of the basic variables. The first statement separates out the trivial equations of the form a = a.

B,NB:= selectremove(evalb, Sol):

The next statement simply extracts the variables from those trivial equations.

B:= op~(B):
Zs:= [z||(1..3)]:

Now iterate through the basic variables, setting each to 1 and all the others to 0. Call this set of evaluations E. Then evaluate the nonbasic assignments using E. Finally, evaluate the Zs using E plus the evaluated nonbasic assignments.

[seq(
     (E-> eval(Zs, eval(NB, E) union E))({v= 1} union (B minus {v} =~ 0)),
     v in B
)];

So, each sublist above is [z1,z2,z3] evaluated at a particular basic solution.

From a*r^n = b, you get r = (b/a)^(1/n). We can do the problem with symbolic a, b, and n. You can substitute a=3 and b=5 if you want, but n must remain symbolic. If n is not symbolic, then you can't take the limit as n -> infinity. This may be where you went wrong, but it shouldn't have frozen your computer.

restart:
interface(showassumed=0):
assume(a>0, b>0, n::posint):
f:= x-> x^3:
r:= (b/a)^(1/n):

The kth subinterval goes from a*r^(k-1) to a*r^k as k goes from 1 to n.

A:= sum(f(a*r^k)*(a*r^k - a*r^(k-1)), k= 1..n);

limit(A, n= infinity);

Expanding upon nm's Answer, in order for the loop to end, there needs to be a change to p1 or q1 inside the loop. The expression p1-q1 computes something, but doesn't save it; it doesn't change anything. To change p1 or q1, you need an assignment statement p1:= ... or q1:= .... Like this:

GCD:= proc(p::posint, q::posint)
local p1:= p, q1:= q;
     while p1<>q1 do
          if q1 < p1 then  p1:= p1-q1  else  q1:= q1-p1  end if
     end do
end proc:

 

Change

unapply(g,x);

to

g:= unapply(g,x);

Here is how to make your program much faster. This will also work for values of theta and phi other than 0. I got most plots in about 10 seconds.

The first step is change Digits from 25 to 5. Next, remove the initialization of theta and phi. These will be given values immediately before each plot. In each line with a sum or add, make these three changes:

  1. remove the evalf,
  2. Change the sum or add to Sum (capital S),
  3. Change the upper limit of summation from 50 or 100 to infinity.

In the loop that starts for k from 2 to 5 do change k to kk. Change all occurences of k in the loop!

 

sys:= diff(y(t),t) + diff(z(t),t) = t,
 diff(y(t),t) - 2*diff(z(t),t) = t^2:
ic:= y(0)=1, z(0)=2:
dsolve({sys,ic});

Here are the details of the process that I outlined above. Sorry about the formatting. The uploading of worksheets for display is broken. But you can download the worksheet below.

restart:
f:= x-> (6+6*x^2-x^3)/(1+x^4);
               2     3
     6 + 6 x  - x
x -> -------------
                4    
        1 + x     
d:= simplify(D(f)(x));
                 /   5         4        2              \
               x \x  - 12 x  - 24 x  - 3 x + 12/
               ---------------------------------
                                     2            
                           /  4     \             
                           \x  + 1/

Note that the denominator is always positive. So the sign is determined strictly by the numerator.  Since the numerator is a polynomial, I extract it because fsolve will give all the real roots of a polynomial.

R:= fsolve(numer(d), x);
  -0.685015447205253, 0., 0.601983907155496, 12.1633393136672

Now I plug in a sample point in each of the intervals determined by these roots. All that matters is whether the answer is positive or negative.


D(f)(-1.);
                        5.50000000000000
D(f)(-.5);
                       -2.97577854671281
D(f)(.5);
                        1.67474048442907
D(f)(1.);
                       -6.50000000000000
D(f)(13.);
                       0.0003900695534267


So, the function is increasing on the intervals (-infinity, -0.685), (0, 0.602), and (12.2, +infinity)

derivative.mw

You have this line in your code:

dRoutside := (x,l) -> (rhs(Soutside(x)[3])*x-(rhs(Soutside(x)[2]))(1+l))/(x^(2+l));

It should be:

dRoutside := (x,l) -> (rhs(Soutside(x)[3])*x-(rhs(Soutside(x)[2]))*(1+l))/(x^(2+l));

So, yes, the formula which you derived by the chain rule was wrong.

If you add the multiplication sign, then all the plots match up as far as can be determined with the naked eye.

To convert from the string form back to the Matrix form, we need to know the dimensions of the Matrix because this information is not encoded in the string.

So, given that you know that you want a 4x11 Matrix, and that b is the string form, do this:

a:= Matrix(4, 11, (i,j)-> parse(b[(i-1)*11+j]));

Maple does evaluate the integrals: It says that the answer is undefined, and that is the correct answer. (In your post, you incorrectly use eval on the integrals. But you have the correct evalf in your attached worksheet.) The plots in your worksheet clearly show that the limits are oscillatory, hence undefined.

If Maple could not the evaluate the integrals, then it would've returned the integrals unevaluated.

 

See ?combinat,randcomb .

Enter the sum like this

Sum((k^2+k-1)/(k+2)!, k= 1..infinity);
value(%);

You should get the answer 1/2.

I don't understand your integral. Clearly it diverges if taken literally:

assume(A>0);
Int(X/(X-A)*(X-1), X= 0..infinity) ;
or
Int(X/(X-A)/(X-1), X= 0..infinity) ;

Either way it diverges. So, could you write it more clearly?

 

First 335 336 337 338 339 340 341 Last Page 337 of 394