I am trying to solve the inverse problem for the following function in R.
x + 2 (C1 * y) + C1 * C1 * z = d2
I can currently enter C1 and get d2 but need to enter d2 and get C1. The variables x, y and z are all known and never change.
I already have some known C1 and d2 values to use.
C1 d2
5 0.000316
0 0.000193
-5 0.000123
Is there an R function which will allow me to enter the function, previous results and a d2 value and for it return the C1 coefficient?
You have a quadratic equation of the form:
You can solve quadratics (and in fact any polynomial equation) with the function
polyroot()in R:(Which gives two solutions, as you would expect)
To solve for a range of input values, you need to put this into your favourite
applyfunction, in this casesapply():