janhardo

695 Reputation

12 Badges

11 years, 39 days

MaplePrimes Activity


These are replies submitted by janhardo

@Thomas Richard 

Thanks

Yes, the worksheet is made in 2002 by a person who studied at the same time i did for secondairy schools teacher math. 
Only he studied falso or mathematical engineering too at the same time, so trained with Maple
It was possible to follow two studies at the same time, but i was too late and it just finished the second study then when i ask for. ( in fact years too late , i did not knew it)

I think i will be most complex functions , so it will be generally then.
Don't know yet not else what more to do ?

tomleslie 

Thanks

I am wondering if all code in the book is rubbish , that 's why i came up with this example. (checktri) from the book from wich i think this could be obselote code?
If i am able to recognise bad code, then chance it in good code easily, that was the idea.
How to recognise this obselote code then?

So i don't want to learn how to code badly, no of course not  
I will study your made example with a subprocedure in it and  downloaded the programming guide.

Your code example is not the same a s intentend as in the book 
Its about knowing what type of triangle is concerned ( 4 types) and a plot with a normal vector what acts as a help for visualizing ( read ) the plot in the right position 

@janhardo 

------------------------------------------------------------------------------

I think that you're causing yourself confusion by making an unnecessary distinction between procedures and subprocedures.  A procedure B only needs to be considered a subprocedure of procedure A if B directly refers to the locals or parameters of A. In the code that follows, SelectX is a subprocedure of ModuleApply, but maxmin and pluralize are not. SelectX needs to be declared inside ModuleApply, but the others do not although they are used within ModuleApplySelectX itself has a subprocedure, j-> Y[j]=y. Such a procedure is called anonymous because it has no proper name.

---------------------------------------------------------------------------------

Using a module definition is for grouping procedures in general and in some case there are also sub procedures involved

@janhardo 

Seems to be all wrong here in this old procedure 

  • It is main procedure with sub procedures , but not together 
  • The need of a module here ?
  • It seems to be wrong programmed with evaln ?
     

druiehoekvb-met_evaln_geprogammerd_fout_dusCD5-3b.mws

@janhardo 

Why i should use :
add( n!/(k!*(n-k)!)*a^(n-k)*b^k, k=0..n);

instead of a do loop ?

Answer: its easier to use a add statement then a do loop statements  , correct?

@tomleslie 

Thanks for your advice and showing the right approach.

its a book from 2002 An introduction to programming using Maple -david betounes + another book too from 2002 ( also there examples of procedures defined with :  evaln ) 

The example procedures with this structure : proc ( ..,evaln , .. ) are problematic programmed then in the book ?
Enclose a example of this more 

druiehoekvb-met_evaln_geprogammerd_fout_dusCD5-3b.mws

@Carl Love 

Thanks

your procedure on saddle point calculation is not set up as a module, why not?

Making a procedure for saddlepoints - MaplePrimes

In BadSqr ( ) procedure  , the command BadSqr is not usable, why using this s variable then?  
without return statement  BadSqr (3,s );  i get 9 
Confusing this return statement whille sqr:=x^2 is the last statement in BadSqr().

BadSqr:= proc(x)
local sqr;    
sqr:= x^2;
   # return
end proc
:

BadSqr(3); 
                               9
----------------------------another example with evaln ----------------------

Example 2.5 (Binomial Expansion)

The following is a short procecure to compute expansions of binomials:

 binom:=proc(a,b,n,result::evaln)
    s:=0;
    for k from 0 to n do
        s:=s+(n!/(k!*(n-k)!))*a^(n-k)*b^k;
    end do;  
    result:=s;
    RETURN()           
### WARNING: `s` is implicitly declared local
### WARNING: `k` is implicitly declared local
  end proc: 

As explained in the book this is a procedure for expanding expressions of the form 
                          "(a + b)^n"

 where n is a nonnegative integer .  There is no output because of the RETURN command.  The expansion is stored in the variable s which is is passed to the output parameter result .  Let's test the procedure on some expansions we know.

----------------------------------------------------

How to use this procedure is not straightforward 

procedure_binomium_CD2-6.MWS

@Carl Love 

Thanks

I was writing about the first procedure that i posted , not about the procedure made by @tomleslie

@Carl Love 
Thanks

Its a old book from 2002 were i took this example from : the word "module" is not listed in the index of the book 
Groups of related procedures  that's how it is presented in the book.

This book needs then a overhaul of the present programming practice with Maple 
I must see that the structure of your module example is yet not clear for me but: 
A group of related procedures and other code can be put together into a module 
That's the start for me 

----------------------------------------------------------------------------------

The code that you're using as examples uses a very bad programming practice: The procedures return their values through parameters declared evaln rather than through the normal return mechanism.

------------------------------------------------------------------------------------
What does this exactly mean  between the -----?

@janhardo I see that the input parameters from the second procedure as local variables are declared in the main procedure .
Indeed the sub procedure is treated like a local variable

@tomleslie 
Thanks

Its one procedure nowypou made.

It was more about the concept/mechanism of a second or more procedures , how to include this in a mainprocedure ...

@Carl Love 

That makes the last code version more versitale for using f(x,y,z) , but for this the code needs to be modified a lot i think.
To make this code general also makes it more versatile

Your expertise for coding in Maple is beyond the average user.
Still wonder why , how the average user of Maple with no strong programming skills can use the inbuilt commands(statements)  and construct easily a procedure to make his homework?

Looked again to code in ExtremaAndSaddles_onderzoek_code_(6).mw
Comparing the two saddle point procedures with debug shows more about their structure?

@janhardo 

Was looking first at this

Gradient:= proc(f)
local x, y, V:= (x,y); 
    unapply(diff~(f(V), [V]), [V])
end proc
:

later on this is changed into the code hereunder , but tried to figure out the idea behind this first code piece.

#Returns a list of procedures that return the 1st partial derivatives #of f.

Gradient:= proc(f, {arity::posint:= 2})
local x, i, V:= seq(x[i], i= 1..arity);
    map(unapply, diff~(f(V), [V]), [V])
end proc

@Carl Love 
Thanks

Amazing code to see all critical points in the graph. 
The colored points on the graph and in the table have educational value.
Saddle points are now clear to examine.
Also the gradients patterns between a min/max and a saddlepoint and were there is hardly a gradienvector to see , there has it the value 0. 
Two minima points to see, but there is no distinction between them.
The gradient occurs at a levelcurve in the graph.  
To learn from this you need at least two of the types of critical points in a graph 

This all with only a function input in the procedure, that's convenient.
Domain is now automatically set, but perhaps manual too in order to see more critcal points
A message to do this ..or not 

Note: i get two graphs with a colored table?

@janhardo 

Seems to be difficult to make a procedure out of the calculations of  special points of f(x)  from @kitonum and @Acer 
The only way out to make a procedure seems to be the high level procedure programming  from @ Carl
I should think that the average Maple user uses the inbuilt procedures,.Problem is the input for the main procedure when there are subprocdures, but maybe it is collecting all inputparameters of the sub procedure(s) and use them as inputparameters for the mainprocedure.

First 43 44 45 46 47 48 49 Last Page 45 of 73