Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 361 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@fluff I take it that you want the option of doing 0, 1, or 2 switches, right? You can't get two switches by including the switch argument twice.You make switches take a value in {0, 1, 2} by specifying the parameters like this

MontyHall:= proc(N::posint, {switches::identical(0,1,2):= 0})

and then making the calls like this

MontyHall(100000);  MontyHall(100000, switches=1);

etc.

@Markiyan Hirnyk Note that the prime notation for derivatives, A'(t), only works with 2D input.

@Kitonum It's O(n^4) because inside the loop for choose(S,3) there is a seq that scans over the remaining vertices.

I agree with you on points (1) and (3).

Do you mean that you want to do a simulation of the situation, with random selection?

Do you want the contestant to choose to switch always?

@rwooduk The green arrow for file upload is the last (rightmost) item in the second row of the toolbar.

(But I was able to download your file from zippyshare.)

@jelmew None of the basic simplifying commands work with the non-commutative multiplication operator `.`. If you are working with tensors, you should probably load the Physics package, which has its own simplifiers. Outside of that, the expression at hand can be further simplified via

eval(%, `.`= `*`);

First, please format your code so that it is readable by a human. Something like this
printf("No           root                   x[i+1]                 abs(x[i+1]-x[i])\n");
for i to n do
     y[i] := evalf(x[i]+(-D1(x[i])+sqrt(D1(x[i])^2-2*f(x[i])*D2(x[i])))/D2(x[i]));
     x[i+1] := evalf(y[i]-f(y[i])/sqrt(D1(x[i])^2-2*f(x[i])*D2(x[i])));
     printf("%d         %10.10f     %10.10f       %10.10e \n",
             i+1,       x[i+1],    f(x[i+1]), abs(x[i+1]-x[i])
     );
     if abs(x[i+1]-x[i]) < tol then
          print("approximate solution" = x[i+1]);
          print("No of iterations" = i+1);
          break
     end if
end do;

What is y[i]? What are D1 and D2? Did you intend for n to represent the maximum allowed number of iterations? n and tol and f need to be specified. Your formula for x[i+1] looks weird---too complicated. What function are trying to find the root of?

This is the kind of error message that a programmer puts into code to indicate that a serious bug has occured. This error message in particular occurs in the short procedure DynamicSystems:-TF_Matrix.

@jelmew I tested this on the uploaded worksheet:

evalindets(combine(Mcross, symbolic), sqrt, expand);

Maybe there are no solutions. It would be nice to have some evidence that a solution exists (such as a plot) before fine tuning fsolve with options.

There are complex solutions that fsolve will find if you give it the option complex.

@Adri van der Meer Regarding your point (1): It is not necessary to declare the dimensions of an Array. See my Answer for an example of this.

@Preben Alsholm These links cover the univariate case only.

@john125 Can you post a worksheet with the actual equations, please?

@john125 Sorry, I meant

select(y-> is(y>0), [Sols]);

@toandhsp Cut and pate Kitonum's code directly from the Post.

First 580 581 582 583 584 585 586 Last Page 582 of 709