HP Forums
How to get all solutions to e^x=1 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: How to get all solutions to e^x=1 (/thread-22316.html)



How to get all solutions to e^x=1 - townba - 09-12-2024 04:08 AM

I'm having trouble trying to find how to get the Prime to fully solve e^x=1. Complex is on, Principal is off.

When I try solve(sin(x)=0), I get {n_0*π}, which I expect. However, when I try solve(e^x=1), I get {0} instead of something like {2*i*n_0*π}. (For comparison, the HP 50g solves e^x as 2·i·π·n1.)

Is there a different function I should use?


RE: How to get all solutions to e^x=1 - townba - 09-16-2024 04:34 AM

I downloaded the source code for Giac and took a look. Looks like the n_0 approach is only used for trigonometric functions, so I'm not sure this is possible without a change to the CAS.

I hacked in a solution in solve.cc:

Code:

  static gen isolate_exp(const gen & e,int isolate_mode,GIAC_CONTEXT){
    if (isolate_mode &1) {
      if (isolate_mode &2){
        identificateur x(string("n_")+print_intvar_counter(contextptr));
        return ln(e,contextptr)+(x)*one_tour(contextptr)*cst_i;
      }
      else {
        return ln(e,contextptr);
      }
    }
    …

It works, though its output can be unwieldy for non-simplistic cases. (I suppose this could be true of the trig functions as well.)
  • solve(e^x=1) gives list[2*i*n_0*pi], which is what I was hoping to get.
  • sol := solve(e^(x^2)=1) gives a very long answer containing things like im(n_0) and re(n_0).
  • simplify(subst(sol, [im(n_0)=0, re(n_0)=n_1])) gives list[(1+i)*sqrt(-n_1*pi),(-1-i)*sqrt(-n_1*pi)], which is correct (-n_1 could be simplified as well). (I was a bit surprised that that particular subst approach works, but Giac/Xcas is awesome.)

I think this could be a nice approach, though this behavior change could be surprising. It might need a separate configuration setting and other work for it to be generally acceptable.