Map function syntax

I can't quite wrap my brain around how to do this mapping.
I'm controlling a motor, and have an input value that is from 0 to 50. 0 is stop and 50 is 100% speed.
My motor controller need a speed value given to it from 0 (stop) to 57000 (full speed).
I have a POT that reads 0 to 1024 full swing.

I want my POT to control the maximum speed, so that the max speed will be from 50% to 100%. So if the POT is turn all the way one way, my input value (0 to 50) will be mapped to 0 to 57000. If my POT is turned all the way the other way, my input value (0 to 50) will be mapped from 0 to 28500.

without the potval, I have something like:

speed = map(inVal, 0, 50, 0, 57000);

What's the best way to add in the factor from the POT?
thanks.

I'm not quite sure if I understand. If the voltage of the pot is 0V, you want to map to 28500; if it's 5V you want to map to 57000. Anything in between will be proportional?

Some simple maths in the line of below should do

28500 + ((analogvalue * 28500) / 1024)

Thanks. That number will be big is it's 5 volts on the analog. (29184000), so and int won't work, and I should use a long, correct?

I could do something like:

long maxSpeedVal = map(inputVal, 0, 50, 0, 28500 + ((analogvalue * 28500) / 1024));

I'm not sure what the compiler produces; you probably have to cast to long. To get the understanding, use a Serial.print() to print a calculated value. That way I got to below that prints the correct value.

void setup()
{
  Serial.begin(9600);
  int analogvalue = 512;
  long result = 28500 + (((long)analogvalue * 28500) / 1024);
  Serial.println(result);
}

Note: you anyway need a long as 57000 will not fit in an int. Alternative can be use of unsigned int.

void setup()
{
  Serial.begin(9600);
  int analogvalue = 512;
  unsigned int value = 28500 + (((long)analogvalue * 28500) / 1024);
  Serial.println(value);
}