Menu

#23 ITERATE(): some improvements

Next_Release
open
nobody
None
2
2018-12-21
2015-03-04
No

Hello, Jan.

Finally, I've tested the ITERATE() function at work. And now with this function iMath can do really huge calculations, e.g numerical integration of ordinary differential equations, for few seconds. Yes, it works!

You may open my file. It's similar to Euler method v0.39-RC.odt, that was posted earlier, but now it's solved with ITERATE(). On my PC with windows the startup recalculation takes 9-10 sec, then it may take 4-5 sec (was 7 minutes before). That's awesome! On Ubuntu it's twice faster (4-5 and 2-3 sec, maybe this is hardware issue, not OS)! Don't look at results, they are different, because there were another input parameters.

But it needs some improvements to be finished. This is not about ITERATE() itself, though.

  1. It needs GUI. Take a look at the "iterate.ods". The table form is ideal for ITERATE() function. I'm not sure I could write that in command line manually. So I can propose you new dialog for it soon.
  2. User-defined functions need to be able to have numerical values, like variables are. I had to make many auxiliary equations with substitutions to be able to get numbers in result and this was a headache. "f(x)" is not just like "sin(x)" in iMath, right? While we may print "f", it's strange that we may not get val(f).
  3. After all, it needs a short how-to. I can take care of it.
2 Attachments

Related

Feature Requests: #56

Discussion

  • zeon_account_will_be_deleted

    4.Would be nice to be able to insert one ITERATE() inside another ITERATE(). Do you remember my example with T_sm, alpha and C_pk? Such system of equations should be somehow solved on every single step:

    ITERATE(@1@; @2@; @3@; ITERATE(@T_sm@; @a@; @C_pk@, ...); @4@; @5@...)

    But this kind of code will do nothing, because ITERATE() returns a vector of values. Maybe there is some workaround?

     

    Last edit: zeon_account_will_be_deleted 2015-03-04
  • zeon_account_will_be_deleted

    Hi, Jan.

    I continue posting what I've found using ITERATE() in practice here, including things, that seem to be a bug. Just to not forget.

    In examples, that I post here, I've hidden a lot of unnecessary text and algorithm. If you want to see it, please check this option: Tools -> Options ->LibreOffece Writer ->Formatting Aids -> Display of ->Hidden text

    5.It's impossible to use numeric values of the variables after the ITERATE() in next calculations. Take a look at my comments.

     
  • Jan Rheinlaender

    Hi Vladislav,

    thank you for testing the ITERATE function.

    1. and 3. Yes it certainly needs a better GUI and explanation (that should be a section in iMath-tour.odt)
    2. I'm not totally sure where your problem is. Have you looked at section 3. in iMath tour about finding the value of the function with a double VAL() ?
    3. This is currently not possible because of the way that iMath works. ITERATE is a statement. Therefore it is evaluated at compilation time, which means the inner ITERATE will only be evaluated once because it is only compiled once. (Actually, "compiler" is the wrong name here. It should be called "interpreter").
      The work-around would be to define another statement like ITERATE2 which does a nested iteration. This would require a lot of parameters, of course.
    4. You are right, this is a bug. I will work on it
     
    • zeon_account_will_be_deleted

      Hi, Jan.

      1. ok
      2. To write and solve the ODE I should create several function definitions:
        %%ii FUNCTION {{none}, h, τ}
        %%ii FUNCTION {{none}, ρ_sm, h; τ}
        This is necessary to create derivatives, e.g. dh/dτ, which will not turn to 0 after "simplify(..., "diff")".
        The meaning of solving an ODE is that we do not know, how exactly all these variables are related (indirectly only). We have no algebraic equations for h(τ) and ρ_sm(h,τ), we can't find their numerical values. In the case of numerical methods we don't even receive algebraic equations at the end. We just solve the list of auxiliary equations n times and receive the numerical values of h1, h2, h3... hn. No FUNCDEF h(τ) -- no VAL(VAL(h(τ))
        I've corrected my example, I've added VAL(VAL(...)) to all equations inside the ITERATE(). As I expected, it doesn't help.
      3. This means a brand new function in iMath, right? Why a lot of parameters? Is it possible to upgrade current ITERATE()? Can you make, that all functions and statements inside the ITERATE(...) are not evaluated immediately, but collected into a solid algorithm, and then evaluated? I suppose, that other statements, like VAL(), DIFFERENTIATE(), will be halted too, and then evaluated on every iteration, that means a loss of performance. Maybe make an exception for ITERATE() only?
       

      Last edit: zeon_account_will_be_deleted 2015-03-09
  • zeon_account_will_be_deleted

    HI Jan!

    Is it possible to implement for ITERATE option to accept vector (actually list of data) as input parameter?

    I experimented with graphs and tried to plot a graph of a parametric function F(x,y)=0 that iMath cannot solve to type of y=f(x). So I tried to get values ov x and y using iterations. I've found, that I need one ITERATE string per one pair (x,y) of values. If you enhance ITERATE functionality to accept vectors, this would be much easier to create bulk iterative calculations.

    See example.

     
  • Jan Rheinlaender

    Should be possible in 2.2.7~beta2

     
    • zeon_account_will_be_deleted

      Well... something is going on, but LO is freezing during recalculation. I need to figure out what is wrong.

       

Anonymous
Anonymous

Add attachments
Cancel