Skip to main content

Interpolacja funkcji metodą Lagrange'a

Witam, zamieszczam kolejny programik napisany w javie - do czego służy widać z tytułu posta. Jest to kolejny projekt zaliczeniowy przy czym przy jego tworzeniu najważniejsze było zrozumienie algorytmu jego działania. W związku z czym nie zamieszczam całości kodu, a jedynie kod obsługi przycisku "Oblicz":

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:

    //pobieram ilość elementów które powinienem pobrać z tablicy

    wielkosc = jSpinner1.getValue( ).hashCode( );

    x = Double.valueOf(jTextField1.getText( ));

    Double iloczyn = 1D;

    Double suma = 0D;

    //tablice tymczasowe

    Double[ ] X = new Double[wielkosc];

    Double[ ] Y = new Double[wielkosc];

    //wczytywanie danych z komponentu do tablicy

    for (int i = 0; i < wielkosc; i++) {

      Y[i] = Double.valueOf(jTable1.getModel( ).getValueAt(i, 1).toString( ));

      System.out.println("i " + i + "y = " + Y[i]);


    for (int i = 0; i < wielkosc; i++) {

      X[i] = Double.valueOf(jTable1.getModel( ).getValueAt(i, 0).toString( ));

      System.out.println("i " + i + "x = " + X[i]);


    for (int i = 0; i < wielkosc; i++) {
      iloczyn = 1D;

      for (int k = 0; k < wielkosc; k++) {
        if (i != k) {
          iloczyn *= (x - X[k]) / (X[i] - X[k]);

          System.out.println("x " + x);

          System.out.println("k " + k + " = " + X[k]);

          System.out.println("i " + i + " = " + X[i]);

          System.out.println("iloczyn " + iloczyn);

      suma += Y[i] * iloczyn;

      System.out.println("suma " + suma);

    jTextArea1.append("wynik" + suma +"\n");

Kod wygenerowany za pomocą programu: Code Generator


Popular posts from this blog

How to simulate slow connection (developer proxy in Node.js)

Update: If you use Chrome then you can use "Throttling" so simulate slow network for all your assets. This should be easier than proxy.

Toggle device modeChoose Network type.Refresh the page 


For some time I wanted to use some proxy for development and testing of eg. slow internet connection, but it was hard to find something useful and free. I know there is Charles but buy it to use it at most one in a month is not for me.

I started thinking about Node.js, maybe I can write proxy for me? But fortunately I found one.

With this module I can write really short code to create slow server:

var http = require('http'), httpProxy = require('http-proxy'); httpProxy.createServer(function (req, res, proxy) { var buffer = httpProxy.buffer(req); setTimeout(function () { proxy.proxyRequest(req, res, { host: 'localhost', port: 8080, …

Course Review: The Bitfountain iOS 8 with Swift Immersive

This is second big iOS learning project. For first one read iOS Programming book review. As I only have two of them done I have to compare them somehow.

I am mindful that it took me a really long time to finish it (since last autumn). For a couple of months this year I didn't even have the internet to learn it, so it could not be helped. But last half of the June I've spent watching the videos every day and managed to finish it before any new internet problems.

So how was it?
In my opinion, it's great if you're starting out. There are a lot of basics, and seeing how to do things in XCode just makes your learning much easier than looking at the photos in the book. On the other hand, learning is more shallow and it is much easier to just follow the videos and learn only the basics without bigger picture about iOS SDK. I somehow missed more challenging exercises (even though I don't like to do them ;)

Course it pretty long but many videos are quite short (1-2…