Sunday 31 October 2021

Javascript find intersections given two functions

I am trying today to solve for the coordinates where functions intersect. I am using the nerdarmer library right now, but it only returns only one solution out of all the possible solutions. For example, I want the code below to print -1, 0, 1 but it only outputs 0. Another example is if I want to find intersections between y = 0 and sin(x), I want the output to be ..., (-2pi, 0), (-pi, 0), (pi, 0), (2pi, 0), (3pi, 0), ...

intersect("x^3", "x")
function intersect(f1, f2){
    var x = nerdamer.solve('f1', 'f2');
    console.log(x.toString());  
}

Is there any way to get all the possible solutions?



from Javascript find intersections given two functions

No comments:

Post a Comment