Post Reply 
Convert Foster Netowrk to Cauer
06-03-2024, 01:48 PM
Post: #1
Convert Foster Netowrk to Cauer
As part of the exercise with fitting the exponentials...
Those exponentials represent a "foster Network" a series connection of a bunch of parallel RC's.

https://www.mathworks.com/help/sps/ref/f...model.html

For various reasons, I want to convert them to a Cauer Network, a series connection of resistors with shunt C's.

https://www.mathworks.com/help/sps/ref/c...model.html

Matlab has a function to do this:
https://www.mathworks.com/help/sps/ref/e...oster.html

Which uses "Euclid Long Division", is this something I can do on the Prime?
Find all posts by this user
Quote this message in a reply
06-04-2024, 06:24 AM
Post: #2
RE: Convert Foster Netowrk to Cauer
Do I understand correctly - you mean continued fractions?
https://en.wikipedia.org/wiki/Continued_fraction
HP-Prime handles continued fractions well.
Regards
Find all posts by this user
Quote this message in a reply
06-04-2024, 01:29 PM
Post: #3
RE: Convert Foster Netowrk to Cauer
I am not sure if it is a continued fraction or not. I am not sure what "Euclid Long Division" is.

That is why I am asking.
Find all posts by this user
Quote this message in a reply
06-04-2024, 05:41 PM
Post: #4
RE: Convert Foster Netowrk to Cauer
So give me a simple numerical example.
Find all posts by this user
Quote this message in a reply
06-04-2024, 06:39 PM
Post: #5
RE: Convert Foster Netowrk to Cauer
All I have are the links. I don't have access to Matlab any more, so I can't get an example.
Find all posts by this user
Quote this message in a reply
06-04-2024, 09:08 PM (This post was last modified: 06-06-2024 08:52 AM by carey.)
Post: #6
RE: Convert Foster Netowrk to Cauer
(06-03-2024 01:48 PM)KeithB Wrote:  Which uses "Euclid Long Division", is this something I can do on the Prime?

For whatever it's worth, here's ChatGPT's response to a request to write code for the HP Prime's PPL programming language to implement "Euclidean long division."

Code:

EXPORT EuclideanLongDivision()
BEGIN
 LOCAL startTime, endTime, elapsedTime;
 LOCAL dividend, divisor, quotient, remainder;
  
  // Input dividend and divisor
  INPUT(dividend, "Euclidean Long Division", "Enter the dividend:");
  INPUT(divisor, "Euclidean Long Division", "Enter the divisor:");
  
  // Record the start time
  startTime := TICKS;

  // Check for zero divisor
  IF divisor == 0 THEN
    MSGBOX("Error: Divisor cannot be zero.");
    RETURN;
  END;

  // Initialize quotient and remainder
  quotient := 0;
  remainder := dividend;
  
  // Perform Euclidean long division
  WHILE remainder >= divisor DO
    remainder := remainder - divisor;
    quotient := quotient + 1;
  END;
  
 // Record the end time
  endTime := TICKS;

  // Calculate the elapsed time
  elapsedTime := endTime - startTime;

  // Display the result
  PRINT("Quotient: " + quotient);
  PRINT("Remainder: " + remainder);
  PRINT("Elapsed time: " + elapsedTime + " milliseconds");
  MSGBOX("Quotient: " + quotient + "\nRemainder: " + remainder +
 "\nElapsed time: " + elapsedTime + " milliseconds" );
END;

"To use this code:

1. Open the Program Editor on your HP Prime calculator.
2. Create a new program and name it `EuclideanLongDivision`.
3. Copy and paste the code above into the Program Editor.
4. Save the program.
5. Run the program, and it will prompt you to enter the dividend and the divisor. The quotient and remainder will be displayed as the result.

This code checks for division by zero and performs the Euclidean long division, displaying the quotient and the remainder at the end."

Good luck!
Find all posts by this user
Quote this message in a reply
06-04-2024, 11:26 PM
Post: #7
RE: Convert Foster Netowrk to Cauer
(06-04-2024 09:08 PM)carey Wrote:  For whatever it's worth, here's ChatGPT's response...

I hereby declare GodwAIn's law: as any discussion grows longer the probability of a response created using AI approaches 1.
Find all posts by this user
Quote this message in a reply
06-05-2024, 02:33 AM
Post: #8
RE: Convert Foster Netowrk to Cauer
(06-04-2024 11:26 PM)BruceH Wrote:  
(06-04-2024 09:08 PM)carey Wrote:  For whatever it's worth, here's ChatGPT's response...

I hereby declare GodwAIn's law: as any discussion grows longer the probability of a response created using AI approaches 1.

Better get used to it (and AI's jaw-dropping ability to generate dozens of lines of code in milliseconds).
Find all posts by this user
Quote this message in a reply
06-05-2024, 08:12 AM
Post: #9
RE: Convert Foster Netowrk to Cauer
Are you serious about this artificial intelligence or are you just joking?
After all, the above-mentioned the algorithm created by artificial intelligence is pathetic.
It is division with the remainder obtained by laborious subtraction of the divisor (sic!).
If you don't believe it, give him 1000000 and 3 - it will take a while.

But back to the topic, enough of this mockery.
Following the link:
https://www.mathworks.com/help/sps/ref/e...oster.html
I see a continued fraction and the word "Euclid".

It is known that a rational fraction can be expressed as a continued fraction.
The "numbers" of this continued fraction can be obtained using the Euclidean Algorithm.

And that's probably what it comes down to.

Simple numerical example:
35/16=?
Euclid's algorithm:
35 = 2*16 + 3
16 = 5* 3 + 1
3 = 3* 1 + 0 End

The numbers after the "=" signs (2,5,3) are the consecutive numbers of the continued fraction, i.e.:

35/16 = 2 + 1 / (5 + 1/3)
Write it down as a fraction on a piece of paper so you can see it better.

And now HP-Prime comes into action:

dfc(35/16) –> [2,5,3]

and vice versa:

dfc2f([2,5,3]) –> 35/16

Regards.

PS.
I have always said that with this artificial intelligence it is "much ado about nothing".
Find all posts by this user
Quote this message in a reply
06-05-2024, 11:41 AM
Post: #10
RE: Convert Foster Netowrk to Cauer
The CAS function iquorem returns a similar result as that chat GPT program, but way faster. I think one of the following CAS functions are what the OP is looking for:

quo
rem
quorem
iquo
irem
iquorem

Perhaps check them out it he calculator help.

-road
Find all posts by this user
Quote this message in a reply
06-06-2024, 08:07 AM (This post was last modified: 06-06-2024 03:57 PM by carey.)
Post: #11
RE: Convert Foster Netowrk to Cauer
It seems that my post in which I presented some AI-generated PPL code to help answer the op's question whether the Euclidean Division algorithm can be done on the HP Prime, posted only after noticing no other code had been posted (and included the caveat "For whatever it's worth"), attracted several off-topic AI comments. While it's not surprising that in a "Museum" some folks might look askance at the innovation of AI-generated code, and nothing wrong with that, but some comments seemed to ignore basic facts about this AI-generated code, hence this reply. Interestingly, the AI-generated code remains the only PPL code posted to this thread (on the fascinating network theorems of Foster and Cauer), took only milliseconds to generate, is easy-to-understand, and worked correctly the first time, already a significant improvement over the quality of ChatGPT generated code just a few months ago.

(06-04-2024 11:26 PM)BruceH Wrote:  
(06-04-2024 09:08 PM)carey Wrote:  For whatever it's worth, here's ChatGPT's response...

I hereby declare GodwAIn's law: as any discussion grows longer the probability of a response created using AI approaches 1.

While I'm sure it was an attempt at humor, this play-on-words that confuses including AI-generated code within a human response with an AI-generated response and analogizes to Godwin's law (a "law" that predicts the inevitability that discussions, if continued long enough, will make reference to nazis and Hitler) seems a bit much. (And if heading in that direction, missed the opportunity to mention the interesting but tragic real-life biography of William Cauer that ended in Berlin in 1945).

(06-05-2024 08:12 AM)hp-zl Wrote:  Are you serious about this artificial intelligence or are you just joking?
After all, the above-mentioned the algorithm created by artificial intelligence is pathetic.
It is division with the remainder obtained by laborious subtraction of the divisor (sic!).
If you don't believe it, give him 1000000 and 3 - it will take a while.

But back to the topic, enough of this mockery.

The challenge to try Dividend = 1000000 and Divisor = 3, (presumably intended as a torture test of this code), gives the expected result of Quotient = 333333 and Remainder = 1 in 818 milliseconds using the Windows HP Prime emulator. (Timing was accomplished by asking ChatGPT to generate additional program execution timing code. As with the original code, the timing code worked correctly on the 1st attempt and has now been added to the code in my initial post).

Criticism on the basis of inefficiency of this AI-generated code seems misplaced and ignores: (i) speed-optimized code wasn't prompted for; (ii) the code is easy-to-understand; (iii) the time to generate the code (milliseconds) was of the same order (milliseconds) as code execution time (let that sink in); (iv) for many applications, programmer time is at least as important a consideration as program execution speed.

Imagine an IT manager walking over to a programmer to task her to write a program and she hands back a working prototype before the manager finishes the sentence. It's interesting that a human programmer would be praised as a prodigy for such an accomplishment but AI-generated code is considered "pathetic."

(06-05-2024 08:12 AM)hp-zl Wrote:  PS.
I have always said that with this artificial intelligence it is "much ado about nothing".

"There is no reason anyone would want a computer in their home."
- Ken Olsen, founder of Digital Equipment Corporation (DEC), World Future Society convention, Boston, MA (1977).

(06-05-2024 11:41 AM)roadrunner Wrote:  The CAS function iquorem returns a similar result as that chat GPT program, but way faster.

You realize you're comparing the speed of a CAS function that might have taken man-hours or man-days to write vs an AI-generated function that took milliseconds to generate and wasn't optimized for speed?

======================

Finally, having never attempted PPL programming before, the experience of manually merging the timing code with the original code (both AI-generated) forced me to examine the structure of PPL code and learn a little PPL syntax, enough that I'm now motivated to learn PPL (with an AI-assistant :). In short, there's nothing to fear (this isn't skynet) and one can use AI as little or as much as one chooses, or not at all.
Find all posts by this user
Quote this message in a reply
06-06-2024, 02:04 PM
Post: #12
RE: Convert Foster Netowrk to Cauer
Just saw, I can't spell "network" properly, sigh.

Anyway, checking the reference in the function info, it appears that the discussion is incomplete. I will come back once I get it all sorted out.
Find all posts by this user
Quote this message in a reply
06-06-2024, 05:27 PM
Post: #13
RE: Convert Foster Netowrk to Cauer
@Carey

Take a deep breath and relax.

Recognize that, as of today, intelligence is only human.
Yes, there are databases and search algorithms (even very effective ones), but this cannot be called intelligence.

The fact that a certain group of people, for obvious purposes, started spreading the word: Artificial Intelligence, Artificial Intelligence, etc. - It does not mean anything.
Next, it's just an effective database search.

This is best evidenced by the algorithm you attached, which can be summarized as follows:
"Subtract until the result is less than the second number."

Even an average programming enthusiast will come to the conclusion that this algorithm is poor.
And it won't help to ensure that subtracting threes 333333 times took 818 ms - perhaps even on the newest computer (you're writing about an emulator, not a physical calculator).
(I wonder how long it would take you for the numbers 1000000 and 1).

It is also irrelevant that the above-mentioned the algorithm was found in the database within a millisecond (sic!).

The important thing is that this algorithm is futile.

You could say:
All this artificial intelligence is worth as much as your algorithm.

Remember:
for now intelligence is only human.

Yours faithfully.

PS.
I know it's hard to convince the convinced.
Find all posts by this user
Quote this message in a reply
06-06-2024, 05:49 PM (This post was last modified: 06-06-2024 09:59 PM by carey.)
Post: #14
RE: Convert Foster Netowrk to Cauer
(06-06-2024 05:27 PM)hp-zl Wrote:  @Carey

Take a deep breath and relax.

Recognize that, as of today, intelligence is only human.
Yes, there are databases and search algorithms (even very effective ones), but this cannot be called intelligence.

The fact that a certain group of people, for obvious purposes, started spreading the word: Artificial Intelligence, Artificial Intelligence, etc. - It does not mean anything.
Next, it's just an effective database search.

This is best evidenced by the algorithm you attached, which can be summarized as follows:
"Subtract until the result is less than the second number."

Even an average programming enthusiast will come to the conclusion that this algorithm is poor.
And it won't help to ensure that subtracting threes 333333 times took 818 ms - perhaps even on the newest computer (you're writing about an emulator, not a physical calculator).
(I wonder how long it would take you for the numbers 1000000 and 1).

It is also irrelevant that the above-mentioned the algorithm was found in the database within a millisecond (sic!).

The important thing is that this algorithm is futile.

You could say:
All this artificial intelligence is worth as much as your algorithm.

Remember:
for now intelligence is only human.

Yours faithfully.

PS.
I know it's hard to convince the convinced.

This isn't a general debate about AI, machine vs human intelligence, etc., etc., (which would belong in a different forum) and by fixating on this quick simplistic algorithm generated in the blink of an eye you create a strawman argument that misses the point. One can generate in seconds hundreds of AI-generated algorithms of varying complexity just by prompting for them — this one was not prompted for level of complexity. But I do agree with your last line :)
Find all posts by this user
Quote this message in a reply
06-07-2024, 03:09 AM
Post: #15
RE: Convert Foster Netowrk to Cauer
(06-03-2024 01:48 PM)KeithB Wrote:  
Matlab has a function to do this:
https://www.mathworks.com/help/sps/ref/e...oster.html

Which uses "Euclid Long Division", is this something I can do on the Prime?

By the way “Euclid Long Division” is referenced, my first interpretation is that it’s not integers that are being thought of / assumed as the domain of interest. The process used for integers can be used in wider contexts. One typical example in an introductory university course would be polynomials.

This sort of thing can be done on the HP Prime with the CAS command “quorem”. For example, evaluating

quorem(48*q^3+3,16*q^2+2,q)

gives back

[3*q,-6*q+3]

which indicates that dividing 48*q^3+3 by 16*q^2+2 gives a quotient of 3*q and a remainder of -6*q+3. Iterating over this can let one convert, e.g., rational polynomials to a continued fraction whose terms are polynomials. (Along the same vein as converting a rational number to a continued fraction whose terms are integers.)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)