Carl Love

Carl Love

28085 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Here is another method, which combines the good features of nm's and Kitonum's Answers:

eq:= a %* (2*A + 2*B) + b %* C = c %* (2*A + B) + d %* (B*2) + e %* (C + 4*B);

Like nm's solution, this is part of an integrated network of commands and operators specifically designed for working with inert expressions. Like Kitonum's solution, this targets the exact parts of the expression that you want to be inert, and it can be applied before any automatic simplifications have already "ruined" the form that you want (that doesn't happen for this example, but it will for others).

The value command can be used to remove the inertness (or any inertness that is achieved by prefixing symbols with %).

Unlike your mixing-tank problem, the symbolics of this problem have been fully specified. You just need to enter the equations, use dsolve, then solve, then plot. Doing so doesn't require the slightest bit of understanding of Newton's law of cooling. The entirety of the law is expressed in the differential equation given in the problem: The rate of change of temperature (i.e., the deriavtive T'(t)) is proportional to (i.e., equals a constant k multiplied by) the difference in temperature between an object (T(t)) and its surroundings (A(t)).

To determine the equilibrium solutions, i.e., when y'=0, replace diff(y(t), t) with 0 in the differential equation, and solve the remaining equation algebraically (i.e., not as a differential equation) for y(t). In this case, it'll simply be a quadratic equation:

solve(subs(diff(y(t),t)= 0, LG), y(t))

It doesn't matter whether you do this before or after setting numeric values for aYc, and H.

The values that you find will correspond to places where the solution curve is horizontal, or constant.

I assume that when you say "solve for x", you mean solve f(x,y)=0 for x. Here's an example with a simple function. However, fsolve can give a variety of non-answers, and you may need to decide how to deal with these. These non-answers become much more likely as f becomes more complicated. My simple example has none of these non-answers.

f:= (x,y)-> sin(x)-y:
f_inv:= proc(y::numeric) local x; try fsolve(f(x,y), x) catch: FAIL end try end proc:
Y:= <seq(-1..1, 0.01)>:
f_inv_Y:= f_inv~(Y):
#Check for the possible presence of non-answers:
type(f_inv_Y, 'Vector'(numeric));
                              true
#No non-answers found.
plot(<Y | f_inv_Y>);

Also depending on the complexity of f, you may wish to put a timelimit on each individual fsolve and return the non-answer FAIL if the time is exceeded for a particular y. If you need this, I'll be happy to show you how.

I believe that the above will work in Maple 6; I only have a slight skepticism about the seq command. If it doesn't work, it can be adjusted for Maple 6, I'm sure.

Use a table of Records, like this:

Plots:= table([
    P1 = Record(
        "plot"= plot(x, size= [250$2]), 
        "label"= "first-degree function"
    ),
    P2 = Record(
        "plot"= plot(x^2, size= [250$2]),
        "label"= "second-degree function"
    )
]);
Choice:= RandomTools:-Generate(choose({indices(Plots)}))[];
Plots[Choice]:-plot;
Plots[Choice]:-label;

 

If the discard rule is as I stated in my most-recent Reply above, then the following procedure will do it. Its second argument, V, is what you call the category-1 variables. There's no need to specify the category-2 variables since, obviously, any name that isn't a category-1 variable is a category-2 variable.

RemoveUncommomFactors:= (S::{set,list}(algebraic), V::set(name))->
     map(primpart, S, V)
:
RemoveUncommomFactors({a*x, b*x, c*(x+y)}, {x,y});
                           {x, x + y}

 

 

Hints: The way that you've phrased the question suggests that a is a completely free variable. But this is not true. For any ellipse, a = sqrt(b^2 + c^2). We might as well fix c=1, so b=1 and a=sqrt(2). And we might as well fix the position by saying that the equation is x^2/2 + y^2 = 1, so F1 = (-1,0) and F2 = (1,0).

To get a parameterized solution, replace with convert(Q, rational) in the LinearSolve command. I don't know why this isn't mentioned on the help page.

Look at the piecewise structure with lprint:

lprint(f)

You'll see that the operands of f that you want are the even-numbered ones, plus the final one:

seq(op(k,f), k= 2..nops(f), 2), `if`(nops(f)::odd, op(-1, f), NULL);

Assumptions are usually ignored by solve. Put the inequality together with the equation:

solve({x^2 - x - 2, x > 0}, x)

 

Unfortunately, expand isn't threadsafe. And, you must also make local to be threadsafe. This latter point is a clear-cut case of improperly shared global memory, which is the essence of being non-threadsafe. There's a possibility that simply making local is enough to correct the problem (because perhaps expand for pure polynomials doesn't use global memory). I wouldn't rely on it, but I'd be curious to see your results if your only change is to make local. Please test and report back. Meanwhile, I'll try optimizing that code.

Is there a reason that you put the monomials in lists rather than sets? Sets seems like the natural choice because I don't think that you'd want order to matter when the membership test is done.

Use t= -15. .. 15. For from -7 to 7, display a message such as "invalid t value" on a blank background by using a textplot.

Here's another way that I thought was nifty. Regarding efficiency, I don't know how it compares to the others, but I'd be surprised if it was significantly worse.

F:= proc(
    p::polynom(anything,x),
    x::name, 
    n::depends(And(posint, Not(integer[1..d-1]))), 
    d:= degree(p,x)
)
    Matrix((n-d, n), proc(k) option remember; coeff(p, x, k) end proc@(-`-`))     
end proc
:
P:= randpoly(x);
F(P, x, 10);

 

The job can be done by

remove(evalb, sol)

To use subsindets:

subsindets(sol, And(`=`, satisfies(evalb)), e-> ())

Since I don't recommend applyrule, someone else will need to show that.

The most commonly used definition for the "length", "magnitude", or "norm" of a finite-dimensional vector is the Euclidean norm---the one that you show. However, there are other possibilties that are useful for various mathematical purposes, such as the measurement of error in a calculation. For any p >= 1, the p-norm of v is sum(abs(v[i])^p, i= 1..n)^(1/p). So the Euclidean norm is the 2-norm, and this can be returned from LinearAlgebra by Norm(v, 2) or Norm(v, Euclidean). Taking the limit as --> infinity gives the element of maximal absolute value. This is called the infinity-norm. AFAIK, the only commonly used values of p are 12, and infinity. However, all these p-norms generate the same topology. The command Norm will also accept 0 <= p < 1 or p= -infinity. These are not norms in the usual sense of that word, although the computational formula is still defined.

First 84 85 86 87 88 89 90 Last Page 86 of 395