Carl Love

Carl Love

28070 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

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);

 

In the future, please use plaintext for your posted Maple code, or upload a worksheet. Then we won't need to retype your commands.

The solve your problem, go to the Maple Application Center and download the package DirectSearch. The worksheet below shows how to use it. You can see that the package stumbles around a bit before coming up with a solution, but the solution that it finally produces is accurate.

 

restart:

Digits:= 15:

T[l]:= 20:

C[p]:= 3779:

rho:= 1026:

nu:= 0.004/60:

P:= 1000:

lign1:= H = 40.09 + 14.774*ln(T[i]-T[l])+(2.28+0.338*ln(T[i]-T[l]))*T[l];

H = 85.69+21.534*ln(T[i]-20)

lign2:= H = -nu*rho*C[p]*ln(1-(T[i]-T[r])/(T[i]-T[l]));

H = -258.483600000000*ln(1-(T[i]-T[r])/(T[i]-20))

lign3:= P = nu*rho*C[p]*(T[i]-T[r]);

1000 = 258.483600000000*T[i]-258.483600000000*T[r]

Two failed attempts to solve it:

solve({lign||(1..3)}, {T[i], T[r], H});

Warning, solutions may have been lost

fsolve({lign||(1..3)}, {T[i], T[r], H});

fsolve({1000 = 258.483600000000*T[i]-258.483600000000*T[r], H = -258.483600000000*ln(1-(T[i]-T[r])/(T[i]-20)), H = 85.69+21.534*ln(T[i]-20)}, {H, T[i], T[r]})

Sol:= DirectSearch:-SolveEquations([lign||(1..3)]);

Warning, objective function returns unfeasible value 1017419.58204931+20066.4653263053*I for initial point [H = .900000000000000, T[i] = .900000000000000, T[r] = .900000000000000]; trying to find a feasible initial point

Warning, the new feasible initial point is [H = -.124468522829816, T[i] = 27.0904567017001, T[r] = 44.6637687621344]

Warning, complex or non-numeric value encountered; trying to find a feasible point

Sol := [2.12535788608859*10^(-22), Vector(3, {(1) = 0.4057199021e-11, (2) = 0.5826450433e-11, (3) = -0.1273292582e-10}), [H = 134.278515805142, T[i] = 29.5482965427669, T[r] = 25.6795791463827], 609]

Sol[3];

[H = HFloat(134.27851580514186), T[i] = HFloat(29.54829654276689), T[r] = HFloat(25.6795791463827)]

 

 

Download Temp_Power.mw

Why not simply use solve:

solve((z^2-1)/(z^2+1) = c, z);

Simple: Use a local declaration:

lisse:= proc(...)
local AzIII;

...
end proc:

It's not built-in (AFAIK), but it can be written as a trivial one-liner. However, you do need to specify the maximum number of bits to allow for the numerator.

`convert/dyadic`:= (x::nonnegative, b::posint)-> ``(trunc(x))+round(2^b*frac(x))/2^b:

convert(1.74, dyadic, 5);

     (1)+3/4

convert(1.74, dyadic, 6);

     (1)+47/64

The pochhammers can be converted to summations by following the differentiation command with

convert(%, Sum);

The best simplifier that I've found for explicit algebraic numbers (meaning those specified without RootOf) is evala@evalc. In this case, this combo will quickly reduce ab, and c to a form from which it's obvious that no further simplification is possible. Then I do two independent verifications--one numeric and one symbolic---that these simplifications are correct. The numeric is evalf[10]@evalf[999]; the symbolic is evala@Normal.

 

restart:

a:= -((4*I)*sqrt(3)+4*sqrt(3)-5-7*I)/((4*I)*sqrt(3)+4*sqrt(3)-7-9*I);

 

b:= -((390*I)*sqrt(3)+30*sqrt(3)-52-675*I)/(-3-4*I+2*sqrt(3)+(2*I)*sqrt(3))^3;

 

c:= -(1/2)*sqrt(2-2*I)*((6*I)*sqrt(3)+6*sqrt(3)-11-10*I)*
    (-2+sqrt(3))*sqrt(-2-2*I)*((2*I)*sqrt(3)+2*sqrt(3)-5-2*I)/
    (-3-4*I+2*sqrt(3)+(2*I)*sqrt(3))^3;

 

-((4*I)*3^(1/2)+4*3^(1/2)+(-5-7*I))/((4*I)*3^(1/2)+4*3^(1/2)+(-7-9*I))

-((390*I)*3^(1/2)+30*3^(1/2)+(-52-675*I))/((-3-4*I)+2*3^(1/2)+(2*I)*3^(1/2))^3

-(1/2)*(2-2*I)^(1/2)*((6*I)*3^(1/2)+6*3^(1/2)+(-11-10*I))*(-2+3^(1/2))*(-2-2*I)^(1/2)*((2*I)*3^(1/2)+2*3^(1/2)+(-5-2*I))/((-3-4*I)+2*3^(1/2)+(2*I)*3^(1/2))^3

v:= <a,b,c>:

vs:= (evala@evalc)~(v);

vs := Vector(3, {(1) = (-209/481-(226/481)*I)+(120/481)*sqrt(3)-((128/481)*I)*sqrt(3), (2) = (132/343)*sqrt(3)+(425/343)*I, (3) = (374/343)*sqrt(2)-((75/343)*I)*sqrt(3)*sqrt(2)})

evalf[999](v-vs): evalf(%);

Vector(3, {(1) = 0.1000000000e-998-0.7000000000e-998*I, (2) = 0.1861000000e-995+0.2560000000e-995*I, (3) = 0.1000000000e-997+0.4700000000e-997*I})

(evala@Normal)~(v-vs);

Vector(3, {(1) = 0, (2) = 0, (3) = 0})

Perm(cycles)

``

 

Download evala_evalc.mw

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