0
$\begingroup$

I have a formula which cannot be expressed in terms of y.

fv = (p (1 + r) (-1 + (1 + r)^m) ((1 + r)^(m y) - (1 + x)^y))/
      (r (-1 + (1 + r)^m - x)) + c (1 + r)^(m y)

I'd like to solve it numerically with some kind of matrix operation.

For example

with

r = 0.05/12
m = 12
p = 1000
x = 0.03
c = 2000
fv = 92988.93

Can this be done with linear algebra, or is an iterative approach necessary?

Wolfram Alpha is not giving any clues for a matrix solution. Maybe some gradient descent program is required.

enter image description here

$\endgroup$
5
  • $\begingroup$ Can you please define what you mean by "solve it numerically"? It sounds like you are looking for an algorithm to do something. What are the inputs to the algorithm, and what is the desired output? $\endgroup$
    – D.W.
    Jan 27, 2023 at 23:35
  • $\begingroup$ Welcome to Computer Science! Note that you can use LaTeX here to typeset mathematics in a more readable way. See here for a short introduction. $\endgroup$
    – D.W.
    Jan 27, 2023 at 23:36
  • $\begingroup$ @D.W. I have solved before some simultaneous equations with a single-step formula obtained from matrix calculations. I just wonder if there is a computational technique for solving these formulae that can't be expressed in terms of a single variable. $\endgroup$ Jan 28, 2023 at 0:00
  • $\begingroup$ That doesn't answer my questions. $\endgroup$
    – D.W.
    Jan 28, 2023 at 0:08
  • $\begingroup$ @D.W. The inputs are r, m, p, c, x, fv and the expected output is y = 6. (Reals only) Iteration looks unavoidable. $\endgroup$ Jan 28, 2023 at 0:17

3 Answers 3

1
$\begingroup$

Linear algebra and matrices are not relevant here. Roughly speaking, they are useful when you have a system of linear equations. Here, you have a single equation, not a system of equations; and it is nonlinear.

If I understand correctly, given $p,m,\dots$, you are trying to find a value of $y$ that satisfies the equation. This equation can be written in the form

$$f(y) = 0$$

where $f$ is a function of $y$ (it also depends on $p,m,\dots$ but those are considered known constants). Here $f(y) = (p(1+r)\cdots) - fv$.

You can find an approximate solution to such an equation using an iterative algorithm, such as Newton's method. See https://en.wikipedia.org/wiki/Root-finding_algorithms.

$\endgroup$
1
  • $\begingroup$ I'm pretty sure Newton's is the way to go, thanks. $\endgroup$ Jan 28, 2023 at 0:21
2
$\begingroup$

From what I see, your equation has the form

$$A(1+a)^y+B(1+b)^y+C=0$$ where $a,b$ are small. Such a nonlinear equation cannot be solved analytically.

To find an approximate solution, you can write

$$0=A(1+a)^y+B(1+b)^y+C\approx A(1+ay)+B(1+by)+C$$ and solve for $y$. An even better approximation comes from

$$0=A(1+a)^y+B(1+b)^y+C\\\approx A\left(1+ay+a^2\frac{y(y-1)}2\right)+B\left(1+by+b^2\frac{y(y-1)}2\right)+C$$

which is quadratic in $y$ (by the generalized binomial formula).

Then you can refine with Newton's method. Few iterations will be needed.

$$y\leftarrow y-\frac{A(1+a)^y+B(1+b)^y+C}{A\log(1+a)(1+a)^y+B\log(1+b)(1+b)^y}.$$

$\endgroup$
1
  • $\begingroup$ Very useful, thanks. $\endgroup$ Feb 2, 2023 at 13:51
0
$\begingroup$

Newton-Raphson solution for n

Need to find a root for this formula with one unknown, n

(p ((1 + r)^n - (1 + x)^n))/(r - x) + c (1 + r)^n - fv = 0

Using the algorithm here: https://en.wikipedia.org/wiki/Newton%27s_method#Code

This method requires the derivative of the formula.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.