Carl Love

Carl Love

28095 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

I'm just expanding on Axel's Answer here.

Unless you're doing textbook problems in Calculus I or II, I'd avoid using Student:-Calculus1:-Rule. The more general command is IntegrationTools:-Parts.

What's wrong with the output as it's presented by default?

restart:
Eq1 := f(x,g(x,t)) + f(x,y):
diff(Eq1, x);

If you don't like the Ds, then do

convert(%, diff);

First, the f as you've shown it is a table, not a list. It needs to be a list or 1-D rtable (Vector or Array) to sort it. (Kitonum's Answer gets around this issue by tacitly converting the table to a list with seq.) To make it a list, define it as

f:= [[1,3,2], [2,1,3], [1,2,3], [2,3,1], [3,2,1], [3,1,2]]:

Now, you can simply do

sort(f);

This fulfills the requirements that you specified. However, if the lists have different lengths, then the default sort places priority on length over content. I don't like that. I'd like something akin to an alphabetic sort. For that you need a custom sort procedure, like this:

Sort:= proc(A::list, B::list)
local k, nA:= nops(A), nB:= nops(B);
     for k to min(nA,nB) do
          if A[k] <> B[k] then return A[k] < B[k] end if
     end do;
     nA < nB
end proc:

Then do

sort(f, Sort);

 

You have a syntax problem---the absence of multiplication operators. After correcting that, assuming that some of the constants are positive will help Maple to finish the integral.

The first problem: The coefficients C__2 and C__4 need to be followed by the multiplication operator *. So, your function becomes:

C__p:= T -> C__1 + C__2*(C__3/(T*sinh(C__3/T)))^2 + C__4*(C__5/(T*cosh(C__5/T)))^2;

The second problem can be resolved by including an assuming clause:

int(C__p(T), T= T__ref..T__sys)
     assuming T__ref > 0, T__sys > T__ref, C__3 > 0, C__5 > 0;

The output is lengthy, and you may never be able to get it simplified to the form that you suggested. But you may be able to get Maple to show that the two forms are equivalent. If that's what you want to do, let me know.

What you're doing wrong is very simple: Your Y data in the Excel file is on a percentage scale (0  to 100), but your model function is on a 0 to 1 scale. If you divide every value by 100, you'll get a near-perfect fit. You can divide it all by 100 with

Y:= Y /~ 100:

This is the fit that I got with DirectSearch:-DataFit:

[a = .522164088988118, m1 = 22.7042491482519, m2 = 9.51958388629120, s1 = 6.47780713862839, s2 = 3.34678806698068]

Here's my worksheet:

Download data_fit.mw

 (The MaplePrimes editor won't let me display this worksheet inline for some reason.)

Note that I included parameter constraints. This is not possible with Statistics:-Fit. The constraints that I used were

Constraints:= [a >= 0, a <= 1, m1 >= 0, s1 >= 0, m2 >= 0, s2 >= 0, m1 <= 60, m2 <= 60]:

Here's my final plot: The upper red line is the fitted function, the green points are the data, and the lower red line is the derivative of the fitted function, which explicitly shows the bimodality.

Try this:

Statistics:-ColumnGraph(y, datasetlabels= convert(x, list));

A histogram is something completely different: Although it may superficially appear similar to a column graph, it can only be applied to a single set of data. In Maple, a BarChart is just like a ColumnGraph with the columns being horizontal.

See the help page ?plots,complexplot3d.

The following simple command will unassign all your variables. It won't remove assumptions on variables because assumptions aren't assignments:

unassign~(<anames(user)>):

I'm Answering Question 1 with a single expression:

plot(arctan(2*tan(x))+Pi*ceil((x-Pi/2)/Pi), x= -10..10);

 

The following code will make a 4x4 array of labelled 3-D plots (rows indexed by T[g], columns by k) of the real parts of the function:

restart:
nu:= -delta/2*sqrt(T[0]-4*T[g]);
x:= -T[g]/T[0]^2*gamma*G*delta*sqrt(alpha*k)/p;
F:= p^(1+delta*T[0]/2)*(C[1]*BesselJ(nu,x)+C[2]*BesselY(nu,x));

(please check that my edit of your function is correct.)

params:= [delta = 0.2e-2, G = .2, gamma = .2, alpha = 5.36, C[1] = 500, C[2] = 100]:
Fe:= eval(F, params):
Tg:= [1.1, .615, .48, .2962]:  K:= [1.2, 1.3, 1.4, 1.5]:
P:= [.22, .23, .24, .25]:  T0:= [3.666667, 2.307692, 1.714286, 1.377778]:
plots:-display(
     Matrix(
          (4,4),
          (i,j)-> plot3d(
               Re(eval(Fe, [T[g]= Tg[i], k= K[j]])),
               p= min(P)..max(P), T[0]= min(T0)..max(T0),
               caption= sprintf("T[g]=%a, k=%a", Tg[i], K[j])
          )
     ), axes= normal, transparency= .15
);

Use partial fractions:

e1:= convert(cot(x), confrac, x, 6):
convert(e1, parfrac, x);

By the way, your original form is called a continuED fraction, not a continuOUS fraction. I edited this in your Question.

You asked:

And how do I find the values of m1, s1, m2, s2 and a?

Instead of Fit(...) use Fit(..., output= parametervalues).

As far as I can tell, there is no predefined command for this in the ListTools package, although it is closely related to ListTools:-Split. That command can't look at both a list element and its next element at the same time, which is what your application requires. So, here's a procedure for it:

SplitScan:= proc(f, L::list)
local R:= Vector(), k:= 0, j, last:= 1;
     for j from 2 to nops(L) do
          if f(L[j-1], L[j], _rest) then
               k:= k+1;
               R(k):= L[last..j-1];
               last:= j
          end if
     end do;
     [seq(k, k= R), L[last..]]
end proc:

Its use:

SplitScan(`<>`, ca); #Split where element <> previous element.

For example,

y[0]:= -38:
for k to 9 do  y[k]:= evalf([solve(x^2 = y[k-1])][1]) end do;

I wasn't aware that the word "to" as you use it above was valid Matlab syntax. I thought it should be a colon. Regardless, your intended meaning is clear.  In Maple:

Hy:= Vector(M);
Ex:= Vector(M+1);
for t from 1 to T do
    Ex[1]:= evalf(exp(-t));  #Don't you mean Ex[t]???
     for k from 1 to M do
          Hy[k]:= Hy[k] - (Ex[k+1] - Ex[k])
     end do;
     for k from 2 to M do
          Ex[k]:= Ex[k] - (Hy[k] - Hy[k-1])
     end do
end do;

I've translated exactly what you wrote. I haven't tried to correct any logic errors.

First 252 253 254 255 256 257 258 Last Page 254 of 395