mmcdara

6730 Reputation

18 Badges

8 years, 186 days

MaplePrimes Activity


These are replies submitted by mmcdara

@vv 

As CD=AB-2 is assumed to be a strictly positive integer (provided C and D are not confounded, which is the assumtion you use),
its niminum value is 1.
Which corresponds to AB = 3, and BC=5, so the lowest value of AD is 9.

Why do use Maple to do this?
It's a hydraulic hammer to kill a fly, and that's why teachers get desperate when they see students pulling out their pocket calculators to add 9 and 6.

Why do you keep asking questions like that?
A lot of your problems, like this one, can be solved by a middle school student and there is no need of any CAS for that.

Do you really want to know if Maple is capable to answer this one?
I think if he could not, it would have been thrown out a long time ago.

I am pretty sure there are more challenging problems for Maple than this one.

Remark: 
The formulation of the problem is for youngsters but lacks precision to be solved by Maple (does "consecutive" mean "not confounded"?)

@imparter 


You write I have an equation  W which constist of wo,w1,w2 and w3,:
No, you have 4 variables w0, ...w3 and another one W1 (you mispelled W in yout reply) which is equal to

W1:= (w0+w1*r^2+w2*r^4+w3*r^6);

W1 is not an equation:

whattype(W1); 
                     `+`
type(W1, 'equation')
                    false

At the end (output labeled (1) in your worksheet) the expression of  W1 depends on 5 indeterminates:

indets(W1, name)
                        {a, b, c, r, z}


Later, before applying plot, you do several substitutions which transform W1 into a new expression which depends on 11 indeterminates:

           {Da, Gr, S, alpha, c, kf, ks1, ks2, m, phi1, phi2}


You write  i want to plot the graphs for two data combine in one plot display in W1,
I understand you want to plot the expression of W1 (the one which depends on {a, b, c, r, z}, or the one which depends on {Da, Gr, S, alpha, c, kf, ks1, ks2, m, phi1, phi2} ?) as a function of two independent variables:

  • Do you want to do something like plot3d(some_expression_of_W1, variable_1, variable2) where some_expression_of_W1 is a an rewritting of W1 which contains variable_1 and variable2 ?
     
  • If it is so what are those inependent variables  variable_1 and variable2 ?
    To clarify this, you can do something like this
    plot3d(eval(W1, [a=1, b=2, c=3]), r=0..1, z=0..1)
    if you use the expression of W1 labeled (1) in your worksheet.

    Or 
    data := {Da=1, Gr=1, S=1, alpha=1, c=1, kf=1, ks1=1, ks2=1, m=1, phi1=1, phi2=1}:
    plot3d(eval(W1, data), r=0..1, M=2..9);
    if you use the expression of W1 after the rewrittings of {a, b, c}.

    But maybe you want to do
    data := {Da=1, Gr=1, S=1, alpha=1, c=1, kf=1, ks1=1, ks2=1, m=1, phi1=1, phi2=1}:
    W1e := eval(W1, data):
    plot( [seq(W1e, M=__M), __M=2..9)], r=0..1, legend='M'=~[$2..9]);


Try to be more precise in what you want to achieve.


The attached file explains you where the error comes from and why, once fixed, the plot command will produce another error.
It is up to you to fix this latter by giving numeric values to several remaining undeterminates.
Error_in_Display_1_mmcdara.mw

@minhthien2016 

My reaction to the MMA link you provide:

I'm disappointed by the lack of seriousness of the person who replied you: it simply shows that it has no statistical (nor mechanical) skills, as its answer simply makes no sense (unless it previously drawn the histogram of your raw data and observed that the the hypothesis of a uniform distribution was acceptable).

Don't take the answers you receive at face value: it's your responsibility to analyze them to understand whether or not they're credible.

Please read again my reply, I updated it.

The original @nm's question was "The problem is to find from all permutations of [1,2,3,4] those lists which has 2 in them before 3." and It feels like everybody took the same direction than @nm's, which is "construct the list of all permutations and select those where 2 appears before 3".
But It looks more natural to "construct directly the list of permutations for which 2 appears before 3".  
Behind the question I asked @Carl Love  (since I only have Maple 2015 I can't evaluate the performance of his solution) my real question was "Is this second approach more efficient than the one everyone else has considered?"

Here is a simple code (that could probably be improved) which seems to prove it's the case.
For comparison, I used @Kitonum's method, which @acer found to be the most efficient.
 

restart

C := proc(N, left, right)
  local P, J, L, k, n, j:

  P := combinat:-permute({$1..N} minus {left});
  J := ListTools:-Search~(right, P);

  L := table([]):
  k := 1:
  for n from 1 to (N-1)! do
    for j from 1 to J[n] do
      L[k] := [op(1..j-1, P[n]), left, op(j..-1, P[n])]:
      k    := k+1:
    end do:
  end do:
  L
end proc:

eval(C(4, 2, 3))

table( [( 1 ) = [2, 1, 3, 4], ( 2 ) = [1, 2, 3, 4], ( 3 ) = [2, 1, 4, 3], ( 4 ) = [1, 2, 4, 3], ( 5 ) = [1, 4, 2, 3], ( 6 ) = [2, 3, 1, 4], ( 7 ) = [2, 3, 4, 1], ( 9 ) = [4, 2, 1, 3], ( 8 ) = [2, 4, 1, 3], ( 11 ) = [2, 4, 3, 1], ( 10 ) = [4, 1, 2, 3], ( 12 ) = [4, 2, 3, 1] ] )

(1)

n := 4:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

12

 

memory used=15.02KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns, gc time=0ns

 

n := 5:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

60

 

memory used=41.78KiB, alloc change=0 bytes, cpu time=0ns, real time=1000.00us, gc time=0ns

 

n := 6:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

360

 

memory used=175.72KiB, alloc change=0 bytes, cpu time=1000.00us, real time=2.00ms, gc time=0ns

 

n := 7:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

2520

 

memory used=1.07MiB, alloc change=0 bytes, cpu time=8.00ms, real time=8.00ms, gc time=0ns

 

n := 8:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

20160

 

memory used=8.76MiB, alloc change=36.00MiB, cpu time=84.00ms, real time=84.00ms, gc time=6.98ms

 

n := 9:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

181440

 

memory used=73.08MiB, alloc change=288.00MiB, cpu time=988.00ms, real time=824.00ms, gc time=343.09ms

 

# For comparison on my machine (from acer):
# Kitonum's suggestion

L:=combinat:-permute([1,2,3,4,5,6,7]):
CodeTools:-Usage(select(t->ListTools:-Search(2,t)<ListTools:-Search(3,t), L)):
nops(%);

print():print():
L:=combinat:-permute([1,2,3,4,5,6,7,8]):
CodeTools:-Usage(select(t->ListTools:-Search(2,t)<ListTools:-Search(3,t), L)):
nops(%);


print():print():
L:=combinat:-permute([1,2,3,4,5,6,7,8,9]):
CodeTools:-Usage(select(t->ListTools:-Search(2,t)<ListTools:-Search(3,t), L)):
nops(%);

memory used=1.44MiB, alloc change=0 bytes, cpu time=19.00ms, real time=19.00ms, gc time=0ns

 

2520

 

 

 

memory used=11.54MiB, alloc change=0 bytes, cpu time=138.00ms, real time=138.00ms, gc time=0ns

 

20160

 

 

 

memory used=103.83MiB, alloc change=26.92MiB, cpu time=3.66s, real time=2.03s, gc time=2.25s

 

181440

(2)
 

 

Download suite_2_3.mw

@Carl Love 

As I can't use the Iterator package (still Maple 2015), could you please give me the performances you get when evaluating function f for a few values of N:

f := N -> {seq}(p[], p= Iterator:-TopologicalSorts(N, {2<3}));
CodeTools:-Usage(f(...)):

Thanks in advance

@Aung 

I'm fed up with people asking questions and not bothering to give feedback on the answers they've received.
Considering that what I did no longer interest you I then remove some parts of this reply


Result without explanation



When you will be interested again, if that ever happens, let me know, I will deliver you the code

@nm 

You must create an account first (free and anonymous, your email adress is never asked nor your username).
Once done the description page looks loke this 
Enter your answer and click on the Check button to check it.

Solutions are gathered here.
As Project Euler is more computing oriented than brainstorming this site only contains code in 4 different languages (MMA in particular) but no textual explanation of the way to get these solutions is provided.

This site provides more explanations, but only for the problems the author solved.

From Project Euler home page:

What is Project Euler?

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

@Aung 

Why didn't you tell me if my first reply helped you in solving your initial problem?

More of this, I don't understand your first reply (nor the second for that matter)

sir...i still make a mistake....i think..model...
here is my integration....
i try normally it gives zero...but i try watching from maple Help 
it can't solve...please check this and then i can recaculate the model 

What does "i try normally it gives zero." mean?
"it can't solve" what?

@Aung 
 

restart:

with(IntegrationTools):

eq1 := n -> Int(sum(A[i]*lambda[i]*exp(-lambda[i]*(t - tau)), i = 1 .. n)*tau, tau = 0 .. t);

proc (n) options operator, arrow; Int((sum(A[i]*lambda[i]*exp(-lambda[i]*(t-tau)), i = 1 .. n))*tau, tau = 0 .. t) end proc

(1)

# example (Expand "works with" Int, not with int.

N := 3:

eq2 := IntegrationTools:-Expand(eq1(N), continuous);

A[1]*lambda[1]*(Int(tau*exp(lambda[1]*tau), tau = 0 .. t))/exp(lambda[1]*t)+A[2]*lambda[2]*(Int(tau*exp(lambda[2]*tau), tau = 0 .. t))/exp(lambda[2]*t)+A[3]*lambda[3]*(Int(tau*exp(lambda[3]*tau), tau = 0 .. t))/exp(lambda[3]*t)

(2)

simplify(eq2);

A[1]*lambda[1]*exp(-lambda[1]*t)*(Int(tau*exp(lambda[1]*tau), tau = 0 .. t))+A[2]*lambda[2]*exp(-lambda[2]*t)*(Int(tau*exp(lambda[2]*tau), tau = 0 .. t))+A[3]*lambda[3]*exp(-lambda[3]*t)*(Int(tau*exp(lambda[3]*tau), tau = 0 .. t))

(3)

value((3));

A[1]*exp(-lambda[1]*t)*(exp(lambda[1]*t)*t*lambda[1]-exp(lambda[1]*t)+1)/lambda[1]+A[2]*exp(-lambda[2]*t)*(exp(lambda[2]*t)*t*lambda[2]-exp(lambda[2]*t)+1)/lambda[2]+A[3]*exp(-lambda[3]*t)*(exp(lambda[3]*t)*t*lambda[3]-exp(lambda[3]*t)+1)/lambda[3]

(4)

# To combine the terms the way you want you can do something like this (or something else)

se, re := selectremove(has, expand((4)), exp):
st, rt := selectremove(has, expand(re), t):

eq2 := collect(st, t) + map(normal, (collect(eval(rt+se, exp = (u -> 1/exp(-u))), [seq(A[n], n=1..N)])))

(A[1]+A[2]+A[3])*t+(-1+exp(-lambda[1]*t))*A[1]/lambda[1]+(-1+exp(-lambda[2]*t))*A[2]/lambda[2]+(-1+exp(-lambda[3]*t))*A[3]/lambda[3]

(5)

eq2_bis := collect(eq2, [seq(A[n], n=1..N)])

(t+(-1+exp(-lambda[1]*t))/lambda[1])*A[1]+(t+(-1+exp(-lambda[2]*t))/lambda[2])*A[2]+(t+(-1+exp(-lambda[3]*t))/lambda[3])*A[3]

(6)

eq2_ter := map(normal, eq2_bis)

(lambda[1]*t+exp(-lambda[1]*t)-1)*A[1]/lambda[1]+(lambda[2]*t+exp(-lambda[2]*t)-1)*A[2]/lambda[2]+(lambda[3]*t+exp(-lambda[3]*t)-1)*A[3]/lambda[3]

(7)

 


 

Download suggestion.mw

 


Without constraints, mainly on the lambdas which should be negative (viscoelastic model) you have no chance to get a result
Look at this
 

restart

with(Statistics):with(plots):with(Optimization):with(LinearAlgebra):

E[1] := 126*10^9:E[2] := 11*10^9:G[12] := 6.6*10^9:G_0__12 := 10.1*10^9:nu[12] := .28:E_0__2 := 15.5*10^9:

true_strain := [0, .406915, .710106, .989362, 1.28457, 1.53989, 1.86702, 2.21011, 2.625, 2.99202]:

true_strain := true_strain[2..-1]:
true_stress := true_stress[2..-1]:


N := nops(true_strain);

sigma_t := strain -> E[instantaneous]*(1-lambda[90*deg]*strain*(add(P[i], i=1..N)-(add(P[i]*exp(lambda[i]*strain/epsilon_dot), i=1..N)))/epsilon_dot)*strain:

9

(1)

Digits := 15:
obj := add(
         (
           sigma_t(true_strain[i])
           -
           true_stress[i]
         )^2
         , i=1..N
       ):

opt := NLPSolve(obj, {seq(lambda[j] >= -1, j=1..N), seq(lambda[j] <= 0, j=1..N)} );

[6683400368455538., [E[instantaneous] = HFloat(8.444510441702259e7), P[1] = HFloat(1.0), P[2] = HFloat(1.0), P[3] = HFloat(1.0), P[4] = HFloat(1.0), P[5] = HFloat(1.0), P[6] = HFloat(1.0), P[7] = HFloat(1.0), P[8] = HFloat(1.0), P[9] = HFloat(1.0), lambda[1] = HFloat(-1.8789657429094086e-300), lambda[2] = HFloat(1.8789657651601472e-300), lambda[3] = HFloat(-1.8789657874108858e-300), lambda[4] = HFloat(1.8789658096616243e-300), lambda[5] = HFloat(-1.878965831912363e-300), lambda[6] = HFloat(1.8789658541631015e-300), lambda[7] = HFloat(-1.87896587641384e-300), lambda[8] = HFloat(1.8789658986645787e-300), lambda[9] = HFloat(-1.8789659209153173e-300), lambda[90*deg] = HFloat(0.9997201132757775)]]

(2)

display(
  ScatterPlot(true_strain, true_stress, symbol=circle, color=blue),
  pointplot([[0.001$2]], symbol=circle, color=blue),
  plot(eval(sigma_t(Sigma), opt[2]), Sigma=0.001..max(true_strain), color=red)
)

 

display(
  ScatterPlot(true_strain, true_stress, symbol=circle, color=blue),
  pointplot([[0.001$2]], symbol=circle, color=blue),
  plot(eval(sigma_t(Sigma), opt[2]), Sigma=0.001..max(true_strain), color=red),
  axis[2]=[mode=log]
)

 

opt := NLPSolve(
         obj,
         {
           seq(P[j] >= 10, j=1..N),
           seq(lambda[j] >= -1, j=1..N),
           seq(lambda[j] <= 0, j=1..N)
         }
       );

display(
  ScatterPlot(true_strain, true_stress, symbol=circle, color=blue),
  pointplot([[0.001$2]], symbol=circle, color=blue),
  plot(eval(sigma_t(Sigma), opt[2]), Sigma=0.001..max(true_strain), color=red)
)

[1241236907553440.50, [E[instantaneous] = HFloat(9.759820692425984e7), P[1] = HFloat(10.0), P[2] = HFloat(10.0), P[3] = HFloat(10.0), P[4] = HFloat(10.0), P[5] = HFloat(10.0), P[6] = HFloat(10.0), P[7] = HFloat(10.0), P[8] = HFloat(10.0), P[9] = HFloat(10.0), lambda[1] = HFloat(-5.61032344030491e-13), lambda[2] = HFloat(-5.61032344030491e-13), lambda[3] = HFloat(-5.61032344030491e-13), lambda[4] = HFloat(-5.61032344030491e-13), lambda[5] = HFloat(-5.61032344030491e-13), lambda[6] = HFloat(-5.61032344030491e-13), lambda[7] = HFloat(-5.61032344030491e-13), lambda[8] = HFloat(-5.61032344030491e-13), lambda[9] = HFloat(-5.61032344030491e-13), lambda[90*deg] = HFloat(0.9994098437679935)]]

 

 

 


 

Download 90As4_mmcdara.mw

So define your own physical constraints and proceed as I did.
Come back to me/us if you still have problems.

@salim-barzani 

Q : "but why you go to end and not finish the work i wish i can do like you and i wish always finish the work"

A : I ended my work for four reasons:

  1. The expressions of eq0, .., eq10 I got are not the same of those you write: Where do yours come from?
  2. In what I did equations eq0, .., eq9 ( you discard eq10) depend upon 14 parameters
    {k, lambda, mu, w, B[1], B[2], a[1], a[2], a[3], a[4], a[5], alpha[0], alpha[1], beta[1]}
    So there is likely an infinity of 14-uples that verify these 10 equations.
  3. On your side you want to solve your 10 equation system {eq0, .., eq9} with respect to 7 unknowns:
    {w, a[1], a[2], a[3], alpha[0], alpha[1], beta[1]}
    So it is very likely that you have no solutions at all.
  4. Whatever the true expressions of these 10 equations are, they are highly non linear, which means that even if the number of unknowns was "correct", solve will never give you the formal expressions of these unknown (they would be so complex anyway that you would probably not even be able to display them).

So I didn't see the need to go any further until you had checked my expressions of the equations, correctly defined the system to be solved (why do you throw out eq10?) and its unknowns, and understood that its formal resolution is a dead end.

@vv 

The biggest circle which tangents the outer shape at a single point has these characteristics

P3 = NULL
P2 = [1.268415320, 1.896811508]
P1 = [0.6984958110, 0.5060156134]
P0 = [1.134857966, 1.138248648]
r  = 0.7692659625
3 4 5 6 7 8 9 Last Page 5 of 142