Carl Love

Carl Love

28085 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

The command evalm has no use in modern Maple. It is causing your problem. Simply remove it.

I recall myself and others showing you the copy command with respect to records a few weeks ago, and also discussing last name evaluation. The two concepts are related in a somewhat coincidental way: All structures that use last name evaluation also require copy. One of the uses of eval is to get past the last name to the actual structure. But eval is not a substitute for copy.

1. Do both the integral and the simplification with assuming a > 0. The eval is unnecessary.

2. Include the option allsolutions to solve. The z assuming complex is unnecessary.

What you want to display can be displayed by

`q*`(z) = piecewise(2/3 < z and z <= 1, 0, 1/3 < z and z <= 2/3, 1, 0 <= z and z <= 1/3, 2);

Of course, you can arrange it so that the values in the expression are filled in programmatically.

You could define an operator for double factorial:

`&!`:= x-> doublefactorial(x);

Then use it as, for example,

5&!2;

The 2 could be anything. It's simply there because a second argument is required.

Radicals aren't considered functions, and even sqrt gets converted to a form with an exponent, either 1/2 or -1/2. Try

hasradical:= e-> hastype(e, 'anything'^'fraction')

This is your third consecutive Question where the answer has been, essentially, "use unapply rather than ->" How can we improve your learning of this?

Yes, the dimension is the number of equations of the form variable=variable in (one branch of) solve's output. It is trivial to count these. If we have

Soln:= [solve(...)];

then

Dims:= (S::set(`=`))-> nops(select(evalb, S));
Dims~(Soln);

returns the dimensionality of each corresponding solution branch. This only handles branches that are sets of equations, which is the most-common case, but solve can return inequalities and piecewise expressions also.

Here is a procedure for it:

Conditioned:= proc(
   event::{relation, set(relation)},
   cond::{relation, set(relation)}, 
   RV::name= RandomVariable &under Statistics:-RandomVariable
) 
uses St= Statistics;
local 
   Event:= `if`(event::relation, {event}, event),
   Cond:= `if`(cond::relation, {cond}, event)
;
   if nargs=3 then 
      (Event,Cond):= subs(lhs(RV)= St:-RandomVariable(rhs(RV)), [Event, Cond])[]
   fi;
   #union used rather than intersection because Probability considers a set
   #of relations to represent the intersection of the corresponding events. 
   St:-Probability(Event union Cond)/St:-Probability(Cond)
end proc:

The procedure can be used like this:

Conditioned(X^2 > 12, X > 2, X= Poisson(2));

or like this:

Y:= Statistics:-RandomVariable(Poisson(2)):
Conditioned(Y^2 > 12, Y > 2);

 

Try command eliminate instead of solve. In cases where solve returns nothing, eliminate returns partial solutions and residual equations. Pay particular attention to the number of these residual equations.

You can get the matrix from Excel to Maple by

M:= ExcelTools:-Import(...);

You can plot that matrix directly (converting to ordered triples not necessary) by

Statistics:-ScatterPlot3D(M, lowess, ...);

See help pages ?ExcelTools,Import and ?Statistics,ScatterPlot3D. In particular, ScatterPlot3D has many options for refining the plot.

The reason why it doesn't work is explained in detail in the 5th paragraph of Description at ?patmatch. In particular, it says at the very end of that paragraph that the condition can't use <>. So, if I wanted to use a conditional clause to do what you want, I'd do

MyPat1:= (e, la::name)->
   patmatch(
      e, 
      conditional(
         a::anything*x^b::anything,
         _type(a, Not(identical(y))) and _type(b, Not(identical(y)))
      ),
      `if`(nargs > 1, la, NULL)
   )
:

However, it's just easier to avoid the conditional altogether, this way:

MyPat2:= (e, la::name)-> 
   patmatch(
      e, 
      a::Not(identical(y))*x^b::Not(identical(y)), 
      `if`(nargs > 1, la, NULL)
   )
:

In addition to the knowledge about conditional, you should learn from this Answer that there is a type identical and that the negation of any type T is also a type, Not(T).

Your interpretation of the problem is correct. However, I object to the wording of the problem. A sphere is a surface, not a volume. The correct word for the 3-D region enveloped by a sphere is ball.

To avoid repetition in your calculation, which increases the risk of mistyping something, I'd arrange it like this:

f:= (x, y, z)-> (x^2 + y^2 + z^2)^2:
Spherical:= [x,y,z]=~ rho*~[sin(phi)*cos(theta), sin(phi)*sin(theta), cos(phi)];
V:= [rho= 0..r, theta= 0..2*Pi, phi= 0..Pi]:
(M, d):= VectorCalculus:-Jacobian(rhs~(Spherical), lhs~(V), 'determinant'):
d:= simplify(abs(d));
J:= Int(eval(f(x,y,z), Spherical)*d, V);
soln:= value(J);

 

You can call solve using keyword explicit as the third argument. Or you can use command allvalues to convert RootOfs after they are generated.

Your definition for G needs multiplication signs, just like you have in your definition for M.

First 170 171 172 173 174 175 176 Last Page 172 of 395