ChatGPT calculations are wrong

I have to second @ruby_coder’s opinion. LLMs’ completion outputs can vary largely based on input, even with temp=0

That being said, there exist AI interfaces for the Wolfram languange which could solve your problem

1 Like

Yes, of course (from wikipedia):

The Wolfram Language is a proprietary, general high-level multi-paradigm programming language developed by Wolfram Research. It emphasizes symbolic computation, functional programming, and rule-based programming and can employ arbitrary structures and data.

So, of course it can do math :slight_smile:

It is also a functional programming / rules-based / symbolic programming system and not a GPT text-autocompletion / prediction engine.

As @Dent implies, but does not mention directly, is that there are better AI tools (which are expert system and rule-based) which do math very well. It is important to understand what a GPT based model is before asking it to expect results which are not part of the design criteria ( see footnote 1).

ChatGPT is a text-prediction engine and is not an expert system and nor is it “rule-based” except some of the proprietary tweaking and moderation which we don’t have a concise list of, to my knowledge.

Footnote:

  1. There is no shortage of people attempting to use GPT models to perform tasks which GPT models are not designed to do as optimally as non GPT based models. This reminds us (every day here in this community) of the old saying goes “When you have a hammer in your hand, everything looks like a nail !” ChatGPT is no exception to this adage.

  2. The above situation is normal in the life-cycle of a new technology, especially during the peak of the “public hype phase”. Over time, developers will get “back to normal” and will realize where GPT-models are optimal and when they are suboptimal.

1 Like

I’m gonna put that adage a step further: From the lips of Adam Savage, who got it from someone else: “In every tool, there is a hammer.” So, like, even if you don’t have a hammer in your hands, you can probably make one out of what you do have, and that isn’t necessarily the greatest idea

1 Like

Hahaha… well said and very timely. Thanks @Dent

Yeah, we are seeing a lot of that everywhere, including this lively community for sure.

:slight_smile:

Fair point. I should have.

One very basic calculation was “calculate the sum of the following numbers: 200 192 187 187 196 190 188 198 204 191 175 198 188 189 186 198 189 187 180 179” The answer given was ‘3,038’ when it should be ‘3.802’. I also asked for the mode of these numbers and got 2 (187). When there are two numbers each with 3 instances.

Sounds like you need some programming exerience! There are many free programming courses available online, but myself and others on the forum have intro guides/courses/etc. especially geared toward LLM-use

Yes, as @Dent kindly mentioned, you will get better results if you “think” like a software developer.

For example:

Prompt:

Write a ruby method to calculate the sum of a string of numbers, given the string of numbers separated by white-space. Output the final sum.

ChatGPT Completion

def sum_numbers(string_of_numbers)
    numbers = string_of_numbers.split(' ').map(&:to_i)
    sum = 0

    numbers.each do |num|
        sum += num
    end

    puts sum
end

Ruby Console Testing… (where I send a lot of my time testing, BTW):

irb(main):027:1* def sum_numbers(string_of_numbers)
irb(main):028:1* numbers = string_of_numbers.split(' ').map(&:to_i)
irb(main):029:1* sum = 0
irb(main):030:1* 
irb(main):031:2* numbers.each do |num|
irb(main):032:2* sum += num
irb(main):033:1* end
irb(main):034:1* 
irb(main):035:1* puts sum
irb(main):036:0> end
=> :sum_numbers
irb(main):037:0> sum_numbers("200 192 187 187 196 190 188 198 204 191 175 198 18
8 189 186 198 189 187 180 179")
3802
=> nil
irb(main):038:0> 

That method is a “good start” but it does not account for all variations of “white space” between numbers, and it just prints and does not return the sum, but it’s a start :+1: It’s easy to either reword the prompt, but faster to just make the changes and move on to the next task at hand.

Second Case:

For your second case, @stuartmitch.home maybe you can try again, changing your prompt using more “programmer geek-speak” ? :slight_smile:

HTH

Note: What many of us have learned about GPT models, is that they make fine assistants but the more domain knowledge a user has, the more valuable / helpful the assistance. As @Dent is trying to say, the more domain knowledge you have (in this case programming / software development) the better the language model can assist.

Same for me.
π * (29^2) * 58,7 should be 155,011
and GPT give me 537,295
:hot_face:

That is because ChatGPT is NOT a calculator, it’s a pre-trained generative transformer based on a large-language model, @Bu

ChatGPT is like a text-autocompletion engine, not a scientific calculator.

Also, here is what Google replies (155090.062052):

Here is what ChatGPT offers:

Let’s test this method in the console:

irb(main):008:1* def evaluate_expression
irb(main):009:1*   pi = 3.14159265358979323846
irb(main):010:1*   result = pi * (29**2) * 58.7
irb(main):011:1*   return result
irb(main):012:0> end
=> :evaluate_expression
irb(main):013:0> 
irb(main):014:0> puts evaluate_expression
155090.06205197124

So, Google gave the answer as: 155090.062052
ChatGPT provided a method with answer: 155090.062052...
@Bu said the answer is : 155,011.

Who is correct ??

Google right for that math, I’m sorry because I’m testing motor engine capacity so I split 1000 to get that result.

And like you said, GPT is not calculator, so that I used GPT to get the formular instead of make the math.

Just hope GPT can make calculator better in the future.

GPT is a language model, a text-completion engine, like when you type you see autocorrections , but it’s on a difference scale.

GPT does math GREAT if you like GPT is an assistant to help you create methods and formulas based on your skill at defining a problem and breaking the problem set down into smaller, manageable pieces.

I use OpenAI to solve complex math and programming tasks for clients daily, because when I write code, I use these OpenAI models to draft initial methods for me. If I needed a scientific calculator, I would use a calculator versus wasting time trying to engineer a prompt for a chatty language model to parse.

GPT models are “generative AIs”, not expert systems and not general purpose “human like” AIs like you see in sci-fi; However, the “good and the bad” of current generation GPT models are that they write like an super-confident expert (great language skills) but they are only predicting text, not actually having an real-world domain knowledge of what they are doing, haha

So, as you can see, you are human @Bu but you made a mistake and posted the incorrect answer to your math expression confidently as if it was “a fact”. So, don’t be too disappointed in a chatty beta language model which cannot behave as calculator without being prompted to generate methods versus doing math like a desktop calculator.

:slight_smile:

God, the day I dreaded would come has arrived. I’m afraid I’ve more chance of being an effective programmer as I have of being a successful surgeon!! That’s a big dark hole I don’t want to fall into.

I will take your advice on watching your YT vids. Thamks to you and Ruby for pointing me inthe right direction.

Hey Ruby, now that I am a coding expert, I thought I’d better point out that you made a mistake in your ruby script!! As all we programmers know, it should have been:

def sum_numbers(string_of_numbers)
numbers = string_of_numbers.split(‘,’).map(&:to_i)
sum = 0

numbers.each do |num|
    sum += num
end

Or at least that what ChatGPT thinks.

I’ve got no chance!!

Cheers…Stu

We have no idea what you actually posted to ChatGPT, since you did not post the exact prompt you used.

I have already fully tested what I posted in the Ruby console and anyone can see it works perfectly :slight_smile:

The following is not ChatGPT data, it is real data in the Ruby console.

irb(main):027:1* def sum_numbers(string_of_numbers)
irb(main):028:1* numbers = string_of_numbers.split(' ').map(&:to_i)
irb(main):029:1* sum = 0
irb(main):030:1* 
irb(main):031:2* numbers.each do |num|
irb(main):032:2* sum += num
irb(main):033:1* end
irb(main):034:1* 
irb(main):035:1* puts sum
irb(main):036:0> end
=> :sum_numbers
irb(main):037:0> sum_numbers("200 192 187 187 196 190 188 198 204 191 175 198 18
8 189 186 198 189 187 180 179")
3802
=> nil
irb(main):038:0> 

You may be confused @stuartmitch.home , ChatGPT is not considered “an authority”… so if you want to confirm Ruby code, you should be familiar with how to code in Ruby, etc.

ChatGPT and all GPT models are tools for domain experts to use, these model DO NOT replace domain experts.

What programing language are you an expert or at least somewhat proficient in @stuartmitch.home ? I will prompt Chatty to produce a method in your area of expertise or experience.

:slight_smile:

This expression in your code you posted @stuartmitch.home is very different than what I posted. You are splitting a string with a comma, but in your original string, there is no comma.

See the issue? We have no idea where you got that code or how you prompted the GPT to generate a completion.

:slight_smile:

Loosen up kid. I was just joking!

Yeah, am I’m really busy and trying to help you as my wife begs me to take her outside in the great weather here.

(And I am not a kid.)

Good luck and take care.

It seems ChatGPT is not actually preforming calculation. It got the answer right sometimes but not all the time.


The same as asking ChatGPT to write a code, its answer doesn’t really match with the result of executing the actual code.

I asked whether ChatGPT can be used as calculator:
“Are you a calculator beside being an wikipedia?”
It answered with:
“… I can also perform more complex calculations using algorithms and formulas. So yes, I can function as a calculator.”

I then asked:
“Give me the ternair of 256”
It answered with:
“The ternary representation of 256 is 22222, where each digit represents a power of 3:
2 * 3^4 + 2 * 3^3 + 2 * 3^2 + 2 * 3^1 + 2 * 3^0 = 2 * 81 + 2 * 27 + 2 * 9 + 2 * 3 + 2 * 1 = 256”
But this is actually 242
It should be 100111
1 * 3^5 + 0 * 3^4 + 0 * 3^3 + 1 * 3^2 + 1 * 3^1 + 1 * 3^0 = 243 + 9 + 3 + 1 = 256

Hi @ErikB

You cannot “believe” anything ChatGPT says. ChatGPT is a chatbot based on generative AI tech.

ChatGPT has no idea about anything, it is simply predicting the next sequence of text based on the current text or prior sequence of text using probabilities.

Please search the forums before posting. Your question / comment has been posted countless time here, to be honest.

ChatGPT is based on a language model, it’s not a computer nor a calculator.

HTH