mmcdara

7891 Reputation

22 Badges

9 years, 54 days

MaplePrimes Activity


These are answers submitted by mmcdara

you can do this:

restart


As soon as the expression is of type `*` you can do this

f := sqrt(a*(a+b+c))/(a*b+a*c+b*c)

(a*(a+b+c))^(1/2)/(a*b+a*c+b*c)

(1)

g := (a*b+a*c+b*c)*((1/3)*a+(1/3)*b+(1/3)*c)^(1/3)

(a*b+a*c+b*c)*((1/3)*a+(1/3)*b+(1/3)*c)^(1/3)

(2)

map(t -> if patmatch(t, a::anything^n::fraction,'p') then eval(1/n, p) end if, [op(f)])

[2]

(3)

map(t -> if patmatch(t, a::anything^n::fraction,'p') then eval(1/n, p) end if, [op(g)])

[3]

(4)


counter example

map(t -> if patmatch(t, a::anything^n::fraction,'p') then eval(1/n, p) end if, [op(f+g)])

[]

(5)


For more general expession types  `*` you can do this

map(t -> if patmatch(t, a::anything^n::fraction,'p') then eval(1/n, p) end if, indets(f));
map(t -> if patmatch(t, a::anything^n::fraction,'p') then eval(1/n, p) end if, indets(g));
map(t -> if patmatch(t, a::anything^n::fraction,'p') then eval(1/n, p) end if, indets(f+g));

{2}

 

{3}

 

{2, 3}

(6)


What do you expect in this case? 2 or 4 ?

h := f^(1/2);
map(t -> if patmatch(t, a::anything^n::fraction,'p') then eval(1/n, p) end if, indets(h));

((a*(a+b+c))^(1/2)/(a*b+a*c+b*c))^(1/2)

 

{2}

(7)

 

Download patmatch.mw


See the attached file
Pb_alias.mw

Every time you invoke, let's say U(theta), it's enough to write U instead.



If you have 50 regressors (intercept put aside) you have 50elementary effects50*49/2= 1225 order 1 interactions(or 51*50/2 = 1275) if you account for quadratic effets, and more generally a total of (50+d)!/(50!*d)!effects if you limit yourself to complete polynomials of total order d(intercept included).

When you use a stepwise regressionyou specify the minimum model (usually "1" to say that it could be constant) and the maximum one, which has 1326terms with 50regressors (quadratic effects includes), or 23426terms if you also want to account for order 2 interactions (interactions involving 3 regressors) and cubic effects.

If reallyyou want to do that, use a statistical software instead of Matlab, and if you don't want to spend money and look for a World reference, use R.
And go post your questions here https://community.rstudio.com/.

More generally, when you are dealing with a high-dimensional problem (and 50may already be a high dimension depending on what you want to achieve) you face the so-called curse of dimensionality, which is a common term to say tgat you are in deep s..t if you proceed roughly and without methodology.
"Methodology" always means trying to reduce the dimension of the problem, and one approach could be Sensitivity Analysis(SA).

Being capable to solve a high dimension problem, sorry to say that, is what mkes the difference between a statistician and someone who heard about a method (stepwise regression for instance, or PCR or PLS like in some of your previous questions) and do not know their capabilities, limitations, conditions of use, and is ignorant of the statistical methodology.

I can give you two advices: 

  1. start studying books or courses on data analysis, those that are more practical than theoretical and which focus on the methodology and not on particular techniques.
    You can see here https://www.gdr-mascotnum.fr/ to try and find some ideas.
     
  2. After you are familiar with the methodology, go to an forum (see bove) and ask your questions.
    There are also several excellent books onRthat explain how to approach concrete problems.
     

Maple is a general purpose tool. It reaches excellence in some domains and it is weak on some others.
In particular, despite some packages like CurveFitting, DeepLearning and specially Statistics, it cannot compare to R or SPSS to cite a few (which in turn both have almost zero cabilities in computer algebra).
You have an exotic problem to solve? Use the correct tool! 
 


@C_R is right.

But if you seek for a 5-uple which verifies almost exactly the equations you can do this:

J   := add(fa[i]^2, i=1..6):
opt := Optimization:-Minimize(sqrt(J), iterationlimit=100)
Warning, limiting number of major iterations has been reached
[                      -10                                       
[4.10501055530149644 10   , [U[0] = HFloat(7.01309745602936e-5), 

  V[0] = HFloat(-6.489610924321912e-5), 

  W[0] = HFloat(-3.4133357940097986e-4), 

  Z[0] = HFloat(4.557011539226921e-5), 

                                      ]
  r[0] = HFloat(3.536008624037784e-4)]]

# substituting the optimizer within the 6 equations gives almost 0
eval([seq(fa[i], i=1..6)], opt[2]);
[HFloat(1.2696690084905257e-11), HFloat(-2.3564374807767145e-12), 

  HFloat(3.2706322945133913e-12), HFloat(2.5254566668356693e-11), 

  HFloat(-1.8185399678621357e-10), HFloat(3.669127846427833e-10)]


REMARK 1: starting from another point could lead to another minimizer (look to Optimization:-Minimize for more details).

REMARK 2: fa[6]=0 ==> U[0] = V[0] = W[0] = Z[0] = r[0] = 0.
Unfortunately some fa[i] are of the form 0/0... unless these inderminate forms are both equal to some constant.

REMARK 3: assuming r[0] <> 0, then fa[i]=0 ==> numer(fa[i])=0 for each i=1..5,.
More of this each numer(fa[i]) is an homogenous polynomial.
Let P one of these  polynomial and V the sequence of its indeterminates.
Then P(C*V) = Cd*P(V) where d is thetotal degree of P.
This suggests that if  M is a minimizer of J (see the above code), then C*M will be another one:

evalf[3]( eval([seq(fa[i], i=1..6)], (lhs=rhs/100)~(opt[2])) );
[       -15          -16         -16         -15          -14  
[1.26 10   , -2.35 10   , 3.27 10   , 2.53 10   , -1.81 10   , 

         -14]
  3.65 10   ]
evalf[3]( eval([seq(fa[i], i=1..6)], (lhs=rhs/10^10)~(opt[2])) );
[       -31          -32         -32         -31          -30  
[1.26 10   , -2.35 10   , 3.27 10   , 2.53 10   , -1.81 10   , 

         -30]
  3.65 10   ]

So one can infer that U[0] = V[0] = W[0] = Z[0] = r[0] = 0 is indeed the solution provided that limit(U[0]/r[0], r[0]), limit(V[0]/r[0], r[0]),  limit(W[0]/r[0], r[0]), limit(Z[0]/r[0], r[0]) are both equal to some constant. These constants are:

eval([U[0]/r[0], V[0]/r[0], W[0]/r[0], Z[0]/r[0]], opt[2])
  [HFloat(0.19833372035221658), HFloat(-0.18352927309638167), 

    HFloat(-0.9653075421835637), HFloat(0.12887444640967105)]

 


Thera are many ways to fix your code ( @Carl Love already gave you one).
They depend essentially on what you want to do with the solutions you have obtained (the 3 couples (Rm, Xm)).
The attached file presents some of these ways.
Many_ways.mw

But one thing puzzles me: you wrote "I have the numbers of a bode plot (abs and phase) and I want to fit it in an equivalent circuit."
Your equivalent circuit in made of 2 impedances, one real (Rs) with known value  (50) , the other is complex with real part Rm and imaginary part Xm.
Either this second impedance has a value which depends on the frequency, or it has a constant value whatever the frequency.
In the first case it makes sense to computes Rm and Xm for each frequency; but this would no longer make sense in the second case where a real fit (for instance in the least-squares sense) would be more appropriate.


Here is the way to generate the R source file which codes what you wantedto achieve in your toy_try.mw file.
 

restart*with(GraphTheory):

with(ListTools):

G := CycleGraph(7):

E := Edges(G)

{{1, 2}, {1, 7}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}}

(1)

EL     := [convert~(E, list)[]]:
__from := map2(op, 1, EL):
__to   := map2(op, 2, EL):

sprintf(cat(seq("""%d"",", k=1..numelems(__from))), op(__from)):
R_from := cat("From <- c(", %[1..-2], ")");
sprintf(cat(seq("""%d"",", k=1..numelems(__to))), op(__to)):
R_to := cat("To <- c(", %[1..-2], ")");

R_ft := "ft <- cbind(From, To)";
R_gr := "graph1 <- ftM2graphNEL(ft)";

MyRsource := cat(currentdir(), "/graph.R"):

writeline(MyRsource, R_from):
writeline(MyRsource, R_to):
writeline(MyRsource, R_ft):
writeline(MyRsource, R_gr):
fclose(MyRsource)
 

"From <- c("1","1","2","3","4","5","6")"

 

"To <- c("2","7","3","4","5","6","7")"

 

"ft <- cbind(From, To)"

 

"graph1 < -ftM2graphNEL(ft)"

(2)

 

toy_try_mmcdara.mw

This workwheet produces a text file named graph.R located in currentdir().
Assuming you use Rstudio:

  • Open Rstudio.
  • If not already done install package matrix2Graph.
  • Double click on graph.R.
  • Execute the code.
     

In the Rstudio main view the content of graph.R looks like this


PS I didn't run the code for matrix2Graph is not compatible with my R version and because I never use packages that are not in the official R repository https://cran.r-project.org/  (igraph for instance).

 

restart:
A := isolve(n >= 20);
about(_NN1)
                        {n = 20 + _NN1}
Originally _NN1, renamed _NN1~:
  is assumed to be: AndProp(integer,RealRange(0,infinity))

B := isolve(2*k+1 >=0);
about(_NN2)
                           {k = _NN2}
Originally _NN2, renamed _NN2~:
  is assumed to be: AndProp(integer,RealRange(0,infinity))

C := isolve(3*k-1 >=0);
about(_NN3)
                         {k = 1 + _NN3}
Originally _NN3, renamed _NN3~:
  is assumed to be: AndProp(integer,RealRange(0,infinity))

A intersect B intersect C
                               {}
# But :

`A inter B inter C` := isolve({k >= 20, 2*k+1 >= 0, 3*k-1 >= 0});
                        {k = 20 + _NN4}
about(_NN4)
Originally _NN4, renamed _NN4~:
  is assumed to be: AndProp(integer,RealRange(0,infinity))

# A less trivial example


restart:
A := isolve(n >= 20);
about(_NN1)
                        {n = 20 + _NN1}
Originally _NN1, renamed _NN1~:
  is assumed to be: AndProp(integer,RealRange(0,infinity))

B := isolve(2*k+1 <= 40);
about(_NN2)
                        {k = 19 - _NN2}
Originally _NN2, renamed _NN2~:
  is assumed to be: AndProp(integer,RealRange(0,infinity))

C := isolve((3*k-1)/2 >= 12);
about(_NN3)
                         {k = 9 + _NN3}
Originally _NN3, renamed _NN3~:
  is assumed to be: AndProp(integer,RealRange(0,infinity))

`A inter B inter C` := isolve({k >= 10, 2*k+1 <= 40, (3*k-1)/2 >= 12});
  {k = 10}, {k = 11}, {k = 12}, {k = 13}, {k = 14}, {k = 15}, {k = 16}, {k = 17}, {k = 18}, {k = 19}






Download Proposal.mw

First possible mistake: Are you sure that you shouldn't have written

eqns := [Eq13, Eq14, BodyEq1, BodyEq2, BodyEq3, BodyEq4, S__R__1, S__L__1, Joint1R_d, Joint1L_d, S__R__2, S__L__2, shear_SR2, shear_SL2, MSR2_Eq1, MSR2_Eq2, MSL2_Eq1, MSL2_Eq2, A_Eq1, A_Eq2, B_Eq1, B_Eq2]

instead of

eqns := [Eq13, Eq14, BodyEq1, BodyEq2, BodyEq3, BodyEq3, S__R__1, S__L__1, Joint1R_d, Joint1L_d, S__R__2, S__L__2, shear_SR2, shear_SL2, MSR2_Eq1, MSR2_Eq2, MSL2_Eq1, MSL2_Eq2, A_Eq1, A_Eq2, B_Eq1, B_Eq2]

?

Second possible mistake: lines 21 and 22 of AA are identical, which means that B_Eq1= B_Eq2... which is obvious from their definitions (you can  check, if you are patient enough, that Determinant(AA[1..21, 1..21]) <> 0)

So, shouldn't you have written 

B_Eq2 := subs(x = l__nL__2, phiL2prim2) = 0

instead of

B_Eq2 := subs(x = l__nL__2, phiL2prim3) = 0

?

So, correct your errors in the definition of (probably) B_Eq2 and run your code again (once again, this will take time to get the expression of this determinant).

Guessing that this question comes from some math chalenge, here is a way to get the solution by hand (even if I used Maple for the purpose of clarity).

restart:

f := x -> (x^2+1)/(x^2-1)

proc (x) options operator, arrow; (x^2+1)/(x^2-1) end proc

(1)

# As f is summetric the centre (Omega) of the circle C is on the vertical axis.
# Let (0, h) the coordinates of Omega.
# One has f(0)=-1.
# Let R the radius of C, then R = h+1.
#
# Let's take the branch of f defined by x > 1and search the point P of
# coordinates (X, Y=f(X)) such that (X-0)^2+(Y-h)^2=(h+1)^2:


CircleEquation = X^2+(f(X)-(R-1))^2 - R^2;

# As X > 1 on gets this relation


rel := numer(expand(rhs(%)))

CircleEquation = X^2+((X^2+1)/(X^2-1)-R+1)^2-R^2

 

-X^2*(-X^4+4*R*X^2-2*X^2-4*R-1)

(2)

# Clearly only the  term in parenthesis matters.
# Set X^2 = Z

rel1 := collect(algsubs(X^2=Z, op(-1, rel)), Z)

-Z^2+(4*R-2)*Z-4*R-1

(3)

# As we are looking for a tangence point, the discriminant of this
# equation must be equal to 0.
discrim(rel1, Z);
solve({%=0, R > 0}, R)

16*R^2-32*R

 

{R = 2}

(4)

# Thus R = 2 and the circle C has center (0, R-1=1)

R_circle := 2:
 

# Contact point for X > 1.
# As the squareroot ithin sol is equal to 0, one has

Z_contact := 2*R_circle - 1;

# And so:

X_contact := surd(Z_contact, 2);
Y_contact := (Z_contact+1) / (Z_contact-1);

3

 

3^(1/2)

 

2

(5)

# The contact point for X < 1 has coordinates

[-X_contact, Y_contact]

[-3^(1/2), 2]

(6)

 

Download By_hand.mw


THE FILE  calc_slip_two_cylinders_electo.mw  CORRESPONDS TO YOUR PREVIOUS QUESTION, TO WHICH I HAVE ALREADY GIVEN A SOLUTION.

calc_slip_two_cylinders_electo_mmcdara.mw


 

A remark: had you download your worksheet by using the green up-arrow in the menu bar, it would have been easier for anyone here to work on your problem. Think to it the next time you post a question :-)

As I said in the title the system is formally simple (a 4-by-for linear system of full rank) but the expressions of the coefficients of this system are that complex that solve seems incapable to solve it without a little help.

You will find here a simple idea: solve a formal 4-by-4 linear system and, AFTER, replace the coefficients of the solution you got by the true coefficients.

restart

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

u := c1*BesselK(0, alpha1*r) + c2*BesselI(0, alpha1*r) + c3*BesselK(0, alpha2*r) + c4*BesselI(0, alpha2*r) - A1*k^2*(k^2 - (-alpha^2*j*s + 4*c*s)/c)*BesselK(0, k*r)/((-alpha1^2 + k^2)*(-alpha2^2 + k^2)) - B1*k^2*(k^2 - (-alpha^2*j*s + 4*c*s)/c)*BesselI(0, k*r)/((-alpha1^2 + k^2)*(-alpha2^2 + k^2)) + ur*(-alpha^2*j*s + 4*c*s)/(c*(1 + c)):

w := (-1 - c)/(2*s*(4.*c - alpha^2*j))*collect(diff(diff(r*diff(u, r), r)/r, r) + (alpha^2 - 4*c*s)*diff(u, r)/(1 + c) - A1*k^3*BesselK(1, k*r) + B1*k^3*BesselI(1, k*r), [c1, c2, c3, c4], factor):

om := (-1)/2*diff(u, r)/u:

fn1 := collect(simplify(subs(subs(r = 1, u))), [c1, c2, c3, c4], factor):

fn2 := collect(simplify(subs(subs(r = sigma, u))), [c1, c2, c3, c4], factor):

fn3 := collect(simplify(subs(r = 1, w)), [c1, c2, c3, c4], factor):

fn4 := collect(simplify(subs(r = sigma, w)), [c1, c2, c3, c4], factor):

DesiredSolution := solve({fn1 = 0, fn2 = 0, fn3 = 0, fn4 = 0}, {c1, c2, c3, c4})

Warning,  computation interrupted

 

# Check the system

Vector[row](4, i -> has(fn||i, [c1, c2, c3, c4]));
Matrix(4$2, (i, j) -> type(fn||i, linear([c||j])));

Vector[row]([true, true, true, true])

 

Matrix([[true, true, true, true], [true, true, true, true], [true, true, true, true], [true, true, true, true]])

(2)

# This because I'm going to chose two names that are not already used

indets({fn1, fn2, fn3, fn4}, name)

{A1, B1, alpha, alpha1, alpha2, c, c1, c2, c3, c4, j, k, s, sigma, ur}

(3)

# This is a 4-by-4 linear system wrt [c1, c2, c3, c4].
#
# Let MatrixCoeffs be the matrix of coefficients of c(j) in fn(i).
# Let RhsCoeffs bethe column vector of terms in fn(i) which do not
# contain c1, ..., c4.

MatrixCoeffs := Matrix(4$2, (i, j) -> coeff(fn||i, c||j)):
RhsCoeffs    := Vector(4, i -> -eval(fn||i, [c1, c2, c3, c4]=~0)):

# Solve this symbolic system:


SymbolicMatrix := Matrix(4$2, symbol=m):
SymbolicRhs    := Vector(4, symbol=r):
SymbolicSol    := LinearAlgebra:-LinearSolve(SymbolicMatrix, SymbolicRhs):
SymbolicSol    := simplify(SymbolicSol, size):

# Example

SymbolicSol[1]

(((-m[3, 4]*r[4]+m[4, 4]*r[3])*m[2, 3]+(m[3, 3]*r[4]-m[4, 3]*r[3])*m[2, 4]-r[2]*(m[3, 3]*m[4, 4]-m[3, 4]*m[4, 3]))*m[1, 2]+((m[3, 4]*r[4]-m[4, 4]*r[3])*m[2, 2]+(-m[3, 2]*r[4]+m[4, 2]*r[3])*m[2, 4]+r[2]*(m[3, 2]*m[4, 4]-m[3, 4]*m[4, 2]))*m[1, 3]+((-m[3, 3]*r[4]+m[4, 3]*r[3])*m[2, 2]+(m[3, 2]*r[4]-m[4, 2]*r[3])*m[2, 3]-r[2]*(m[3, 2]*m[4, 3]-m[3, 3]*m[4, 2]))*m[1, 4]+((m[3, 3]*m[4, 4]-m[3, 4]*m[4, 3])*m[2, 2]+(-m[3, 2]*m[4, 4]+m[3, 4]*m[4, 2])*m[2, 3]+m[2, 4]*(m[3, 2]*m[4, 3]-m[3, 3]*m[4, 2]))*r[1])/(((m[3, 1]*m[4, 4]-m[3, 4]*m[4, 1])*m[2, 3]+(-m[3, 1]*m[4, 3]+m[3, 3]*m[4, 1])*m[2, 4]-m[2, 1]*(m[3, 3]*m[4, 4]-m[3, 4]*m[4, 3]))*m[1, 2]+((m[3, 2]*m[4, 4]-m[3, 4]*m[4, 2])*m[2, 1]+(-m[3, 1]*m[4, 4]+m[3, 4]*m[4, 1])*m[2, 2]+m[2, 4]*(m[3, 1]*m[4, 2]-m[3, 2]*m[4, 1]))*m[1, 3]+((m[3, 1]*m[4, 3]-m[3, 3]*m[4, 1])*m[2, 2]+(-m[3, 1]*m[4, 2]+m[3, 2]*m[4, 1])*m[2, 3]-m[2, 1]*(m[3, 2]*m[4, 3]-m[3, 3]*m[4, 2]))*m[1, 4]+((m[3, 3]*m[4, 4]-m[3, 4]*m[4, 3])*m[2, 2]+(-m[3, 2]*m[4, 4]+m[3, 4]*m[4, 2])*m[2, 3]+m[2, 4]*(m[3, 2]*m[4, 3]-m[3, 3]*m[4, 2]))*m[1, 1])

(4)

# Here is the lengthof SymbolicSol:

length(SymbolicSol)

7874

(5)

# So try to imagine what would be the length of Desiredsolution... which is
# the reason why solve faces huge problems.
#
# But, knowing SymbolicSol, MatrixCoeffs and RhsCoeffs, it becomes extremely
# simple to get the expression of any c(j).


Substitutions := {entries(SymbolicMatrix =~ MatrixCoeffs, nolist), entries(SymbolicRhs =~ RhsCoeffs, nolist)}:

C_Solution := Vector(4, j -> eval(SymbolicSol[j], Substitutions)):

# For instance


length(C_Solution[1]);
C1 := C_Solution[1]:

35205

(6)

 

Download LinearSolve.mw

Simplifying the expressions of any element of C_Solution is now a very complex task (if possible).

You have two different data, let's say B and Y, even if Y never appears here, and you knox, or suspect,there is among them a functional relation Y = a*B+b*sinh(c*B).
Here a, b and c are the "parameters" of the model, B is named "the independent variable" and Y "the dependent variable".
Unfortunately you don't know what the values of a, b and c arre.
You then realize "observations" of Y for different values of B, and represent these latter by a vector named Bdata and the former by another vector of same length) named Hdata.
The procedure Fit is aimed to assess the values of a, b and c given the observations Bdata and Hdata.

Let Z(a, b, c) the vector whose component i is equal to a*Bdata[i]+b*sinh(c*Bdata[i]).
The most common method to seek for the triple (a, b, c) is to minimizes the euclidian norm of the vector Z(a, b, c) - Hdata wrt (a, b, c). This strategy is named "least-squares method".

I don't remember what Fit exactly did in Maple 13, but in more recent versions Fit is a procedure in the Statistics package which 
"... Fit command fits a model function to data by minimizing the least-squares error...." (from help pages).

Your command has exactly the same syntax today:

  • the first parameter is the model,
  • the second one is the vector of the independent variable(s),
  • the third oneis the one of the dependent variable,
  • and the last one is the name of the independent variable (or the list of the independent variables).


Note that the command Fit can contain several options.


You write that you "never used maple13 and have to describe a code" does it mean you do not have Maple 13 right now?
If it is so, go here
https://www.maplesoft.com/documentation_center/history.aspx
select Maple 13 and next Maple User Manual to load the pdf.
Open it and search for fit or curve fitting.



Use fsolve instead of solve, details in the attached file.
 

restart:

f := s -> cos(s)*cosh(s);
plot([1, f(s)], s=-4*Pi..4*Pi, color=[red, blue], view=[default,-1/2..3/2])

proc (s) options operator, arrow; cos(s)*cosh(s) end proc

 

 

# solve returns only the trivial solution s=0 and its not capable
# get the (infinite) set of al solutions:


infolevel[solve] := 4;

solve(f(s)=1);
infolevel[solve] := 0;

4

 

Main: Entering solver with 1 equation in 1 variable
Dispatch: dispatching to Trig handler
Dispatch: trigonometric substitution _S000002 = cos(s)
Recurse: recursively solving 1 equations in 2 variables
Dispatch: dispatching to OnlyIn handler
Recurse: recursively solving 1 equations in 2 variables
Dispatch: handling a single polynomial
Main: polynomial system split into 1 parts under preprocessing
Main: subsystem is essentially univariate
UnivariateHandler: subsystem has only one equation
UnivariateHandler: solving as if univariate in _S000002
UnivariateHandler: subsystem has only one equation
UnivariateHandler: solving as if univariate in _S000003
Polynomial: removing 1 trivial zeros at the origin
UnivariateHandler: subsystem has only one equation
UnivariateHandler: subsystem has only one equation
UnivariateHandler: solving as if univariate in _S000002
Polynomial: solving a linear polynomial
Recurse: recursively solving 1 equations in 1 variables
Dispatch: dispatching to OnlyIn handler
Recurse: recursively solving 1 equations in 1 variables
Transformer:   solving the uncoupled linear subsystem in _S000004
Recurse: recursively solving 1 equations in 1 variables
Transformer:   solving the uncoupled linear subsystem in s
SolutionsLost: setting solutions lost flag
Main: solving successful - now forming solutions
Main: Exiting solver returning 1 solution

Warning, solutions may have been lost

 

0

 

0

(1)

# f is symmetric:

simplify(f(s)-f(-s))

0

(2)

# The roots of f are 0, Pi/2 + k*Pi where k is a relative integer

roots_of_f := RealDomain:-solve(f(s)=0, allsolutions);

(1/2)*Pi+Pi*_Z1

(3)

# In the half line [0, +oo), the first root is s=0

f(0)

1

(4)

# In the half line (Pi/2, +oo), f(s) > 0 when cos(s) > 0.
# This f(s) > in intervals (Pi/2+k*Pi, Pi/2+(k+1)*Pi) with k
# any odd integer.
# Let omega[k] such an interval.
# As cosh is a strictly increasing function over (0, +oo),
# there exist two points z1 and z2 omega[k] such that f(s) = 1.
#
# In the half line (-oo, 0), f(s) > 0 when cos(s) > 0.
# This f(s) > in intervals (Pi/2-k*Pi, Pi/2-(k+1)*Pi) with k
# any odd integer.
# Let omega[k] such an interval.
# As cosh is a strictly increasing function over (-oo, 0)),
# there exist two points z1 and z2 omega[k] such that f(s) = 1.

AllSolutionsInRange := proc(r)
  local kvalues, i, sols;
  op~({isolve({Pi/2+k*Pi >= max(0, op(1, r)), Pi/2+(k+1)*Pi <= max(0, op(2, r))})}):
  kvalues := rhs~(select((x -> rhs(x)::odd), %)):
  op~({isolve({Pi/2+k*Pi >= min(0, op(1, r)), Pi/2+(k+1)*Pi <= min(0, op(2, r))})}):
  kvalues := kvalues union rhs~(select((x -> rhs(x)::odd), %));
  sols := NULL;
  for i in kvalues do
    sols := sols, fsolve(f(s)=1, s=Pi/2+i*Pi..Pi/2+(i+1/2)*Pi);
    sols := sols, fsolve(f(s)=1, s=Pi/2+(i+1/2)*Pi..Pi/2+(i+1)*Pi);
  end do;
  if verify(0, r, interval) then sols := sols, 0 end if:
  return sort([sols])
end proc:
  

# Example

r := -5*Pi/2..9*Pi/2;
AllSolutionsInRange(r)

-(5/2)*Pi .. (9/2)*Pi

 

[-7.853204624, -4.730040745, 0, 4.730040745, 7.853204624, 10.99560784, 14.13716549]

(5)

 


 

Download 1_mmcdara.mw

 

This is an illustration of what can be done.
I used Maple 2015.2 but the structure which draw the label names is the same in bewer Maple's version.

Download Example.mw

The attached file presents:

  • A non linear model (NLM) and its linear counterpart (LM) under a simple transformation.
  • Two classical estimators of the covariance matrix from the NonlinearFit of NLM and how they both fail.
  • Two methods to asses the covariance matrix of the native parameters of the LinearFit of LM, from the one of the parameters of LM.
  • A discusion about the precautions to use as in both cases (NLM and LM) the joint distribution of the native parameters cannot be multi-normal.

Nonlinear_to_Linear_1.mw

Your initial question was "Need the covariance matrix...".
If you have read carefully the last text in the attached file you must have understood that in cas of a non linear model this covariance matrix doesn't provide sufficient information to draw inferences.
So my question is "Why do you need it?"

First 23 24 25 26 27 28 29 Last Page 25 of 65