Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.maple > #1135

Re: Simplify Difficulty

From Axel Vogt <&noreply@axelvogt.de>
Newsgroups comp.soft-sys.math.maple
Subject Re: Simplify Difficulty
Date 2015-05-10 13:30 +0200
Message-ID <cr8tpvF9oviU1@mid.individual.net> (permalink)
References <g9ednZAkrPT5wdPInZ2dnUU7-K-dnZ2d@megapath.net> <cr79ivFs49hU1@mid.individual.net> <msydnSq0R4qYEtPInZ2dnUU7-TednZ2d@megapath.net>

Show all headers | View raw


On 10.05.2015 00:49, Thomas D. Dean wrote:
> On 05/09/15 13:38, Axel Vogt wrote:
>
>> Not quite sure, what you want (or the proc should do), but for coding:
>
> The proc calculates the inductance of a coil wound on a rectangular form, where the diameter of the wire is small
> compared the smallest dimension of the form.  The dimensions are in meters:
>   a = largest cross section measurement
>   a1 = the smaller cross section measurement
>   b = the length of the coil
>   N = the number of turns
>
> I don't know the cost of operations in maple 15, but, it seems optimize can sometimes make things worse.
>
>  > restart; with(codegen);
>
>  > read "rectangle.mpl";
>  > opt_rect := optimize(rectangle,tryhard):
>  > cost(rectangle);
> 13 storage + 45 assignments + 21 divisions + 38 multiplications + 13 functions + 29 additions
>  > cost(opt_rect);
> 25 storage + 57 assignments + 10 divisions + 45 multiplications + 28 additions + 16 functions
>
>  > read "grover.mpl";
>  > opt_grovr:=optimize(grover,tryhard):
>  > cost(grover);
> 5 storage + 3 assignments + 26 additions + 67 multiplications + 14 functions + 39 divisions
>  > cost(opt_grovr);
> 16 storage + 16 assignments + 46 multiplications + 8 divisions + 23 additions + 12 functions
>
> Tom Dean
>
> grover := proc (a, a1, b, N)
> description "Inductance of a single layer solenoid wound on a rectangular form. From Grover.  Dimensions in meters. a =
> largest cross section measurement.  a1 = the smaller cross section measurement.  b is the length of the coil.  N is the
> number of turns";
> local g, g2, L;
>      g2 := a^2 + a1^2;
>      g := sqrt(g2);
>      L := 10^(-4)*(1/125) * N^2 *a *a1/b
>      * ( (1/2)*(b/a1)*arcsinh(a/b)
>          + (1/2)*(b/a)*arcsinh(a1/b)
>          - (1/2)*(1 - a1^2/b^2)*(b/a1)*arcsinh(a/(b*sqrt(1+a1^2/b^2)))
>          - (1/2)*(1 - a^2/b^2)*(b/a)*arcsinh(a1/(b*sqrt(1+a^2/b^2)))
>          - (1/2)*(a1/b)*arcsinh(a/a1)
>          - (1/2)*(a/b)*arcsinh(a1/a)
>          + Pi/2
>          - arctan(a*a1/(b^2*sqrt(1+g2/b^2)))
>          + (1/3)*(b^2/(a*a1))*sqrt(1+g2/b^2)*(1-(1/2)*g2/b^2)
>          + (1/3)*b^2/(a*a1)
>          - (1/3)*b^2/(a*a1)*sqrt(1+a^2/b^2)*(1-(1/2)*a^2/b^2)
>          - (1/3)*b^2/(a*a1)*sqrt(1+a1^2/b^2)*(1-(1/2)*a1^2/b^2)
>          + (1/6)*b/(a*a1)*(g^3 -a^3 -a1^3)/b^2
>        ) ;
> end proc:
>
>

Usually 'tryhard' works fine. It never checks the cost of a function.

PS:
I think you can do a bit more in your proc, for example some division
occure often, dito squares. But it may depend on what you want to 'see'.

Back to comp.soft-sys.math.maple | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Simplify Difficulty "Thomas D. Dean" <tomdean@speakeasy.org> - 2015-05-09 12:13 -0700
  Re: Simplify Difficulty Axel Vogt <&noreply@axelvogt.de> - 2015-05-09 22:38 +0200
    Re: Simplify Difficulty "Thomas D. Dean" <tomdean@speakeasy.org> - 2015-05-09 15:49 -0700
      Re: Simplify Difficulty Axel Vogt <&noreply@axelvogt.de> - 2015-05-10 13:30 +0200
  Re: Simplify Difficulty Joe Riel <joer@san.rr.com> - 2015-05-10 08:50 -0700
    Re: Simplify Difficulty "Thomas D. Dean" <tomdean@speakeasy.org> - 2015-05-10 17:10 -0700

csiph-web