Carl Love

Carl Love

28115 Reputation

25 Badges

13 years, 137 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

There are many things that can be done. Do you want an exact result, or would a decimal result be okay? If a decimal result is okay, use evalf like this:

Ans:= dsolve([sys_ode, ics]);
evalf(Ans);

If you want to maintain the exactness of the result, do

simplify(expand(Ans), size);

These approaches can be combined in any order, but note that conversion to decimal form is essentially a one-way operation:

evalf(simplify(expand(Ans), size));

In the future, please post your code as an attached worksheet rather than an attached picture. That way we can work with it. Also do this if you want more help on this problem.

Use applyrule like this,

rule:= abs(''a''::algebraic)*abs(1,''a''::algebraic)= ''a'':

(Note that those quotes are double single quotes, not single double quotes.) Example of use:

ex:= sin(x)*abs(sin(y))*abs(1,sin(y)):
applyrule(rule, ex);

Your simplify with side relations didn't work because that only works with polynomial relations.

int(t-> N(i, n, t, T)*N(j, n, t, T), 0..1, numeric):

If Phi is your matrix, then do

subsindets(
     plots:-sparsematrixplot(Phi, 'matrixview'),
     specfunc(AXESTICKS),
     subsindets,
     list,
     L-> `if`(L::list(`=`), [seq(lhs(E) = Eq||(rhs(E)), E= L)], L =~ [q||(L[])])
);

This'll produce decent results even if the matrix is large. If you try to explicitly set the tickmarks (as in Kitonum's solution) for a large matrix, they may be too crowded to view. My solution modifies the tickmarks that are already in the plot rather than creating new tickmarks.

indets(eq, function(identical(t)));

The lhs and rhs are superfluous.

It's fairly straightforward:

f:= cos(2*t/m) + cos(2*(t+5)/m):
plot('maximize'(f), m= 1..10);

It's quite an interesting function! I wouldn't have expected the points of nondifferentiability (one is at m=Pi I believe).

Note that the command plot('maximize(f)', m= 1..10) won't work because that makes it treat f as unassigned.

Yes, it is easy to use a color gradient in a 2D point plot. In the following, assume that

  • XY is a list of pairs of (x,y)-values (each pair itself being a list), 
  • f is a function of two variables that returns your f-value for any point as a floating-point number (force it to floating point with evalf if you need to),
  • Mf is the maximum value of f,
  • mf is the minimum value of f.

Then do

R:= Mf - mf:
plot(`[]`~(XY), style= point, color= [seq(COLOR(HUE, (f(xy[]) - mf)/R), xy= XY)]);

For example, here I take 2^12 random points in [-9,9] x [-9,9] and color them based on the sine of the x-coordinate:

XY:= RandomTools:-Generate(list(list(float(range= -9..9), 2), 2^12)):
plot(`[]`~(XY), style= point, color= [seq(COLOR(HUE, (1+sin(xy[1]))/2), xy= XY)]);

 It is also possible to do a gradient between any two given colors.

Here is the command to create the graph, where and are the vertices of degree 2 that I added.

K:= GraphTheory:-Graph({{1,A},{1,2},{1,4},{1,B},{2,3},{3,4},{2,A},{4,B}, {1,3}}):

Now you can work with the graph object using other commands in the GraphTheory package. For example, you can display it:

GraphTheory:-DrawGraph(K, style= planar);

You can't (safely) use implied multiplication, and you need parentheses for all function calls. So, you need to change your definition of r to

r:= t-> <4*cos(2*t)+4*sin(t), 5*cos(3*t)+4*cos(t),(sin(3*t)+2*sin(t))^2>;

Then your spacecurve command will work.

I have a vague feeling that I may be missing something important in this discussion (especially since I would've expected Acer to come up with this also), but doesn't the following simple code, which uses no unapply and no quotes, do what you want?

G:= [seq(subs(_u= u, theta-> x-> _u*theta*x), u in [v1,v2])];

Many commands (perhaps most) don't automatically map themselves over container objects such as Vectors, lists, and sets. This can often be achieved by appending ~ to the command name, making it into an elementwise command. In your case, this works:

A:= Vector([1, 2, 3]):
solve~(2*A =~ 5+x);

Note also the use of the in =~. See ?elementwise.

 

 

If you're willing to change Matrix itself, you can perform the operation in place, which saves time, memory, and typing:

A[.., 1]:= b;

Matrix, in addition to being a type, is also a procedure. It's the constructor procedure for matrices that you just used. When you use print, it forces the expansion of the name Matrix into its underlying procedure. You'd get the same thing if you'd executed print(Matrix) at the top level (i.e., outside a procedure). The solution to your problem is to simply not use print. A procedure's return value is simply the result of its last executed statement; there's no need to use print to see a procedure's result. Indeed, it is a bad practice to use print in this way. It should only be used to display supplementary information, not the procedure's return value.

Set new initial conditions after the singularity, and plot on the range after the singularity. Then combine the plots. For your case, I set n(14) = 1.1, T(14) = 1.1, then plotted on 14..30. It reaches the next singularity at t = 27.....

To convert a table T into a list in the order implied by its indices, use 

[entries(T, 'indexorder', 'nolist')];

instead of

convert(T, 'list');

Also, the plot and Statistics commands accept lists as well as Vectors. With these changes, your code simplifies to

restart:

Atot:= 0:
PtotFkt:= ii-> ii^2: #Keep function definition outside loop.

for ii from 0 by 0.01 to 2 do
     (Atot, A[ii], t[ii]):= (Atot + 0.01*PtotFkt(ii), Atot, ii)
end do:

#Conversion from tables to lists.
#Reuse names A and t to encourage garbage collection.
(A,t):= [entries]~([A,t], 'indexorder', 'nolist')[]:

plot(t, A, style= point, symbol= asterisk, color= blue);
regress:= Statistics:-PolynomialFit(10, A, t, time);
plot(regress, time= 0..2);

 

First 235 236 237 238 239 240 241 Last Page 237 of 396