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

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.

Most of the information that you need to understand this can be found at ?rtable_eval. You may need to read that page slowly and carefully 10 to 20 times (like I did) to understand it. Also read the seventh and twelfth paragraphs of Description at ?eval. What you also need to know to understand this:

  • Most expressions fully evaluate when used at the command line (in any GUI).
  • Most expressions evaluate to only one level (equivalent to eval(..., 1)) when they're used in a procedure.
  • rtables never evaluate unless that's forced with a specific evaluation command.

To avoid obfuscation, first understand what is happening without the list conversion. To answer your Question about intention: yes, this behavior (before list conversion) is certainly intended. Whether the behavior after the list conversion is intended or correct or should be considered a bug: I don't know---it's a very fine judgement call. Certainly that behavior can be removed by adding an eval to `convert/list`.

A few examples:

 

restart:

A:= <a>:
a:= 1:

A;

Vector(1, {(1) = a})

rtable_eval(A);

Vector(1, {(1) = 1})

A;

Vector(1, {(1) = a})

rtable_eval(A, inplace);

Vector(1, {(1) = 1})

A;

Vector(1, {(1) = 1})

Procedure CL1 is an abbreviated version of how convert(..., list) actually works when applied to a Vector (see line 15 of showstat(`convert/list`)). Procedure CL2 is an alternative version that unintentionally applies another level of evaluation. I really can't say which is better. Procedure CL3 is a very slight variation of CL2 that shows that round-bracket indexing doesn't evaluate the entry whereas square-bracket indexing does. Procedures CL4 and CL5 show that the results of CL3 and CL2 (respectively) remain the same if the indexing type (round bracket or square bracket) is expressed in prefix form.

CL1:= proc(A) local i; [seq(i, i= A)] end proc:

CL2:= proc(A) local i; [seq(A[i], i= 1..numelems(A))] end proc:

CL3:= proc(A) local i; [seq(A(i), i= 1..numelems(A))] end proc:

CL4:= proc(A) local i; [seq(`?()`(A, [i]), i= 1..numelems(A))] end proc:

CL5:= proc(A) local i; [seq(`?[]`(A, [i]), i= 1..numelems(A))] end proc:

B:= <b>:
b:= 2:

CL1(B);

[b]

CL2(B);

[2]

CL3(B);

[b]

CL4(B);

[b]

CL5(B);

[2]

``

 

Download rtable_eval.mw

But I still don't understand this: What is the difference between rtable_eval(A, inplace) and map[inplace](eval, A)?

 

You're probabaly better off using LinearAlgebra:-LinearSolve as in Preben's Answer, but this is possible using solve as in your Question. But your multiply is meaningless, and solve deals with sets or lists of algebraic expressions or equations but not with matrices. However, converting between the forms is straightforward. Additionally, your construction of the matrices could be simplified. This works:

restart:
A1:= Matrix((3,3), symbol= a);
A2:= <A, B, C>;
A3:= <15, 0, 0>;
solve(convert(A1.A2 - A3, set), {A,B,C});

(Of course, this solution is only valid when the determinant is nonzero.)

You don't show the results of your second attempt. When I do it (in Maple 18), I get your desired result:

restart:
sol:= solve(combine(sin(x)^2)=1/4, x, AllSolutions);

     sol := -(1/3)*Pi*_B1+(1/6)*Pi+Pi*_Z1

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