Results 1 to 1 of 1

Math Help - (wx)Maxima self-adjusting for/while/etc

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    7

    (SOLVED) (wx)Maxima self-adjusting for/while/etc

    Hello

    I didn't know how exactly to name the thread, so this is the result. First, I'd like to issue a warning as this will be quite a long post(!), I'll try to explain as best I can.
    I'll post what I have first and then explain:

    Code:
    for n:1 thru N do
     for a:0.1 step 0.1 thru dB do
      for sc:0 step inc do
       while A(%i*sc)<=a do
        if not A(%i*(sc+inc))>a then
         print(float(sc)),scale:sc, inc:0.0001,
          for sc:scale step inc do
           while A(%i*sc)<=a do
            if not A(%i*(sc+inc))>a then
             (print('A(s),"=",float(A(%i*sc))," ; ",'𝜔,"=",float(sc)),inc:0.1,sc:float(sc) );
    I'm trying to find the scaling factor (𝜔, or sc) for a Bessel filter according to order (N) and attenuation (dB) at corner-frequency with the help of the amplitude formula A(s) (it doesn't matter how this is, it works by itself). The values would then be used to generate a curve-fit formula so I wouldn't have to do this whole ordeal for any random value of dB *and* N. This will be used in LTspice, to avoid tables with their obvious limitation(s).
    Now, this would be straight-forward like this (for N only):

    Code:
    for sc:guess step inc while A(%i*sc)>=dB do
     (if not A(%i*(sc+inc))>=dB then
      (scale:sc, print('A(s),"=",float(A(%i*sc))," ; ",'𝜔,"=",float(sc),
    " ; ",'A(s+inc),"=",float(A(%i*(sc+inc)))," ; ",'𝜔,"=",float(sc+inc))) ) $
    which calculates A(s) with increment "inc" starting from guess value "sc:guess". I had patience to do this for dB from 0.1 to 2 and N=2, and a separate one for N from 1 to 12, but the results differ, the curve-fit formulae don't have N *and* dB both as variables.
    Now, I would like the results to be pretty accurate, so inc=0.0001 but, since that will take quite a while to find the 12 values for up to N=12, I'm trying to dynamically adjust "inc" in between iterations.
    So, first: N=2 (1 has no scaling), dB=0.1 and inc=0.01 and start from sc:guess(=0) . This goes very fast. When it reaches a value less than dB, inc should go from 0.01 > 0.0001 and sc=<found value> ("scale"). The value is (very) close enough from the desired one and I can "fine-tune" it with 0.0001 to my goal. That being done, inc should switch back to 0.01 and sc=scale. The loop should go back with the new values and increment a=a+0.1 and start over, then, once a=dB, it should go a step back to N=N+1, and start over. I hope I explained to be understood, my English isn't perfect...
    So, in short, I'd like this to behave like a TV where you search for new channels, from scratch: first it goes in large steps then, when it finds itself close to something, it adjusts the step to a smaller one, then again.

    The first code block shows what I did and, running it gives:

    Code:
    Unable to evaluate predicate -6.81356/log(10)<=a
    which tells me that either it didn't assign a:0.1 or the lines aren't "arranged" the lines properly. My logic tells me it should work, Maxima contradicts me. So, here it is, the problem. If anyone can help me, please do.


    Thank you for your patience,
    Vlad.

    EDIT:
    While I was waiting for an answer I did everything manually. I got the desired formula which is very close to what I need. I still don't know why the loop(s) do(es)n't work, but for now they're not needed anymore.
    Last edited by bubulescu; April 19th 2010 at 12:24 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Adjusting Probabilities To Match Empirical CDF
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: October 28th 2010, 09:21 AM
  2. Replies: 2
    Last Post: April 27th 2010, 10:34 PM
  3. Maxima
    Posted in the Math Software Forum
    Replies: 6
    Last Post: March 14th 2010, 05:54 AM
  4. Adjusting a sample for population size
    Posted in the Statistics Forum
    Replies: 1
    Last Post: September 23rd 2009, 02:11 PM
  5. adjusting a clock
    Posted in the Math Topics Forum
    Replies: 1
    Last Post: March 1st 2008, 10:03 PM

Search Tags


/mathhelpforum @mathhelpforum