building an implicit equation as a contour graph is redundant. You essentially throw away 99.99% of the calculations you did.
It is best to find the y value for a given x that will make equation 0. Here is the code using uniroot in the R base.
R code using uniroot from the R base
x = seq(0, 0.995, length = 100)
Ok c (0, 3) in the uniroot argument is the range of y values ββwhere the root lies. therefore, for each given x value, uniroot will look for a y value from 0 to 3 for the root.
R code using fsolve from the pracma package
library("pracma") x <- seq(0,0.995, length=100) fun <- function(y) c(1 - 0.125 * y^2 - x^2 - 0.005) y_sol <- fsolve(fun, rep(1, length(x)))$x plot(x,y_sol, type="l")
fsolve takes a function whose root is the desired one and guesses the y values ββfor each given x value. Here we say that the values ββof y lie near 1. We give it the value of assumption 1
uniroot wants the related range to look for root, fsolve needs to guess where the root may be.
These are faster ways to build implicit equations. Then you can use any graphics package, for example ggplot2 / rbokeh, to build a graph.
I have not done any tests, so I canβt say which one is faster. Although it does not matter for such a simple implicit function.
MySchizoBuddy
source share