mmcdara

4862 Reputation

17 Badges

6 years, 362 days

MaplePrimes Activity


These are replies submitted by mmcdara

@ogunmiloro 

Ok.

Your model can be summarized as 

diff(G[dp](T), T) = psi[1]*F[d](T)+psi[2]*L[d](T)+psi[3]*E[c](T)-delta[3]*G[dp](T)
=
diff(G[dp](T), T) = F(T)-delta[3]*G[dp](T);

where
F(T) = psi[1]*F[d](T)+psi[2]*L[d](T)+psi[3]*E[c](T)

You say that F[d], L[d] and E[c] are indeed functions of time.
Let's assume that a correct fitting is such that psi[1], psi[2], psi[3], F[d](T), L[d](T) and E[c](T) get these values

psi[1] = p[1], psi[2] = p[2], psi[3] = p[3], F[d](T)=A(T), L[d](T)=B(T), E[c](T)=C(T)

Thus this solution is such that 

p[1]*A(T) + p[2]*B(T) + p[3]*C(T)

and any 6-uple 

(psi[1], psi[2], psi[3], F[d](T), L[d](T), E[c](T) )

which verifies 

psi[1]*F[d](T)+psi[2]*L[d](T)+psi[3]*E[c](T) = p[1]*A(T) + p[2]*B(T) + p[3]*C(T)

gives an exacyly as good fit than 

psi[1] = p[1], psi[2] = p[2], psi[3] = p[3], F[d](T)=A(T), L[d](T)=B(T), E[c](T)=C(T)

Thus your parameters are not identifiable.

If F[d], L[d] and E[c] arr known functions of time the problem remains the same: if F[d], L[d] and E[c] are not linearly independent there is an infinity of triples (psi[1], psi[2], psi[3]) which give exactly fit, meaning the psi are not identifiable.
Can you give the expressions of F[d], L[d] and E[c]? Or at least there values at the different years?

More of this you said nothing about the initial condition on G[dp](T)


Please enlighten us

  • What does (for instance) year 2022 = 3, 023, 744. 14 mean?
    Are 3 quantities collected each year... or only one (GDP) and do you use commas to separate thousands?
  • So, what are the data?
  • What do you mean by "Fit the following model to the data" ?
    Do you mean "solve the ode
    diff(G[dp](T), T) = psi[1]*F[d](T)+psi[2]*L[d](T)+psi[3]*E[c](T)-delta[3]*G[dp](T);
    for some initial condition
    • Which one?  
      G[dp](some_unknown_date) = 1023744 ?
    • What about the parameters 
      delta[3] = .19, psi[1] = .63, psi[2] = .84, psi[3] = .72
      
      Are these the values to use in the previous ode?
      Or are there only indicative values (initial values) of these four parameters you aimed to assess through some minimization procedure?
    • Are F[d], L[d] andE[c] functions of time or constants?
       

Perhaps you think that the people you're asking for help just have to muddle through your draft, and that any effort on your part is superfluous?

@vv 

Your last remark is interesting.
There are no characters with more than 2 bytes in French (more precisely I didn't find any), that is why I asked @erik10 to check my procedure.

PS: I've just browsed the link you provided and voted for your answer.


... that you try to solve a system of 7 equations in only 4 unknowns?


Errors:

  1. What do you expect to do writting f[i] = f[i+1] ? (= instead of := ???)
  2. Your loop is unterminated (end do is missing, see the help pages to write a loop correctly).
  3. What is n in 
    f[i+2] := (2/11)*n[i-1]-(9/11)*n[i]+(12/11)*f[i]+(6/11)*m[i+2]

    Did you wanted to write m instead?
    While n is undefined it's impossible to get the expected results you present.
     

Fix all these points and come again if you still get errors.

@AHSAN 

Isn't the error message clear enough for you not to be able to work out where the error comes from?

Error, (in plots:-display) expecting plot structure but received: contplot

means: "plots:-display expect a plotting command (plot, plot2d, spacecirve, pointplot, PLOT, matrixplot, dataplot, contourplot, ...) but received contplot".
Is contplot a plotting function? Browse the help pages to check that.

One of two things:

  1. You did a typo writting contplot instead of contourplot (do the changing to verify that noerre is generated).
     
  2. Or... you followed my advice, went to https://www.mapleprimes.com/posts/210159-2D-Contour-Plot-And-Legend
    but didn't read what  @acer  wrote and jumped jump straight away to what you wanted without even wondering if the preceding code was necessary or not.
    Read again  @acer's  post: you will see that he begins building the procedure contplot , perhaps you should copy it into your worksheet before using it?

@AHSAN 

You want to plot numeric values don't you? So you must ignore line 1 od the data matrix, which 2..-1 does.
If you want to plot colimn 2 versus colum 1, selecting them thanks to [1, 2] does the job.
Finally data[2..-1, [1, 2]] means "all the rows of data but the first one and columns 1 and 2 (in this order!).

PS: I have updated my answer

@AHSAN 

Why didn't you start from the last file I sent you?
It's much closer than what you want to axhive (multiple plots) than the frist one was?

Here are some answers to to your questions: read it carefully to understandwhy you got errors and avoid reproducing them in the future.

Download Errors_explained_.mw

Your last file customized:

restart:

N := (-18*sqrt(2)*(M-(4/3)*r)*(x^2+2)^2*arctan((1/2)*x*sqrt(2))-9*Pi*(M*r-4/3)*(x^2+2)^2*sqrt(2)+(-36*M+48)*x^3+(-120*M+96)*x)/(4*(x^2+2)^2)

(1/4)*(-18*2^(1/2)*(M-(4/3)*r)*(x^2+2)^2*arctan((1/2)*x*2^(1/2))-9*Pi*(M*r-4/3)*(x^2+2)^2*2^(1/2)+(-36*M+48)*x^3+(-120*M+96)*x)/(x^2+2)^2

(1)

Func := proc(MM, col, sty)
plot(
  [eval(N, MM)]
  , x = -5 .. 5
  , labels = ["x", "N"]
  , axes = boxed
  , labeldirections = ["horizontal", "horizontal"]
  , colour = col
  , linestyle = sty
  , gridlines = false
 ):
end proc:

Vline := (x, eps) -> plot([[x, ymin-eps], [x, ymax+eps]], color=black):
Hline := y -> plot([[-5, y], [5, y]], color=black):

Legends := proc(Ms, Cols, Stys, Left, Right, eps, yleg0, gap)
local n, k, yleg, legs:
n    := numelems(Ms):
legs := NULL:
for k from 1 to n do
  yleg := yleg0 + (k-1)*gap;
  legs := legs,
          plots:-display(
            plot(yleg, x=Left..Left+1, color=Cols[k], linestyle=Stys[k])
            , plots:-textplot([Left+1, yleg, cat("M=", sprintf("%1.4f", eval(M, Ms[k])))], align=right)

          ):
 end do:
 legs := legs, plottools:-rectangle([Left-0.1, yleg0-2*eps], [Right, yleg0+gap*n], color=white)
end proc:

 

params := {
            [M=1.3015, r=0.1],
            [M=1.2812, r=0.1],
            [M=1.2605, r=0.1],
            [M=1.2108, r=0.1],
            [M=1.1523, r=0.1]
          }:

Cols  := [black, red, blue, green, purple]:
Stys  := [solid, longdash, spacedash, dash, dashdot]:
Left  := -4.8:
Right := -1.5:
eps   := 0.4:
yleg0 := ymin+2:
gap   := 1:

p := [ seq(Func(params[k], Cols[k], Stys[k]), k=1..numelems(params)) ]:

g := plottools:-getdata~(p):
map(t -> (min, max)(t[3][.., 2]), g):
ymin, ymax := (min, max)(%):

plots:-display(
  p[]
  , Vline(0, 0)
  #, Hline(0)
  , Legends(params, Cols, Stys, Left, Right, eps, yleg0, gap)
  , gridlines=true
  , title=cat("N = ", 1, ", r = ", sprintf("%1.1f", eval(r, params[1])))
);
 

 

 

 

Download Customized.mw

@Jean-Michel 

Hi, 
I've always felt as you do, that Mapleprimes is not the place to submit homework and expect that someone else will solve it for you.
I've even said this to some OPs, but saw that other contributors had less scruples, not to mention the criticism some have addressed to me. Which is not an excuse to play the same game, I agree.

See you soon, time for bed.

@AHSAN 

If uou want to draw a vertical line at position x=Ajust write

Vline := plot([[A, ymin-eps], [A, ymax+eps]], color=black):

Note that the eps is used here in order that the graph doesn't tangent the upper and lower box.

If you want display N legends, here is a way (customize the parameters as you want):

restart:

N := (-18*sqrt(2)*(M-4/3)*(x^2+2)^2*arctan((1/2)*x*sqrt(2))-9*Pi*(M-4/3)*(x^2+2)^2*sqrt(2)+(-36*M+48)*x^3+(-120*M+96)*x)/(4*(x^2+2)^2)

(1/4)*(-18*2^(1/2)*(M-4/3)*(x^2+2)^2*arctan((1/2)*x*2^(1/2))-9*Pi*(M-4/3)*(x^2+2)^2*2^(1/2)+(-36*M+48)*x^3+(-120*M+96)*x)/(x^2+2)^2

(1)

Func := proc(MM, col, sty)
plot(
  [subs(M = MM, N)]
  , x = -5 .. 5
  , labels = ["x", "N"]
  , axes = boxed
  , labeldirections = ["horizontal", "horizontal"]
  , colour = col
  , linestyle = sty
  , gridlines = false
 ):
end proc:

Vline := (x, eps) -> plot([[x, ymin-eps], [x, ymax+eps]], color=black):
Hline := y -> plot([[-5, y], [5, y]], color=black):

Legends := proc(Ms, Cols, Stys, Left, Right, eps, yleg0, gap)
local n, k, yleg, legs:
n    := numelems(Ms):
legs := NULL:
for k from 1 to n do
  yleg := yleg0 + (k-1)*gap;
  legs := legs,
          plots:-display(
            plot(yleg, x=Left..Left+1, color=Cols[k], linestyle=Stys[k])
            , plots:-textplot([Left+1, yleg, cat(" N=1, M=", sprintf("%1.4f", Ms[k]))], align=right)

          ):
 end do:
 legs := legs, plottools:-rectangle([Left-0.1, yleg0-2*eps], [Right, yleg0+(2*eps+gap)*(n-1)-eps], color=white)
end proc:

Ms    := [1.2, 1.3015, 1.4]:
Cols  := ["red", "green", "blue"]:
Stys  := [1, 3, 1]:
Left  := -4.8:
Right := -0.2:
eps   := 0.1:
yleg0 := ymin+0.3:
gap   := 0.4:

p := [ seq(Func(Ms[k], Cols[k], Stys[k]), k=1..3) ]:

ymin, ymax := (min, max)(seq((min, max)(plottools:-getdata(p[k])[3][.., 2]), k=1..3));

 

plots:-display(
  p[]
  , Vline(0, 0)
  , Hline(0)
  , Legends(Ms, Cols, Stys, Left, Right, eps, yleg0, gap)
);

 

 

-3.01379677260103396, 2.55529587632053135

 

 

 

Download Customize_as_you_want.mw

Are you aware that the ball is located below the surface?
I understand that given the positive value of the gravity the ball, without initial velocity, will go upward to the surface, but it seems a little bit weird.
More of this it would be better if you provide the differential equation of the movement, including the value of the coefficient of restitution.

A suggestion: browse the POSTS tab: some time ago someone published post about a bouncing ball over a 2D random curve.
Unfortunately I can put a finger on it but you could already see here https://maple.cloud/app/5151696808312832/Bouncing+Ball

@Rouben Rostamian  

Thanks, but it was merely a suggestion for you to improve your answer, not a proper answer from me (the final graph should be rotated by -Pi/2 but the text does not follow).
So I'm a bit confused, especially considering that the real good idea (switching to polar coordinates) is yours.

I vote up in return to balance your action.

@Anthrazit 

I've just edited my previous answer.
I agree: if you use only Maplets you don't have any problems.
The only difficulty is that the onchange option of the TextField  component requires that "something else" exists in the maplet in order you can click on.
So it's simpler here to use a Button element in conjunction with TextField:

restart
f := proc()
  local maplet:
  uses Maplets, Maplets:-Elements, Maplets:-Examples:
  maplet := Maplet(
    [
      [
        TextField['TF'](),
        Button("OK", onclick=Evaluate(function='Alert', Argument('TF', quotedtext)))
      ]
    ]
  ):
  Display(maplet)
end proc:
f()

The "three times knocking" is likely a consequence of an undesired interaction between DocumentTools and Maplets packages

Would adding a Button Component suit you?
KnockOneTimes.mw

@KIRAN SAJJAN 

I repeat as I think that maybe I wasn't clear enough:
Did the file I sent you execute correctly?

If it is so, that is already a first good point.
Now you claim it doen's execute correctly with your NEW bcs. What are they, could you please provide them, and only them, without all the unnecessary stuff.

What do you mean by writting "same problem i m using with different boundary conditios"?
That you don't get any solution?
Which is wrong: with your BCs1 as boundary conditions the solution is returned without any problem:

data :=  [
   S1=  0.5,   S2= 0.5, A=  1,
   Pr= 21, delta=0.01,g=0.1, 
   Ec= 0.5, Ra=0.5,Q=1,Gr=0.5,Br=0.5, 
   betu= 1.1,  bett= 1.1, S=  0.1,
   alp= 0.1,   
   bet= 2, 
   M1= 1, 
   Rd= 1
]: 
dsolve(eval({ODEs1[], BCs1[]}, data), numeric)
      proc(x_bvp)  ...  end;

Similarly

dsolve(eval({ODEs[], BCs[]}, data), numeric);
     proc(x_bvp) ... end;   #well posed problem

# a wrong posed problem: what are these auxiliary conditions NBVs?
dsolve(eval({ODEs[], BCs[], NBVs[]}, data), numeric);
Error, (in dsolve/numeric/process_input) invalid specification of initial conditions, got {-1.13493842976305*(D(Theta1))(1) = `Nu1*`, 1.14603660000000*(D(W1))(1) = `C*__f1`}

Is it necessary to write all these modules?

@KIRAN SAJJAN 

# What does this is aimed to do?
subs(
      _Sys= {:-ODEs[], :-BCs[], :-NBVs[]}
      Sol:= dsolve(_Sys, _rest, numeric);
      AccumData(Sol, {_options});
      Sol
   )
Error, `:=` unexpected   ### Of course!!!

Write correctly ModuleApply

1 2 3 4 5 6 7 Last Page 1 of 106