1

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
dotnetCarpenter
  • 10,019
  • 6
  • 32
  • 54
  • 1
    To get just a single, real (not complex), numerical solution for an equation, try `find_root`. E.g. `find_root(575.12=550*(1+0.015)^n, n, 1, 100)` or `find_root(1905.01=1400*(1+r)^12, r, 1e-6, 1)`. – Robert Dodier Feb 27 '23 at 19:09

1 Answers1

1

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.

Raymond Toy
  • 5,490
  • 10
  • 13
  • Thanks! I did not know that I can get Maxima to give me the solution with only variables. I'm learning CAS from TI Nspire (but do not have the software), so I'm kind of guessing my way through Maxima from what I learn in Nspire. Your answer will be of great help going forward! – dotnetCarpenter Mar 09 '23 at 09:30
  • 1
    Consider entering "? " for help related to "". For example "? solve" gives some nice examples. Or read the user's manual online at https://maxima.sourceforge.io/docs/manual/maxima_toc.html – Raymond Toy Mar 10 '23 at 05:29