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

2016-07-02 Thread Miguel Ruiz

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 = 866. / (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 = 866. / (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 = 866. / (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.




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

2016-07-02 Thread Miguel Ruiz

Not optimal solution:

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

yields

#+RESULTS:
#+BEGIN_SRC calc
[r = 866. / (4621.24711316 - 2517.12631405 s2), v = 
4621.24711316 - 2517.12631405 s2]

#+END_SRC

Manually add :var clause in the results block as follows

#+RESULTS:
#+BEGIN_SRC calc :var var-s2=1
[r = 866. / (4621.24711316 - 2517.12631405 s2), v = 
4621.24711316 - 2517.12631405 s2]

#+END_SRC

And finally the modified results block is evaluated

#+RESULTS:
: [r = 41157332.8093, v = 2104.12079911] ; var-s2=1

and

#+RESULTS:
: [r = 12131615.2598, v = 7138.37342721] ; var-s2=-1

Any improvement will be appreciated.

Miguel.




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 = 866. / (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 = 866. / (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 = 866. / (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.




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

2016-06-26 Thread Miguel Ruiz

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 = 866. / (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 = 866. / (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 = 866. / (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.