Hello Stefan,
I guess by your name and email adress that you’re from austria
so you could read and understand German.
I took lecture notes last year in a Numerics course here at the
university of Jena and implemented nearly all of the algorithms
using J, with coloured J lines interspersed with the notes.
(typeset with LaTeX and the minted package)
I used explicit code in some places but most of it is tacit
and thus without for. style loops. But of course there need
to be ^: style loops in many places.
EDIT: I just did a /for\. search and it turned out I didn’t
use it at all
For example, the line for the newton representation of the
lagrange polynomial reads
Newton =: 1 : ’[: +/ (nbase pmul u divdiff)\’ NB. pmul aus Beispiel 1.40
where 1.40 is a clickable back-reference. All the other names
have been defined in the current section.
Up to that point there are no explicit definitions at all.
If you’re interested, I’ll ask if I may send you the pdf file
(I guess it will be okay) in case you’re interested.
cheers,
Hauke
Am 15.10.20 um 15:50 schrieb Stefan Baumann:
Dear all.
Recently I stumbled upon the Newton polynomial and took it as a practice to
implement it without using loops, but failed. I first didn't get a grab on
how to create the matrix used in
https://en.wikipedia.org/wiki/Newton_polynomial#Main_idea, and eventually
came up with code following
https://en.wikipedia.org/wiki/Newton_polynomial#Application:
NB. Newton polynomial
np=: 4 : 0
a=. {. y
for_i. }.>:i.#x do.
y=. (2 (-~)/\ y) % i ({:-{.)\ x NB. Divided differences
a=. a, {. y NB. Coefficients are the topmost entries
end.
NB. Convert the summands aᵢ(x-x₀)…(x-xᵢ₋₁) of the polynomial
NB. from multiplier-and-roots to coefficients form and add them up
+/@,:/ p."1 (;/a) ,. (<''), }:<\ x
)
x=: _3r2 _3r4 0 3r4 3r2
y=: 3&o. x
load'plot'
load'stats'
plot (];(x np y)&p.) steps _1.5 1.5 30
I also tried replacing the loop with fold F:. but again was not able to do
so. Anyone out there who can enlighten me?
Many thanks. Stefan.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
----------------------
mail written using NEO
neo-layout.org
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm