50 questions
1
vote
1
answer
64
views
Wrong function call when solving for steady state using julia's NonlinearSolve
I am using NonlinearSolve to solve a steady state problem. When I do
prob = SteadyStateProblem(eoms!, σ₀, p)
sol = solve(
prob,
SSRootfind(),
abstol = slv.abstol,
reltol = slv.reltol,
)...
1
vote
1
answer
185
views
SiCP Exercise 1.45
Update: I changed the argument 1 in nth-root to 1.0, and then it works.
Why are they different?
Here's my original question.
I have
(define tolerance 0.00001)
(define (fixed-point f first-guess)
(...
0
votes
0
answers
93
views
How to minimize two functions at the same time with common variables
I am trying to find the roots of three equations, and currently I am using minimize from scipy.
from scipy.optimize import basinhopping
import numpy as np
def get_attraction(b1,b2, b3):
c1 = 20 * ...
0
votes
0
answers
112
views
Find non-negative roots of a system of equations using Scipy optimize.root
I am trying to find the fixed points f(x)=x. I transform it to find the root of g(x)=f(x)-x.
from scipy.optimize import root
import numpy as np
def get_attraction(b1,b2, b3):
c1 = 20 * b1 + 12 * ...
0
votes
2
answers
1k
views
How to Make Python Print something at nth Iteration within a For Loop?
I want to preface my question by saying that I am very new to Python and have only started using it for a specific class in grad school.
I have written a script to find the root of a function using ...
12
votes
1
answer
330
views
How to implement fixed points of functors in Java
I recently discovered how to simulate higher order types in Java in a somewhat roundabout way like so
interface H<F, T> { }
Here H encodes a higher order type that takes a type parameter F ...
2
votes
2
answers
7k
views
Express a "case ... of" pattern more elegantly in Haskell
I came across a pattern which I believe can be expressed more elegantly:
I have two functions f1,f2 :: Int -> Int (their impl. is not relevant), and a process :: Int -> Int which does the ...
2
votes
2
answers
272
views
How to verify in Fortran whether an iterative formula of a non-linear system will converge
How to verify in Fortran whether an iterative formula of a non-linear system will converge to the root near (x,y)?
It was easy for a programming language which support symbolic computations. But how ...
0
votes
1
answer
160
views
Questions conerning fixed point implementation of a moving window Newton-Raphson Method
Here is the reference post I am drawing upon: Any Faster RMS Value Calculation in C?
#define INITIAL 512 /* Initial value of the filter memory. */
#define SAMPLES 512
uint16_t rms_filter(uint16_t ...
4
votes
2
answers
232
views
How can I avoid <<loop>> in Haskell?
The program below results in <<loop>> in GHC.
...Obviously. In hindsight.
It happens because walk is computing a fixed point, but there are multiple possible fixed points. When the list ...
3
votes
1
answer
877
views
iteration using the secant method with a tolerance
I am trying to find out how many iterations it takes when I run a secant iteration up to a certain tolerance in maple. However, I am receiving an error code, so if someone could point out where the ...
0
votes
1
answer
323
views
Fastest way to compute large amount of fixed points in python?
I have a large amount of one-dimensional nonlinear fixed point problems to solve, what is the most efficient numerical solver? I'm currently using scipy.optimize.fixed_point, it takes around 17s to ...
2
votes
0
answers
136
views
How to avoid taking negative base of power function during the problem solving process using NLsolve in Julia?
I am a Julia beginner. I would like to solve the following non-linear equation using nlsolve.
#Variables
D= 200 #number of dimension
w= [0.17935458155165915; 0.02074763117110885; 0.429373018098153; ...
4
votes
1
answer
11k
views
Fixed point iteration in Python
Im beginner at Python and I have a problem with this task:
Write a function which find roots of user's mathematical function using fixed-point iteration.
Use this function to find roots of: x^3 + x - ...
1
vote
0
answers
345
views
How to find fixed points or find the stationary points (numerically) in this system with Matlab?
I hope help me in this problem.
I like find the fixes point in this system.
I wrote a code in Matlab as follow:
clear all;
close all;
clc;
%
tic;
rand('state',sum(100*clock)); % seed
%
numreps=2; % ...
1
vote
1
answer
604
views
Minizinc: how can I make the union of a set in this situation (fix point algorithm?)
I have an array of sets that means that the items inside the set must finish before the actual one starts. For example:
before = [ {},
{1},
{},
{},
{2}];
I'm looking to make ...
2
votes
2
answers
136
views
Haskell: monadic fixpoint on RWS is looping if traversing on argument
I am writing a program which involves RWS for tracking mutable state and producing some log. My purpose is to define a computation that evaluates some action, gathers the aftercoming state and ...
1
vote
2
answers
120
views
Find root with Newton's method
I write the newton-method to find root from Scheme example in elisp as
#+begin_src emacs-lisp :session sicp :lexical t
(defun deriv(g)
(lambda (x)
(/ (- (funcall g (+ x dx)) (funcall g x))
...
1
vote
3
answers
128
views
The inner `try` interation in `fixed-point`
I am reading the fix-point of SICP:
#+begin_src emacs-lisp :session sicp :lexical t
(defvar tolerance 0.00001)
(defun fixed-point(f first-guess)
(defun close-enoughp(v1 v2)
(< (abs (- v1 v2)...
7
votes
2
answers
1k
views
Find fixed point of multivariable function in Julia
I need to find the fixed point of a multivariable function in Julia.
Consider the following minimal example:
function example(p::Array{Float64,1})
q = -p
return q
end
Ideally I'd use a ...
0
votes
0
answers
245
views
Fixed point recursion MATLAB
I am not sure if I have come across a trick question or not, but I am coding a fixed point recursion to find root for a given equation. To me, it seems like I have the answer right off the bat, but I ...
-4
votes
3
answers
12k
views
Solve this equation with fixed point iteration method in python [closed]
f(x) = x^2- 2x - 3 = 0
How can I solve this equation non-linear, and used fixed point iteration method in Python ?
0
votes
1
answer
285
views
Horn clauses with multiplication in Z3
I've just started digging into Z3's fixed point solver and I've cooked up an example that hangs when using multiplication but completes when defining multiplication as a series of additions. As I'm ...
1
vote
0
answers
221
views
Break-Point Implementation for Fixed-Point Iteration for System of Equations in Javascript
const x = new Array(3).fill(0)
const x0 = new Array(3).fill(0)
const er = new Array(3).fill(0)
const C = [1, 1, 1];
for (let j = 0; j < 1000; j++) {
for (let i = 0; i < C.length; i++) {
...
5
votes
1
answer
444
views
How to write a fixed point function in haskell
I have a function with the following signature:
simCon :: [Constraint] -> Maybe [Constraint]
I would like to write a method which, incase simCon returns Just [Constraint], I want to feed them ...
2
votes
1
answer
366
views
An OCaml function for finding fixed points
I have an OCaml function for finding fixed points:
>> let rec fix f x =
let x' = f x in
if x = x' then x else fix f x';;
(system message) val fix : ('a -> 'a) -> 'a -> 'a = ...
1
vote
1
answer
960
views
Converting explicit euler to implicit euler (via fixed-point iteration)
So I have a school task where I need to calculate the position of a bunch of cars following each other on a road (AKA driving in a line, so if Car 10 [the car that is first in line] brakes, then Car 9 ...
0
votes
0
answers
397
views
MATLAB - Fixed point iteration
I'm trying to figure out how to create a function for fixed point iteration. But I have been stuck on this for a good hour now and I am finally caving in.
So what am I doing wrong?
I would suspect ...
2
votes
2
answers
1k
views
Find a fixed point with only one input (an array) for the function
I am trying to find a fixed point in an array using a function that only accepts one input (an array). The problem is, I'm trying to avoid building another function that this function can call. If I ...
1
vote
0
answers
581
views
Fixed-Point Iteration Mathematica
This is a mathematica code for fixed point iteration.
expr={1,0,9999};
f[{i_,xi_,err_}]:=(xipp=0.2062129*(20+(2*xi))^(2/5);
{i+1,xipp,Abs[(((xipp-xi)/(xipp))*100)]});
NestWhileList[f,expr,#[[3]]&...
6
votes
0
answers
345
views
There is a function that searches for an attractive fixed point through iteration. Can we generalize it to monadic functions?
Intro
Fixed points are such arguments to a function that it would return unchanged: f x == x. An example would be (\x -> x^2) 1 == 1 -- here the fixed point is 1.
Attractive fixed points are ...
3
votes
2
answers
766
views
How do I iterate until a fixed point in Clojure?
I'm frequently in the position that my code reads like so:
(iterate improve x)
And I'm looking for the first value that no longer is an improvement over the previous. Neither filter nor take-while ...
5
votes
3
answers
1k
views
Is there a fixed point operator in Haskell?
I recently noticed that I quite often write functions which just iterates another function f until it reaches a fixed point (such that f x == x)
I thought this is a pretty general concept, so I think ...
11
votes
3
answers
1k
views
How to find the fixed points of a simple mod function elegantly?
Here is a function, which expressed in C is:
uint32_t f(uint32_t x) {
return (x * 0x156) ^ 0xfca802c7;
}
Then I came across a challenge: How to find all its fixed points?
I know we can test ...
0
votes
0
answers
293
views
MatLab fixed point method to find the root of a function as an input
I've trouble creating a code for finding roots of a function as an input by the fixed point method,
Here I've done it using Newton-Raphson method:
clc,close all
syms x;
fprintf('Newton Raphson\n');
...
2
votes
1
answer
872
views
Fixed point theory and the isGoodEnough function
In Coursera course Functional Programming Principles in Scala, the Lecturer talks about the Fixed Point and wrote some simple implementation of it.
def isCloseEnough(x: Double, y: Double) =
math....
0
votes
1
answer
564
views
R fixed point of a function
I am looking for a fixed point x when f(x)=x of a function, ofcourse numerically, but I have no idea how to solve it with R, I am trying with fsolve with following code, but possibly its not the right ...
2
votes
1
answer
78
views
Matlab optimiziation where objective is implicitly given by a fixed point equation
I have the following problem:
max CEQ(w) s.t. w in (0,1) and I don't know anything about CEQ(w) except that is given by a fixed point equation of the form CEQ(w) = F(CEQ(w)). If I fix a w, I can ...
1
vote
1
answer
2k
views
solve equation using fixed point in scilab?
I have a equation f(x)=exp(x)+3x^2, f(x)=0, x=? then I use scilab to solve that equation using fixed point iteration this is my code
function fixed_point(fung,x0,err)
x=zeros(100);
ea = 100;
i = 1;
x(...
-3
votes
1
answer
3k
views
Stopping criteria matlab iteration
I want to add an While-loop to my matlab-code so that it will stop when the iteration is good enough. With some kind of tolerance, eg. 1e-6.
This is my code now. So i need to add some kind of ...
4
votes
4
answers
1k
views
What is fixed point?
I'm rewatching some of the earlier lectures on SICP. The notion of a fixed-point is a bit confusing to me. The fixed-point procedure: should I be thinking about it this way, "it's the way to find a ...
4
votes
2
answers
3k
views
Fixed point in Scala
Is there a shortcut for the following code snippet?
while (true) {
val newClusters = this.iterate(instances, clusters)
if (newClusters == clusters) {
return clusters
}
clusters = ...
1
vote
4
answers
4k
views
Finding the fixed points of a function
I am trying to find the fixed point of a logistic distribution function and determine how the fixed point changes for different parameter values. The code looks like:
nfxp.reps <- 0
err <- 10
p ...
1
vote
1
answer
2k
views
Ocaml fixed point implementation
I'm trying to figure out how to implement fixed point iteration in Ocaml. That is, given a function f and an x, I want to calculate what the final value of what f(f(f(x)...)) will be.
So for example,...
14
votes
5
answers
5k
views
Fixed point combinator in Haskell
The fixed point combinator doesn't always produce the right answer given the definition:
fix f = f (fix f)
The following code does not terminate:
fix (\x->x*x) 0
Of course, fix can't always ...
6
votes
1
answer
234
views
haskell -- set fixedpoint library?
I'm looking for a library that will compute the fixed point / closure of a set under a number of operators of variable arity. For example,
fixwith [(+)] [1]
for the integers should compute all of N (...
6
votes
4
answers
5k
views
Finding fixed points / attractors / repellors of a Tent map
I need to find fixed points and attractors of a Tent map function given by the definition below:
xt = (3/2) * xt-1 when 0 <= x <= (2/3)
and
xt = 3* (1-xt-1) when (2/3) ...
0
votes
3
answers
2k
views
Finding the Fixed Points of an Iterative Map
I need to find fixed points of iterative map x[n] == 1/2 x[n-1]^2 - Mu.
My approach:
Subscript[g, n_ ][Mu_, x_] := Nest[0.5 * x^2 - Mu, x, n]
fixedPoints[n_] := Solve[Subscript[g, n][Mu, x] == x, ...
0
votes
2
answers
4k
views
fixed point iteration algorithm
I am asked to write a program to solve this equation ( x^3 + x -1 = 0 ) using fixed point iteration.
What is the algorithm for fixed point iteration?
Is there any fixed point iteration code sample ...
9
votes
2
answers
11k
views
Solve this equation with fixed point iteration
How can I solve this equation
x3 + x - 1 = 0
using fixed point iteration?
Is there any fixed-point iteration code (especially in Python) I can find online?