Search code examples
maxima

Understanding simple solve equation output from Maxima


I am a beginner, so I need some basic help, understanding how to configure Maxima to give me the desired output.

I have a simple formula: K_n = K_0 * (1 + r)^n

I am trying to find n, so in Maxima I type the following:

float (solve (575.12=550*(1+0.015)^n))

This gives me:

[203.0^n=1.045672727272727*200.0^n]

I know the solution is 3 but how am I to understand the output from Maxima?

Another example, with the same formula, trying to find r is:

solve (1905.01=1400*(1+r)^12), numer

And the result is: very long result from Maxima

If I use float() instead of numer, I get the correct result, but I am only interested in the final result from Maxima. r=0.026

float (solve (1905.01=1400*(1+r)^12));

Output: r=0.026 is the last result out of 11 results

How can I configure Maxima to output simple decimal solutions?

In another question, How to approximate a number to a n number of decimal places?, one of the answers suggest using fpprintprec to control how many digits are printed but it does not work for me. I get the same result. I have also tried to use the function given in https://stackoverflow.com/a/46510883/205696. decimal_places is sometime useful but does not help me in the first case posted here.

I am using:

wxMaxima: 19.05.7
wxWidgets: 3.1.2
Unicode Support: yes
Maxima version: 5.43.0 (x86_64-apple-darwin13.4.0)
Lisp: SBCL 1.5.3

Solution

  • I find the it's usually a lot better to substitute numbers at the end instead of giving numbers to solve. Thus:

    (%i1) solve(kn=k0*(1+r)^n,n);
                                            kn
                                        log(--)
                                            k0
    (%o2)                        [n = ----------]
                                      log(r + 1)
    

    Then substitute the numbers you want. In this case kn=575.12, k0=550, and r=0.015:

    (%i2) subst([kn=575.12,k0=550,r=0.015],%o2);
    (%o2) [n = 2.999637237374912]
    

    But as Robert says, if you're just looking for a real root, use find_root.