7 years, 2 days

## MaplePrimes Activity

### These are replies submitted by mmcdara

https://www.mapleprimes.com/questions/236509-How-Do-I-Solve-This-One.

As I'm in a good mood today, here's a solution

 > # A maple expression PutMeInTheBox = `#mrow(msubsup(mo("Σ"),mrow(mi("k"),mo("=120")),mo("1300")),mo("i",mathcolor="white"),msup(mrow(mo("("),mo("2"),mo("i",mathcolor="white"),mi("x-k"),mo(")")),mi("k")))`
 (1)
 >
 >

## Can't you provide a Maple code for u...

Can't you provide a Maple code for us to see what you are capable of and then guide you towards the solution?
The formulation of your question sounds like "do my homework, I don't want to bother with it".

## @KIRAN SAJJAN  Could you explain m...

@KIRAN SAJJAN

Could you explain more precisely what you want because your last worksheet doesn't contain any error and your request is not clear (at least for me).
I imagine M is the Mach number, Cf is the friction coefficient and Nu is the Nusselt number, aren't they?
Do you mean that you want to plot , for instance, aNusselt number defined by

`(-a4-Rd)*diff(T(Y), Y)`

for different values of the Mach number?

Could it be this:

 >
 >
 (1)
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 (2)
 >
 (3)
 >
 (4)
 >
 (5)
 >
 (6)
 >
 >
 > W     := unapply(W, Y);Theta := unapply(Theta, Y); U     := unapply(U, Y);Phi   := unapply(Phi, Y); F     := unapply(F, Y);T     := unapply(T, Y); G     := unapply(G, Y);H     := unapply(H, Y);
 (7)
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >

 >
 > Zs :=  [z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11, z12, z13, z14,z15, z16,z17,z18,z19,z20,z21, z22, z23, z24,z25, z26]: print~(Zs):
 (8)
 > IZs := indets(Zs) minus {M}; numelems(Zs), numelems(IZs);
 (9)
 > Zsol := proc(Ma) fsolve(eval(Zs, M=Ma)) end proc: # example Zsol(1)
 (10)
 > F := proc(Y, Ma) eval(sum(b[i]*Y^i,i=0..7), Zsol(Ma)) end proc: T := proc(Y, Ma) eval(sum(c[i]*Y^i,i=0..7), Zsol(Ma)) end proc: G := proc(Y, Ma) eval(sum(d[i]*Y^i,i=0..4), Zsol(Ma)) end proc: H := proc(Y, Ma) eval(sum(h[i]*Y^i,i=0..4), Zsol(Ma)) end proc:
 >
 > plot([seq(T(Y, Ma), Ma = 1 .. 3)], Y = 0 .. 1, axes = boxed, color = [red, green, blue], legend = `~`[cat]("M=", [`\$`(1 .. 3)]), thickness = 2, labels = [Y, T])
 >
 >
 >
 (11)
 >
 (12)

 > Cf := 'Cf': Nu := 'Nu': plot(   [seq(a1*(1+1/bet)*diff(F(Y, Ma), Y), Ma = 1 .. 3)]   , Y=0..1   , color=[red, green, blue]   , legend = `~`[cat]("M=", [`\$`(1 .. 3)])   , labels=[Y, "Cf"] ); print(): plot(   [seq((-a4-Rd)*diff(T(Y, Ma), Y), Ma = 1 .. 3)]   , Y=0..1   , color=[red, green, blue]   , legend = `~`[cat]("M=", [`\$`(1 .. 3)])   , labels=[Y, "Nu"] )

 >
 >
 >
 >

## @ogunmiloro Ok.Your model can be su...

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)

## Could you make some presentation effort?...

• 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 ?
```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.

## Did you notice ......

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

## Almost one error per line...

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 ...

@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 val...

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 fro...

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.

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

## @Jean-Michel Hi, I've alwa...

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 ...

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

## Are you aware that the ball is located b...

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 w...

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.