emacs-orgmode
[Top][All Lists]

## Re: [O] Two numerical solutions from fsolve inside calc source block

 From: Miguel Ruiz Subject: Re: [O] Two numerical solutions from fsolve inside calc source block Date: Sat, 02 Jul 2016 13:30:05 +0200 User-agent: Roundcube Webmail/1.0.6

```Better yet:

#+begin_src calc :wrap "src calc :var var-s2=1"
fsolve([8.66e10 = r * v, -7.51e6 = 0.5*v^2 - 6.67e-11*6e24/r],[r,v])
#+end_src

El 2016-06-26 15:53, Miguel Ruiz escribió:
```
```Hi,

I have this block which is intended to get the two numerical solutions
of the equations system:

#+begin_src calc
fsolve([8.66e10 = r * v, -7.51e6 = 0.5*v^2 - 6.67e-11*6e24/r],[r,v])
#+end_src

This way I get the generic form of a multiple solution, and citing the
manual "It will invent variables n1, n2, …, which represent
independent arbitrary integers, and s1, s2, …, which represent
independent arbitrary signs (either +1 or -1)."

So I get

#+RESULTS:
: [r = 86600000000. / (4621.24711316 - 2517.12631405 s1), v =
4621.24711316 - 2517.12631405 s1]

Now, to get the two solutions I have to evaluate manually the result
expression replacing s1 by "*1" and "*-1"

#+begin_src calc
[r = 86600000000. / (4621.24711316 - 2517.12631405 *1), v =
4621.24711316 - 2517.12631405 *1]
#+end_src

#+RESULTS:
: [r = 41157332.8093, v = 2104.12079911]

And

#+begin_src calc
[r = 86600000000. / (4621.24711316 - 2517.12631405 *-1), v =
4621.24711316 - 2517.12631405 *-1]
#+end_src

#+RESULTS:
: [r = 12131615.2598, v = 7138.37342721]

Emacs calc manual states "Note that variables like n1 and s1 are not
given any special interpretation in Calc except by the equation solver
itself. As usual, you can use the s l (calc-let) command to obtain
solutions for various actual values of these variables.", but I cannot
figure out a way to call (calc-let) or its algebraic equivalent inside
a calc source block.

I can accept a only-elisp workaround if it is more convenient.

Any hint to do everything commented without user interaction?

Regards.
```
```

```