Discussion:
trivial calculator problem
Svjatoslav Agejenko
2021-05-03 00:10:47 UTC
Permalink
Hello !

I'm want to have arbitrary calculators to design electronics circuits.
Idea is that I enter the formula and known values and let computer
to calculate the missing part.

I'm hopelessly stuck with Axiom/FriCAS in this trivial case:
(I tried both)


frequency == 10 -- Hz
impedance == 53 -- Ohm

solve(impedance = 1 / (2 * %pi * frequency * capacitance))


I get result:

1
(3) [capacitance= ------]
106%pi

Can you please tell, how can I get result as floating point value
instead ?





Also question: I red that FriCAS is supposedly refactored and improved
version of AXIOM. Are there any reasons for sticking with AXIOM ?
Is there some disagreement in the community which one is better ?






FYI: I also implemented this calculator in Maxima like this:
-------------------------------------------------------
eq: impedance = 1 / (2 * %pi * frequency * capacitance);

_frequency: 1; /* Hz */
capacitance: 1E-6; /* Microfarad */
impedance: 53; /* Ohm */

if not ?boundp('frequency) then print(float(solve(''eq, frequency)));
if not ?boundp('capacitance) then print(float(solve(''eq, capacitance)));
if not ?boundp('impedance) then print(float(solve(''eq, impedance)));
----------------------------------------------------

By commenting out variable I want to compute and setting appropriate
values for remaining variables I got needed result. The problem
with Maxima was that it started crashing or more complicated formulas.



Best regards
--
Svjatoslav Agejenko
XMPP/Jabber: ***@xmpp.jp
Radio: ES1SVJĀ 
WWW: http://svjatoslav.eu
Ralf Hemmecke
2021-05-03 06:30:48 UTC
Permalink
Post by Svjatoslav Agejenko
solve(impedance = 1 / (2 * %pi * frequency * capacitance))
1
(3) [capacitance= ------]
106%pi
Can you please tell, how can I get result as floating point value
instead ?
(12) -> res := solve(impedance = 1 / (2 * %pi * frequency * capacitance))

1
(12) [capacitance = --------]
1060 %pi
Type: List(Equation(Expression(Integer)))

Look at the result type. You take the first of this list.

(13) -> res.1

1
(13) capacitance = --------
1060 %pi
Type: Equation(Expression(Integer))

and the right-hand side of it.

(14) -> rhs(res.1)

1
(14) --------
1060 %pi
Type: Expression(Integer)

Unfortunately, conversion to Float does not work directly. But you can
do it via

(16) -> rhs(res.1)::Expression(Float)

(16) 0.0003002923_4545640629_39
Type: Expression(Float)
(17) -> rhs(res.1)::Expression(Float)::Float

(17) 0.0003002923_4545640629_39
Type: Float

Or convert first to a list of equations over floating point expressions

(18) -> fres := res :: List(Equation(Expression(Float)))

(18) [capacitance = 0.0003002923_4545640629_39]
Type: List(Equation(Expression(Float)))

and then single out the parts as above.
Post by Svjatoslav Agejenko
Also question: I red that FriCAS is supposedly refactored and improved
version of AXIOM. Are there any reasons for sticking with AXIOM ?
That depends on what you want. AXIOM follows another development
direction than FriCAS. Most probably for what you are doing either of
the two alone is sufficient. They share a very big code base.
Post by Svjatoslav Agejenko
Is there some disagreement in the community which one is better ?
The disagreement was rather in the way how further development on the
system should be done. Choose one and be done. The respective developers
will certainly favour their own system, otherwise they would not develop
different forks. So you should rather ask other users of the system why
they prefer this or that system.

Ralf
Arthur Norman
2021-05-03 07:01:24 UTC
Permalink
Just to add to the options, since Macsyma was mentioned too

With Reduce (available via sourceforge) I can try

on rounded;
precision 5;
equation := impedance = 1/(2*pi*frequency*capacitance);
capacitance := 1.0e-6;
if not numberp impedance then first solve(equation, impedance);
if not numberp frequency then first solve(equation, frequency);
if not numberp capacitance then first solve(equation, capacitance);
end;

and my output is then

12


0.159155
equation := impedance=-----------------------
capacitance*frequency


capacitance := 0.000001


159155.0
impedance=-----------
frequency


159155.0
frequency=-----------
impedance



=====

I think that from outside the immediate community I would characterise
Axiom/Fricas as a sensible choice for those concerned with avoiding
getting wrong answers because of "special cases" or slips that could
emerge from failing to be aware of the detailed mathematics theories and
structures that underpin a calculation. Axiom rather than Fricas may
especially appeal to those who want to ability to inspect its (literate)
source and based on that check and follow through everything it does so
that they can formalise a justification of the correctness of its results.

Arthur

Loading...