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

Any map R^2 -> R^2 can be viewed as a map C -> C and thus plotted with plots:-conformal. It is irrelevant that the complex map is neither conformal nor analytic; the plot command doesn't care.

restart:
#Convert any map R^2->R^2 to the equivalent C->C:
ToComplex:= Z-> unapply(inner([Z((Re,Im)(_z))],[1,I]), _z):
Z:= ToComplex((r,t)-> (r*exp(t), r*exp(-t)));
plots:-conformal(Z, 0..1+I, labels= [r,t], grid= [13,13], numxy= [51,51]);

Regarding linspace: It is now not needed because its purpose is handled by the grid option. However, it is a generally useful command from Matlab. It can be implemented in Maple by

linspace:= proc(a,b,n::And(posint, Not(1)))
local k, h:= (b-a)/(n-1);
   seq(a+k*h, k= 0..n-1)
end proc:

A more Mapleish implementation uses ranges:

linspace:= proc(ab::range(algebraic), n::And(posint, Not(1)))
local k, a:= op(1,ab), h:= (op(2,ab)-a)/(n-1);
   seq(a+k*h, k= 0..n-1)
end proc:

So it can be called via

linspace(0..1, 11);

It is possible to solve your system symbolically and obtain 7 explicit solutions for p, v, and w in terms of t that are not terribly complicated:

restart:
eq1:= 3*v^2-v*t*(v^2+3)-3*w^2+w*t*(w^2+3)=0:
eq2:= v*(p*v^2+3)/(3*v^2+1)-w*(p*w^2+3)/(3*w^2+1) = 0:
eq3:= -v*(p*v^2+3)/(3*v^2+1)-w*(p*w^2+3)/(3*w^2+1) = 0:
_EnvExplicit:= true:
Sols:= [eliminate({eq1,eq2,eq3},{p,v,w})]:
simplify(Sols);

 

Use a parametric plot3d for the plane:

plot3d([u,u,v], u= 0..0.01, v= 0..100, transparency= .8);

Here's another example. As Preben noted, the key point is to include the output= Array(...) option to dsolve, where the array contains the independent-variable values. In this example, I FFT the famous Lorenz Attractor.

restart:
N:= 12: #Use 2^N t-values.
(Tmin,Tmax):= (0,20):
xyz0:= [1,1,1]:
sys:= {
   diff(x(t),t) = sigma*(y(t) - x(t)),
   diff(y(t),t) = x(t)*(rho - z(t)) - y(t),
   diff(z(t),t) = x(t)*y(t) - beta*z(t),
   ([x,y,z](Tmin) =~ xyz0)[]
}:
params:= [sigma= 10, rho= 28, beta= 8/3]:
h:= (Tmax-Tmin)/(2^N-1):
T:= Array(1..2^N, k-> Tmin + h*(k-1)):
Sol:= dsolve(eval(sys, params), numeric, maxfun= 0, output= T);
plots:-odeplot(Sol, [x,y,z](t));
#When you modify this example for your system, do NOT change ANY of the numbers 
#in the next line.
XYZ:= DiscreteTransforms:-FourierTransform(Sol[2,1][.., 2..], 1); 
for P in [Re,Im] do
   print(plots:-pointplot3d(P~(XYZ), style= line))
od;

 

Yes, to solve systems of polynomial equations/inequalities over the reals, you should use RegularChains, not Groebner. The RegularChains package is massive, perhaps the largest in Maple, but you probably don't need to access it directly. There are several user-friendly access points from outside the package. I think that the most appropriate in your case is SolveTools:-SemiAlgebraic.

Please post your system of equations/inequalities using plaintext Maple code, not MathJax. I would've tried solving your system, but I don't fully understand it.

To differentiate with respect to a function (such as another derivative), use Physics:-diff:

y:= diff(tau(t), t)^2:
Physics:-diff(y, diff(tau(t),t));

 

FirstHit:= proc(L::{Array,list}(float), C::realcons)
local c:= evalf(C), k;
   for k to numelems(L) do
      if L[k] > c then return k fi
   od;
   FAIL
end proc:

 

What you have written is a fine answer for part b of the problem, not part a. To answer part a, simply change plot to line in your Tangent command.

The animation has two parts: the part that changes with each frame (the tangent line) and the part that doesn't (the function's plot). The part that doesn't change is in the background option below:

f:= x-> 2/(1+exp(-x)):
plots:-animate(
   plot,
   [
       Student:-Calculus1:-Tangent(f(x), x= x0, output= line),
       x= -6..6,
       color= "DarkGreen", thickness= 3
   ],
   x0= -5..5,
   background= plot(f, -6..6, thickness= 3)
); 

To play the animation, you need to click on it and start it with the toolbar controls or the context menu.

The problem is due to solve, specifically SolveTools:-Inequality:-Piecewise, being unable to deal with assumptions. To get around this automatically, we can freeze any underscore variables, call solve, and then thaw the result. In this example, I'll assume that sys is a set of equations/inequaities that possibly contains trouble-making automatically generated variable with assumptions.

expand(thaw(solve(subsindets(sys, suffixed(_), freeze@``) ,{x})))

Runge-Kutta-Fehlberg is Maple's default numeric method for initial value problems (IVPs) when you use command dsolve(..., numeric). So, there's no need for you to do any loops or explicit computation. Also, you don't need to convert higher-than-first-order ODEs to first-order systems; that's done automatically.

If you present your ODEs in their original form, your initial conditions, and your parameter values, I will show you how to enter them into dsolve. Hopefully you have some initial conditions that are not all zeros. Otherwise, the solution will just be the zero function.

I think that this solution is more specific than Mehdi's (because it targets only xs with numeric indices) and less convoluted than VV's (because it doesn't involve the intermediate step of replacement with _XX(...)):

remove(hastype, A, x['numeric']);

where A is any list or set of expressions. That seems somewhat intuitive. The quotes aren't necessary. They're there to guard against the possibility that the quoted item has been assigned a value.

Here is some code. The first three lines are a correction of the code that you already wrote. The fourth line makes a point plot. Since the fibonacci numbers are very close to an exponential function, a logarithmic plot is also a good option. So, my fifth line makes a logarithmic point plot.

restart;
nums:= [seq(i, i= 1..20)];
fibnums:= combinat:-fibonacci~(nums);
plot(`[]`~(nums, fibnums), style= point, symbol= solidcircle);
plot(`[]`~(nums, fibnums), style= point, symbol= solidcircle, axis[2]= [mode= log]);

 

I will assume that by a[123], etc., you mean a[1,2,3], etc. Then this procedure does it:

UsmanSum:= proc(n)
local 
   i,j,k,
   S:= Sum(Product(E[k], k in j)*a[j[k] $ k in j], j subset {$1..n})
;
   if not n::nonnegint then 
      S
   else
      S = 
      add(add(mul(E[k], k= j)*a[j[]], j= combinat:-choose(n,i)), i= 2..n) +
      add(E[i], i= 1..n) +
      1
   fi
end proc:

For example:

UsmanSum(4);

Or

UsmanSum(n);

will display the summation notation for symbolic n,

You need to place some Maple commands in an initialization file. I have some help about that below.

The commands plots:-setoptions and plots:-setoptions3d can be used to set options that will be used by default for all 2D and 3D plot commands, respectively. So, put commands such as these in your initialization file:

plots:-setoptions(labelfont= [TIMES,32], axesfont= [TIMES,16], titlefont= [TIMES,32], captionfont= [TIMES,32]):
plots:-setoptions3d(
ditto ):

I haven't included every possibility for a font option above. The options will become defaults, meaning that can be overridden by direct inclusion of the same option with a different value in the plot command.

A Maple initialization file is a file of plaintext commands (entered just as you would enter them in a worksheet). The commands are executed every time that you do a restart, just as if you'd typed them in directly or used the read command. The name of  the file is operating-system dependent; details about the file's name can be found at ?worksheet,reference,initialization.

Unfortunately I don't see that the help page mentions this explicitly, but patmatch simply doesn't work on equations. It says that it works on type algebraic; equations are not that type. I don't know why it doesn't simply return an error message if you try to pass a non-algebraic in the first argument.

Your example could be handled by typematch or match.

The matching commands that I know of are (listed in order of complexity): typematch,, match, patmatch, applyrule, and define. As you move through that list, the commands get more and more fussy.

First 168 169 170 171 172 173 174 Last Page 170 of 395